-
-
Notifications
You must be signed in to change notification settings - Fork 775
Description
Background
When commands in cmds are executed, the commands are printed in green regardless of their exit status:
On the contrary, commands in preconditions are printed only when they failed:
YAML
version: "3"
tasks:
successful_precondition:
preconditions:
- sh: |
echo 0
true # simulates a non-failing precondition
cmds:
- echo 1
failing_precondition:
preconditions:
- sh: |
echo 0
false # simulates a failing precondition
cmds:
- echo 1What I want
Sometimes I want to suppress this and fully customize the output by myself via echo.
cmds has silent: true for this.
While preconditions supports msg key to customize the failure message, it cannot capture the result of the command, making it impossible to notify why or how the precondition failed.
Edit: while clarifying and re-thinking the issue in response to this comment, I noticed preconditions suppressed the commands output regardless of their exit status. This means, even if preconditions ever supported silent: true, dynamically notifying why/how a precondition failed would not be possible. While I should change the title to like "A way to set dynamic failure messages for preconditions to notify why/how they failed?" and rewrite the content, let me close this issue for now because I have currently no time to do that.
Workaround
My current workaround is
-
give up using
preconditions -
and switch to normal
cmds, in which I write a precondition command withsilent: trueset
test:
cmds:
- defer: test '{{.IS_SUBTASK}}' == 1 || notify-send 'done' --title 'task {{.TASK}}' --no-sound
- cmd: |
#ref: |https://github.com/orlangure/gnomock/issues/1225|
id=$(docker inspect orlangure/gnomock-cleaner:latest | jq -r '.[0].Id')
if [[ ${id} == 'sha256:e111a67a34e36f6d5d3ae3359ad54bc2422c936f249115492473325bd4cadcf0' ]]; then
echo 'Check `docker ps` and run this:'
echo '$ docker tag orlangure/gnomock-cleaner:v0.32.0-arm64 orlangure/gnomock-cleaner:latest'
echo
exit 1
fi
silent: true
- go test ./... {{.CLI_ARGS}}