feat: add failfast support for parallel tasks
Implement new failfast behavior to terminate the parent task immediately when any child task fails.
This replaces the previous default behavior, where he execution will stop as soon as any task fails.
New default behavior
By default, when running tasks, the execution of child tasks continues even if one fails.
Restoring Previous Behavior
To restore the previous behavior, you can explicitly set failfast: true or with the flag --failfast.
Example
With this configuration, if task-a fails early, the parent will stop immediately without waiting for task-b or task-c.
version: '3'
tasks:
task-a:
cmds: [ "bash -c 'echo A; sleep 1; exit 1'" ]
task-b:
cmds: [ "bash -c 'echo B; sleep 2; exit 0'" ]
task-c:
cmds: [ "bash -c 'echo C; sleep 3; exit 1'" ]
parent:
deps: [task-a, task-b, task-c]
failfast: true # To restore the previous behavior
Looking forward to seeing how tests go here!
@elvism-lullabot is this defining "fail fast" backwards? To me, failfast: true matches the current behaviour of task. If we set it to false, it would mean we'd "fail slow" and let existing tasks run to completion.
Looking forward to seeing how tests go here!
@elvism-lullabot is this defining "fail fast" backwards? To me,
failfast: truematches the current behaviour of task. If we set it to false, it would mean we'd "fail slow" and let existing tasks run to completion.
I updated the code so that the failfast behavior matches the PR description and desired logic.
Really excited for this. I'm not a maintainer, but I wonder if it would make sense to make failFast default to true, to preserve the existing behaviour, so this could be shipped quicker (wouldn't be a breaking change)?
I have tested these changes and they seem to work as described. Excited for this one to be merged!