From bcefc61da43f4b2cbd610f157ecc4d96b28933e5 Mon Sep 17 00:00:00 2001 From: Georgios Kalpakas Date: Fri, 12 May 2017 11:01:42 +0300 Subject: [PATCH] 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. --- .../scripts-js/lib/upload-server/index-preverify-pr.ts | 8 ++++---- aio/scripts/deploy-preview.sh | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/aio/aio-builds-setup/dockerbuild/scripts-js/lib/upload-server/index-preverify-pr.ts b/aio/aio-builds-setup/dockerbuild/scripts-js/lib/upload-server/index-preverify-pr.ts index cedae675c4..24126d00b1 100644 --- a/aio/aio-builds-setup/dockerbuild/scripts-js/lib/upload-server/index-preverify-pr.ts +++ b/aio/aio-builds-setup/dockerbuild/scripts-js/lib/upload-server/index-preverify-pr.ts @@ -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) { diff --git a/aio/scripts/deploy-preview.sh b/aio/scripts/deploy-preview.sh index 72589e9e91..9e11604aa0 100755 --- a/aio/scripts/deploy-preview.sh +++ b/aio/scripts/deploy-preview.sh @@ -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