Repository navigation
Introduce ScriptTrigger & CommandsTrigger for the Deno plugin - #434
Malaydewangan09 merged 2 commits into
Conversation
|
Same review as #436, because this is the same file with the package and image name swapped. 23 lines differ from the go copy, all cosmetic. Ran it locally: 17/17 pass including the Docker tests. Findings, all of which apply to the other copies too:
#436 already has fixes for the test and the doc wording, worth porting those across rather than re-deriving them. One thing specific to Deno. That one is worth fixing here rather than deferring, since it's small and specific to this module. |
Part of kestra-io#313. plugin-scripts wants every submodule to expose a ScriptTrigger and a CommandsTrigger so a flow can be triggered whenever the underlying script/commands execution completes, with an exit condition deciding whether the trigger fires. plugin-script-deno was missing both. Ports the pattern already established in plugin-script-go and plugin-script-node (the two existing reference implementations checked against): a polling trigger that runs the sub-plugin's Script/Commands task once per poll, matches the rendered exitCondition against either the exit code ('exit N') or a regex/substring against the emitted vars and failure logs, and supports edge mode (default on) to emit only on a not-matching-to-matching transition. - ScriptTrigger wraps io.kestra.plugin.scripts.deno.Script - CommandsTrigger wraps io.kestra.plugin.scripts.deno.Commands - Both default containerImage to 'denoland/deno', matching the existing Script/Commands tasks' default Fixes kestra-io#423
Ports the review fixes from the PowerShell PR and adds the one Deno specific item the reviewer asked for. - ScriptTrigger now exposes the Script task's `permissions` property (same default: --allow-env, --allow-read, --allow-write) and passes it through. Without it a trigger script could never be granted --allow-net, so polling an HTTP endpoint, the obvious use of a Deno polling trigger, always failed under the sandbox. Added an example that polls an endpoint with --allow-net. The task construction moved into a package-private buildTask() so the wiring is unit tested without Docker. - ScriptTriggerTest no longer asserts against a private copy of the matching logic. matchesCondition is package-private and the tests call it on a real ScriptTrigger (CsvSource table for exit codes). - Documented the edge mode limitation instead of leaving it silently broken: lastMatched is a plain field that does not survive the worker's serialize/deserialize round trip, so in a distributed deployment edge mode fires on every matching poll. Code comment, corrected schema descriptions, and a note on the edge test that only proves same-instance dedup. The real fix needs a cross-poll state mechanism shared by the whole plugin family and is tracked separately. - Removed the "failure logs" claim from the docs: a failed run passes null vars, so only 'exit N' can match a failure. - @EqualsAndHashCode.Exclude on lastMatched, with a comment that says only what the exclusion does (equals already falls back to object identity via AbstractTrigger and callSuper=call). - Example intervals PT10S -> PT60S, matching the coded default. Reviewed-by: Malaydewangan09
e866daf to
936ae92
Compare
|
Thanks for the local run and for pointing at the #436 fixes, ported those across (936ae92, rebased onto current main). Deno specific, Ported from #436: Not changed, deliberately:
Unit tests pass locally (15/15 in this module). I still don't have Docker, so the container-backed tests are unrun on my side, though nothing in this change touches their paths apart from the new 🤖 AI-assisted, as noted in the description. |
|
Checked the
So the gap is actually closed, not just wired. The ported fixes all landed: no "failure logs" left in either class, no unqualified "emit only on transitions", Agreed on both deferrals. The Nothing blocking from me. |
Summary
Fixes #423, part of #313.
plugin-scriptswants every submodule to expose aScriptTriggerand aCommandsTrigger, so a flow can be triggered whenever the underlying script/commands execution completes, with an exit condition deciding whether the trigger fires.plugin-script-denowas missing both.Implementation
Ports the pattern already established in
plugin-script-goandplugin-script-node(checked both as reference implementations, per the issue). A polling trigger that:Script/Commandstask once per pollexitConditionagainst either the exit code (exit N) or a regex/substring against the emitted vars and failure logsScriptTriggerwrapsio.kestra.plugin.scripts.deno.Script;CommandsTriggerwrapsio.kestra.plugin.scripts.deno.Commands. Both defaultcontainerImagetodenoland/deno, matching the existingScript/Commandstasks' own default.Testing
ScriptTriggerTestmirrors the pure condition-matching unit tests fromplugin-script-go'sScriptTriggerTest(no Docker required), now calling the real package-privatematchesConditionand covering thepermissionswiring, 15/15 passCommandsTriggerTestmirrorsplugin-script-go's integration-style tests that calltrigger.evaluate(...)directly against a real container run. I don't have Docker available in my sandbox, so I could not run this file locally; it follows the exact same structure already merged and passing inplugin-script-go/plugin-script-node, withdenoland/deno:latestas the image and shell-level commands (exit 1,echo '::{"outputs":...}::') that run the same way regardless of the container's runtime./gradlew :plugin-script-deno:compileJava :plugin-script-deno:compileTestJavasucceeds./gradlew :plugin-script-deno:spotlessCheckfails, but only onCommands.java, which has a pre-existing import-order violation onmainunrelated to this PR🤖 AI-assisted: I used Claude Code to help draft and verify this fix; I reviewed the diff and cross-checked it against the existing Go/Node reference implementations before opening this PR.