-
-
Notifications
You must be signed in to change notification settings - Fork 763
Description
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 1Acceptance criteria: (check indicates whether current behavior fulfills the criteria)
- ✅ Running
task positiveshould not do anything - ✅ Running
task negativeshould fail with exit code 2 - ❌ Running
task test-positiveshould check the precondition - ✅ Running
task test-positiveshould printI am OK - ❌ Running
task test-negativeshould check the precondition - ❌ Running
task test-negativeshould printPrecondition negative failedexit with an error code 1- not sure if it should inherit the error code or not
- ❌ Running
task test-negativeshould not printI am not OK - ❌ Running
task test-invalidshould 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.