task
task copied to clipboard
Allow using tasks in `preconditions` (possibly `status`)
Using task: ...
in preconditions
This feature requests aims to allow using task: ...
property in preconditions
array of a task.
Currently, preconditions
is an array of either string (interpreted as shell commands) or an array of objects with sh
(also interpreted as a shell command) and msg
(interpreted as a string) being printed when given shell command exits with a return code != 0.
Example:
version: '3'
tasks:
positive:
cmd: exit 0
negative:
cmd: exit 2
test-positive:
preconditions:
- task: positive
cmd: echo "I am OK"
test-negative:
preconditions:
- task: negative
msg: Precondition negative failed
cmd: echo "I am not ok"
test-invalid:
preconditions:
- task: positive
sh: exit 1
Acceptance criteria: (check indicates whether current behavior fulfills the criteria)
- ✅ Running
task positive
should not do anything - ✅ Running
task negative
should fail with exit code 2 - ❌ Running
task test-positive
should check the precondition - ✅ Running
task test-positive
should printI am OK
- ❌ Running
task test-negative
should check the precondition - ❌ Running
task test-negative
should printPrecondition negative failed
exit with an error code 1- not sure if it should inherit the error code or not
- ❌ Running
task test-negative
should not printI am not OK
- ❌ Running
task test-invalid
should not be valid- or throw a validation error on running any task, as the file is technically not valid
Backwards compatibility is assured, as this is just an expansion to the existing object used as an array item in preconditions
. Using both sh
and task
should not be valid declaration of a precondition.
Using task: ...
in status
Similiar as above, however it is an expansion to allowed structure for status
, as it currently does not allow objects, but only strings. It is possible to create a new feature request if these two features in one request are a different scope, but I did not want to create a new issue for it and would rather see if the above passes before creating it.
Afterword
I am aware that deps
are already usable, however it is not possible to use --force
to skip them.