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:
Georgios Kalpakas 2017-05-12 11:01:42 +03:00 committed by Igor Minar
parent 569b1e0eb7
commit bcefc61da4
2 changed files with 9 additions and 9 deletions

View File

@ -18,8 +18,8 @@ function _main() {
// Exit codes: // Exit codes:
// - 0: The PR author is a member. // - 0: The PR author is a member.
// - 1: The PR author is not a member. // - 1: An error occurred.
// - 2: An error occurred. // - 2: The PR author is not a member.
buildVerifier.getPrAuthorTeamMembership(pr). buildVerifier.getPrAuthorTeamMembership(pr).
then(({author, isMember}) => { then(({author, isMember}) => {
if (isMember) { if (isMember) {
@ -27,10 +27,10 @@ function _main() {
} else { } else {
const errorMessage = `User '${author}' is not an active member of any of the following teams: ` + const errorMessage = `User '${author}' is not an active member of any of the following teams: ` +
`${allowedTeamSlugs.join(', ')}`; `${allowedTeamSlugs.join(', ')}`;
onError(errorMessage, 1); onError(errorMessage, 2);
} }
}). }).
catch(err => onError(err, 2)); catch(err => onError(err, 1));
} }
function onError(err: string, exitCode: number) { function onError(err: string, exitCode: number) {

View File

@ -27,17 +27,17 @@ case $preverifyExitCode in
# Preconditions met: Deploy # Preconditions met: Deploy
;; ;;
1) 1)
# An error occurred: Fail the script
exit 1
;;
2)
# Preconditions not met: Skip deploy # Preconditions not met: Skip deploy
echo "Skipping deploy because this PR did not meet the preconditions." echo "Skipping deploy because this PR did not meet the preconditions."
exit 0 exit 0
;; ;;
2)
# An error occurred: Fail the script
exit 1
;;
*) *)
# Unexpected exit code: Fail the script # Unexpected exit code: Fail the script
echo "Unexpected preverification exit code: $preverifyExitCode" echo "Unexpected pre-verification exit code: $preverifyExitCode"
exit 1 exit 1
;; ;;
esac esac