ci(aio): deploy previews for all PRs

PRs that could not be automatically verified will not be publicly accessible,
until manually verified.
This commit is contained in:
Georgios Kalpakas 2017-06-19 01:17:10 +03:00 committed by Matias Niemelä
parent f90b35a85e
commit 808bd4af41
1 changed files with 5 additions and 25 deletions

View File

@ -10,7 +10,6 @@ readonly OUTPUT_FILE=/tmp/snapshot.tar.gz
readonly AIO_BUILDS_DOMAIN=ngbuilds.io
readonly UPLOAD_URL=https://$AIO_BUILDS_DOMAIN/create-build/$TRAVIS_PULL_REQUEST/$TRAVIS_PULL_REQUEST_SHA
readonly DEPLOYED_URL=https://pr$TRAVIS_PULL_REQUEST-$TRAVIS_PULL_REQUEST_SHA.$AIO_BUILDS_DOMAIN
readonly PREVERIFY_SCRIPT=aio-builds-setup/scripts/travis-preverify-pr.sh
readonly skipBuild=$([[ "$1" == "--skip-build" ]] && echo "true" || echo "");
readonly relevantChangedFilesCount=$(git diff --name-only $TRAVIS_COMMIT_RANGE | grep -P "^(?:aio|packages)/(?!.*[._]spec\.[jt]s$)" | wc -l)
@ -24,28 +23,6 @@ readonly relevantChangedFilesCount=$(git diff --name-only $TRAVIS_COMMIT_RANGE |
exit 0
fi
# Do not deploy unless this PR meets certain preconditions.
readonly preverifyExitCode=$($PREVERIFY_SCRIPT > /dev/fd/3 && echo 0 || echo $?)
case $preverifyExitCode in
0)
# 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
;;
*)
# Unexpected exit code: Fail the script
echo "Unexpected pre-verification exit code: $preverifyExitCode"
exit 1
;;
esac
# Build the app
if [ "$skipBuild" != "true" ]; then
yarn build
@ -68,6 +45,9 @@ readonly relevantChangedFilesCount=$(git diff --name-only $TRAVIS_COMMIT_RANGE |
exit 1
fi
# Run PWA-score tests
yarn test-pwa-score -- "$DEPLOYED_URL" "$MIN_PWA_SCORE" "$PWA_RESULTS_LOG"
# Run PWA-score tests (unless the deployment is not public yet;
# i.e. it could not be automatically verified).
if [ $httpCode -ne 202 ]; then
yarn test-pwa-score -- "$DEPLOYED_URL" "$MIN_PWA_SCORE" "$PWA_RESULTS_LOG"
fi
)