Skip to content

Commit

Permalink
fix: short cmdless tasks exit when dependencies are done
Browse files Browse the repository at this point in the history
Before the last update (which allowed cmd-less tasks to be short), all
cmd-less tasks were considered "long", and were kept alive until the
run was canceled by something else.

The last update mistakenly preserved this keepalive behavior, even for
"short" cmd-less tasks.
  • Loading branch information
amonks committed Jan 19, 2024
1 parent 2879e8d commit 6f1225d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/run/script_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ func (t *scriptTask) Start(ctx context.Context, stdout io.Writer) error {
t.stdout = stdout

if !t.hasScript() {
<-ctx.Done()
// If this is a "long" task, we want to keep running until the
// run is killed. If this is a "short" task with no script, we
// should consider it done as soon as its dependencies are.
if t.Metadata().Type == "long" {
<-ctx.Done()
}
return nil
}

Expand Down
17 changes: 17 additions & 0 deletions pkg/run/testdata/snapshots/group-short-long/out.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ok

watcher starting
.
invalidating {subtask}

subtask starting
hello
exit ok
invalidating {test}

test starting
exit ok

run done

watcher canceled; stopping
15 changes: 15 additions & 0 deletions pkg/run/testdata/snapshots/group-short-long/tasks.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[[task]]
id="test"
type="short"
dependencies=["subtask"]

[[task]]
id="subtask"
type="short"
cmd="echo hello"
dependencies=["watcher"]

[[task]]
id="watcher"
type="long"
cmd="while true ; do echo . ; sleep 1 ; done"

0 comments on commit 6f1225d

Please sign in to comment.