Thanks for this. It is the sort of thing that I thought I might have to do. It is a shame Actions doesn’t have something built-in yet.
For the majority of tests, I am looking for a 0 exit code, so this would only apply for some tests where I specifically want a failure.
My script only outputs the following 0 (pass), 1 (fatal), 2 (error), 3 (warn) and depending upon the test I will be looking for one of these.
My scripts are all BASH so I will likely create what you have posted in BASH.
Maybe a wrapper script that I can pass parameters that will then run the script and if the script provides the expected exit code with the wrapper will output exit code 0 and exit code 1 for unexpected code.
./exitcode.sh [command] [exitcode]
./exitcode.sh "./script.sh" "1"
Hopefully, there will be an inbuilt option in the future. But for now, I think this should do the trick.