ci(aio): correctly catch PR preview pre-verification errors
Previously, `aio/aio-builds-setup/scripts/travis-preverify-pr.sh` was supposed to exit with 1 if a PR did not meet the preconditions and 2 if an error occurred during pre-verification. It relied on the exit codes of the node script that did the actual work, but didn't account for errors that would be thrown in the `sh` script itself (e.g. if the node script was not available). This caused such errors to appear as non-verified PRs, instead of real errors that should fail the build. This commit swaps the exit codes, so that now a 2 means non-verified PR and 1 designates an error.
This commit is contained in:
parent
569b1e0eb7
commit
bcefc61da4
|
@ -18,8 +18,8 @@ function _main() {
|
|||
|
||||
// Exit codes:
|
||||
// - 0: The PR author is a member.
|
||||
// - 1: The PR author is not a member.
|
||||
// - 2: An error occurred.
|
||||
// - 1: An error occurred.
|
||||
// - 2: The PR author is not a member.
|
||||
buildVerifier.getPrAuthorTeamMembership(pr).
|
||||
then(({author, isMember}) => {
|
||||
if (isMember) {
|
||||
|
@ -27,10 +27,10 @@ function _main() {
|
|||
} else {
|
||||
const errorMessage = `User '${author}' is not an active member of any of the following teams: ` +
|
||||
`${allowedTeamSlugs.join(', ')}`;
|
||||
onError(errorMessage, 1);
|
||||
onError(errorMessage, 2);
|
||||
}
|
||||
}).
|
||||
catch(err => onError(err, 2));
|
||||
catch(err => onError(err, 1));
|
||||
}
|
||||
|
||||
function onError(err: string, exitCode: number) {
|
||||
|
|
|
@ -27,17 +27,17 @@ case $preverifyExitCode in
|
|||
# Preconditions met: Deploy
|
||||
;;
|
||||
1)
|
||||
# An error occurred: Fail the script
|
||||
exit 1
|
||||
;;
|
||||
2)
|
||||
# Preconditions not met: Skip deploy
|
||||
echo "Skipping deploy because this PR did not meet the preconditions."
|
||||
exit 0
|
||||
;;
|
||||
2)
|
||||
# An error occurred: Fail the script
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
# Unexpected exit code: Fail the script
|
||||
echo "Unexpected preverification exit code: $preverifyExitCode"
|
||||
echo "Unexpected pre-verification exit code: $preverifyExitCode"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
Loading…
Reference in New Issue