-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix semver checks #942
Fix semver checks #942
Conversation
6c9c532
to
b744293
Compare
Tested that it works now in #943 |
Not sure if any, as the rest of the script is just a bunch of I'm not sure how to best prevent such errors. I guess we could manually check output of steps of the pipeline using |
I educated myself on bash error handling a little bit and I think we both make it work and make it readable. I applied what I learnt to your code and I think it should look like this after modifications: set -e # So that failed commands exit the script
set -o pipefail # So that if a command in a pipe fails, the whole command fails
echo "output<<SEMVER_STDOUT_EOF" >> $GITHUB_OUTPUT
SEMVER_REV_OUTPUT="$(semver-rev rev="$PR_BASE" 2>&1)" && true # "&& true" preserves exit code but cancels effects of set -e
exitcode=$?
# Weird sed strip ANSI colors from output
# If any of the commands below fail, `set -e` and `set -o pipefail` should exit the script
echo "${SEMVER_REV_OUTPUT}" | tee /proc/self/fd/2 | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" >> $GITHUB_OUTPUT
echo "Semver checks exitcode: " $exitcode
echo "SEMVER_STDOUT_EOF" >> $GITHUB_OUTPUT
echo "exitcode=$exitcode" >> $GITHUB_OUTPUT Note that I didn't test this code, this is just to demonstrate the ideas. |
Are you sure you meant |
I tried it and
If we used
|
Yes, I meant |
b744293
to
0e0a9f6
Compare
Updated the PR according to @piodul 's suggestion |
1129f75
to
9cc7e97
Compare
9cc7e97
to
f8d9869
Compare
@Lorak-mmk although this is already merged, please update the PR description to reflect reality (the "It wouldn't prevent" part looks outdated) |
Previously semver checks CI used
/dev/tty
which seems unavailable in Github Actions.Changed it to
/proc/self/fd/2
which I expect to be available pretty much anywhere.Changed this CI step so that the job fails on errors. It wouldn't prevent #936 , because this command is part of pipeline, so it won't be affected by
set -e
, but I think it's a good change anyway.Fixes: #936
Pre-review checklist
./docs/source/
.Fixes:
annotations to PR description.