From 3b24e0edb66be511acf147b4e0a60cc13376ebc9 Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Wed, 17 Oct 2018 19:19:15 +0300 Subject: [PATCH] build: use CI-provider independent variable names (#26377) PR Close #26377 --- .circleci/config.yml | 46 +++++++++++------ aio/scripts/build-artifacts.sh | 17 +++---- aio/scripts/deploy-to-firebase.sh | 38 +++++++------- aio/scripts/deploy-to-firebase.test.sh | 70 +++++++++++++------------- scripts/build-packages-dist.sh | 6 +-- scripts/ci/env.sh | 11 +++- scripts/ci/payload-size.sh | 23 +++++---- scripts/ci/publish-build-artifacts.sh | 2 +- scripts/ci/test-aio-local.sh | 2 +- scripts/ci/test-aio.sh | 2 +- 10 files changed, 121 insertions(+), 96 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index dfa3535526..0b8eeb242d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,7 +17,22 @@ var_2: &cache_key v2-angular-{{ .Branch }}-{{ checksum "yarn.lock" }}-0.7.0 # Define common ENV vars var_3: &define_env_vars - run: echo "export PROJECT_ROOT=$(pwd)" >> $BASH_ENV + run: + name: Define environment variables + command: | + echo "export PROJECT_ROOT=$(pwd)" | tee -a $BASH_ENV + echo "export CI_AIO_MIN_PWA_SCORE=95" | tee -a $BASH_ENV + # This is the branch being built; e.g. `pull/12345` for PR builds. + echo "export CI_BRANCH=$CIRCLE_BRANCH" | tee -a $BASH_ENV + echo "export CI_COMMIT=$CIRCLE_SHA1" | tee -a $BASH_ENV + # TODO(gkalpak): Fix this. + echo "export CI_COMMIT_RANGE=???" | tee -a $BASH_ENV + echo "export CI_PULL_REQUEST=${CIRCLE_PR_NUMBER:-false}" | tee -a $BASH_ENV + echo "export CI_REPO_NAME=$CIRCLE_PROJECT_REPONAME" | tee -a $BASH_ENV + echo "export CI_REPO_OWNER=$CIRCLE_PROJECT_USERNAME" | tee -a $BASH_ENV + # WARNING: Secrets (do not print). + echo "export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=$AIO_DEPLOY_TOKEN" >> $BASH_ENV + echo "export CI_SECRET_PAYLOAD_FIREBASE_TOKEN=$ANGULAR_PAYLOAD_TOKEN" >> $BASH_ENV # See remote cache documentation in /docs/BAZEL.md var_4: &setup-bazel-remote-cache @@ -29,7 +44,7 @@ var_4: &setup-bazel-remote-cache var_5: &setup_bazel_remote_execution run: name: "Setup bazel RBE remote execution" - command: openssl aes-256-cbc -d -in .circleci/gcp_token -k "${CIRCLE_PROJECT_REPONAME}" -out /home/circleci/.gcp_credentials && echo "export GOOGLE_APPLICATION_CREDENTIALS=/home/circleci/.gcp_credentials" >> $BASH_ENV && sudo bash -c "cat .circleci/rbe-bazel.rc >> /etc/bazel.bazelrc" + command: openssl aes-256-cbc -d -in .circleci/gcp_token -k "$CI_REPO_NAME" -out /home/circleci/.gcp_credentials && echo "export GOOGLE_APPLICATION_CREDENTIALS=/home/circleci/.gcp_credentials" >> $BASH_ENV && sudo bash -c "cat .circleci/rbe-bazel.rc >> /etc/bazel.bazelrc" # Settings common to each job anchor_1: &job_defaults @@ -41,7 +56,7 @@ anchor_1: &job_defaults # Similar to travis behavior, but not quite the same. # See https://discuss.circleci.com/t/1662 anchor_2: &post_checkout - post: git pull --ff-only origin "refs/pull/${CIRCLE_PULL_REQUEST//*pull\//}/merge" + post: git pull --ff-only origin "refs/pull/${CI_PULL_REQUEST//*pull\//}/merge" version: 2 jobs: @@ -49,6 +64,7 @@ jobs: <<: *job_defaults resource_class: xlarge steps: + - *define_env_vars - checkout: <<: *post_checkout - run: sudo cp .circleci/bazel.rc /etc/bazel.bazelrc @@ -137,28 +153,30 @@ jobs: - *setup_bazel_remote_execution - run: bazel test //... --define=compile=aot --build_tag_filters=ivy-aot --test_tag_filters=ivy-aot - # This job should only be run on PR builds, where `CIRCLE_PR_NUMBER` is defined. + # This job should only be run on PR builds, where `CI_PULL_REQUEST` is not `false`. aio_preview: <<: *job_defaults environment: AIO_SNAPSHOT_ARTIFACT_PATH: &aio_preview_artifact_path 'aio/tmp/snapshot.tgz' steps: + - *define_env_vars - checkout: <<: *post_checkout - restore_cache: key: *cache_key - run: yarn install --frozen-lockfile --non-interactive - - run: ./aio/scripts/build-artifacts.sh $AIO_SNAPSHOT_ARTIFACT_PATH $CIRCLE_PR_NUMBER $CIRCLE_SHA1 + - run: ./aio/scripts/build-artifacts.sh $AIO_SNAPSHOT_ARTIFACT_PATH $CI_PULL_REQUEST $CI_COMMIT - store_artifacts: path: *aio_preview_artifact_path # The `destination` needs to be kept in synch with the value of # `AIO_ARTIFACT_PATH` in `aio/aio-builds-setup/Dockerfile` destination: aio/dist/aio-snapshot.tgz - # This job should only be run on PR builds, where `CIRCLE_PR_NUMBER` is defined. + # This job should only be run on PR builds, where `CI_PULL_REQUEST` is not `false`. test_aio_preview: <<: *job_defaults steps: + - *define_env_vars - checkout: <<: *post_checkout - restore_cache: @@ -166,9 +184,7 @@ jobs: - run: yarn install --cwd aio --frozen-lockfile --non-interactive - run: name: Wait for preview and run tests - command: | - source "./scripts/ci/env.sh" print - xvfb-run --auto-servernum node aio/scripts/test-preview.js $CIRCLE_PR_NUMBER $CIRCLE_SHA1 $AIO_MIN_PWA_SCORE + command: xvfb-run --auto-servernum node aio/scripts/test-preview.js $CI_PULL_REQUEST $CI_COMMIT $CI_AIO_MIN_PWA_SCORE # This job exists only for backwards-compatibility with old scripts and tests # that rely on the pre-Bazel dist/packages-dist layout. @@ -223,15 +239,16 @@ jobs: publish_snapshot: <<: *job_defaults steps: + - *define_env_vars # See below - ideally this job should not trigger for non-upstream builds. # But since it does, we have to check this condition. - run: name: Skip this job for Pull Requests and Fork builds # Note, `|| true` on the end makes this step always exit 0 command: '[[ - -v CIRCLE_PR_NUMBER - || "$CIRCLE_PROJECT_USERNAME" != "angular" - || "$CIRCLE_PROJECT_REPONAME" != "angular" + "$CI_PULL_REQUEST" != "false" + || "$CI_REPO_OWNER" != "angular" + || "$CI_REPO_NAME" != "angular" ]] && circleci step halt || true' - checkout: <<: *post_checkout @@ -249,15 +266,14 @@ jobs: aio_monitoring: <<: *job_defaults steps: + - *define_env_vars - checkout: <<: *post_checkout - restore_cache: key: *cache_key - run: name: Run tests against the deployed apps - command: | - source "./scripts/ci/env.sh" print - xvfb-run --auto-servernum ./aio/scripts/test-production.sh $AIO_MIN_PWA_SCORE + command: xvfb-run --auto-servernum ./aio/scripts/test-production.sh $CI_AIO_MIN_PWA_SCORE workflows: version: 2 diff --git a/aio/scripts/build-artifacts.sh b/aio/scripts/build-artifacts.sh index 61d9dfddcd..4997c10bb3 100755 --- a/aio/scripts/build-artifacts.sh +++ b/aio/scripts/build-artifacts.sh @@ -2,13 +2,12 @@ set -eu -o pipefail -source "`dirname $0`/../../scripts/ci/env.sh" print - -readonly INPUT_DIR=dist/ -readonly OUTPUT_FILE=$PROJECT_ROOT/$1 -readonly PR_NUMBER=$2 -readonly PR_LAST_SHA=$3 -readonly deployedUrl=https://pr${PR_NUMBER}-${PR_LAST_SHA:0:7}.ngbuilds.io/ +readonly relativeOutputPath=$1 +readonly prNumber=$2 +readonly prLastSha=$3 +readonly inputDir=dist/ +readonly outputFile=$PROJECT_ROOT/$relativeOutputPath +readonly deployedUrl=https://pr${prNumber}-${prLastSha:0:7}.ngbuilds.io/ ( cd $PROJECT_ROOT/aio @@ -20,6 +19,6 @@ readonly deployedUrl=https://pr${PR_NUMBER}-${PR_LAST_SHA:0:7}.ngbuilds.io/ # deployedUrl must end with / yarn set-opensearch-url $deployedUrl - mkdir -p "`dirname $OUTPUT_FILE`" - tar --create --gzip --directory "$INPUT_DIR" --file "$OUTPUT_FILE" . + mkdir -p "`dirname $outputFile`" + tar --create --gzip --directory "$inputDir" --file "$outputFile" . ) diff --git a/aio/scripts/deploy-to-firebase.sh b/aio/scripts/deploy-to-firebase.sh index 2efa8ee889..81507fd4d3 100755 --- a/aio/scripts/deploy-to-firebase.sh +++ b/aio/scripts/deploy-to-firebase.sh @@ -1,35 +1,35 @@ #!/usr/bin/env bash -# WARNING: FIREBASE_TOKEN should NOT be printed. +# WARNING: CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN should NOT be printed. set +x -eu -o pipefail # Only deploy if this not a PR. PRs are deployed early in `build.sh`. -if [[ $TRAVIS_PULL_REQUEST != "false" ]]; then +if [[ $CI_PULL_REQUEST != "false" ]]; then echo "Skipping deploy because this is a PR build." exit 0 fi # Do not deploy if the current commit is not the latest on its branch. -readonly LATEST_COMMIT=$(git ls-remote origin $TRAVIS_BRANCH | cut -c1-40) -if [[ $TRAVIS_COMMIT != $LATEST_COMMIT ]]; then - echo "Skipping deploy because $TRAVIS_COMMIT is not the latest commit ($LATEST_COMMIT)." +readonly LATEST_COMMIT=$(git ls-remote origin $CI_BRANCH | cut -c1-40) +if [[ $CI_COMMIT != $LATEST_COMMIT ]]; then + echo "Skipping deploy because $CI_COMMIT is not the latest commit ($LATEST_COMMIT)." exit 0 fi # The deployment mode is computed based on the branch we are building -if [[ $TRAVIS_BRANCH == master ]]; then +if [[ $CI_BRANCH == master ]]; then readonly deployEnv=next -elif [[ $TRAVIS_BRANCH == $STABLE_BRANCH ]]; then +elif [[ $CI_BRANCH == $STABLE_BRANCH ]]; then readonly deployEnv=stable else # Extract the major versions from the branches, e.g. the 4 from 4.3.x - readonly majorVersion=${TRAVIS_BRANCH%%.*} + readonly majorVersion=${CI_BRANCH%%.*} readonly majorVersionStable=${STABLE_BRANCH%%.*} # Do not deploy if the major version is not less than the stable branch major version if [[ !( "$majorVersion" < "$majorVersionStable" ) ]]; then - echo "Skipping deploy of branch \"${TRAVIS_BRANCH}\" to firebase." - echo "We only deploy archive branches with the major version less than the stable branch: \"${STABLE_BRANCH}\"" + echo "Skipping deploy of branch \"$CI_BRANCH\" to firebase." + echo "We only deploy archive branches with the major version less than the stable branch: \"$STABLE_BRANCH\"" exit 0 fi @@ -46,9 +46,9 @@ else ) # Do not deploy as it is not the latest branch for the given major version - if [[ $TRAVIS_BRANCH != $mostRecentMinorVersion ]]; then - echo "Skipping deploy of branch \"${TRAVIS_BRANCH}\" to firebase." - echo "There is a more recent branch with the same major version: \"${mostRecentMinorVersion}\"" + if [[ $CI_BRANCH != $mostRecentMinorVersion ]]; then + echo "Skipping deploy of branch \"$CI_BRANCH\" to firebase." + echo "There is a more recent branch with the same major version: \"$mostRecentMinorVersion\"" exit 0 fi @@ -59,21 +59,21 @@ case $deployEnv in next) readonly projectId=aio-staging readonly deployedUrl=https://next.angular.io/ - readonly firebaseToken=$FIREBASE_TOKEN + readonly firebaseToken=$CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN ;; stable) readonly projectId=angular-io readonly deployedUrl=https://angular.io/ - readonly firebaseToken=$FIREBASE_TOKEN + readonly firebaseToken=$CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN ;; archive) readonly projectId=v${majorVersion}-angular-io readonly deployedUrl=https://v${majorVersion}.angular.io/ - readonly firebaseToken=$FIREBASE_TOKEN + readonly firebaseToken=$CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN ;; esac -echo "Git branch : $TRAVIS_BRANCH" +echo "Git branch : $CI_BRANCH" echo "Build/deploy mode : $deployEnv" echo "Firebase project : $projectId" echo "Deployment URL : $deployedUrl" @@ -101,8 +101,8 @@ fi # Deploy to Firebase firebase use "$projectId" --token "$firebaseToken" - firebase deploy --message "Commit: $TRAVIS_COMMIT" --non-interactive --token "$firebaseToken" + firebase deploy --message "Commit: $CI_COMMIT" --non-interactive --token "$firebaseToken" # Run PWA-score tests - yarn test-pwa-score "$deployedUrl" "$AIO_MIN_PWA_SCORE" + yarn test-pwa-score "$deployedUrl" "$CI_AIO_MIN_PWA_SCORE" ) diff --git a/aio/scripts/deploy-to-firebase.test.sh b/aio/scripts/deploy-to-firebase.test.sh index 0ffea8e128..b3586138f5 100755 --- a/aio/scripts/deploy-to-firebase.test.sh +++ b/aio/scripts/deploy-to-firebase.test.sh @@ -17,7 +17,7 @@ function check { ( echo ===== master - skip deploy - pull request actual=$( - export TRAVIS_PULL_REQUEST=true + export CI_PULL_REQUEST=true `dirname $0`/deploy-to-firebase.sh --dry-run ) expected="Skipping deploy because this is a PR build." @@ -27,10 +27,10 @@ function check { ( echo ===== master - deploy success actual=$( - export TRAVIS_PULL_REQUEST=false - export TRAVIS_BRANCH=master - export TRAVIS_COMMIT=$(git ls-remote origin master | cut -c-40) - export FIREBASE_TOKEN=XXXXX + export CI_PULL_REQUEST=false + export CI_BRANCH=master + export CI_COMMIT=$(git ls-remote origin master | cut -c-40) + export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX `dirname $0`/deploy-to-firebase.sh --dry-run ) expected="Git branch : master @@ -43,9 +43,9 @@ Deployment URL : https://next.angular.io/" ( echo ===== master - skip deploy - commit not HEAD actual=$( - export TRAVIS_PULL_REQUEST=false - export TRAVIS_BRANCH=master - export TRAVIS_COMMIT=DUMMY_TEST_COMMIT + export CI_PULL_REQUEST=false + export CI_BRANCH=master + export CI_COMMIT=DUMMY_TEST_COMMIT `dirname $0`/deploy-to-firebase.sh --dry-run ) expected="Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ($(git ls-remote origin master | cut -c1-40))." @@ -55,11 +55,11 @@ Deployment URL : https://next.angular.io/" ( echo ===== stable - deploy success actual=$( - export TRAVIS_PULL_REQUEST=false - export TRAVIS_BRANCH=4.3.x + export CI_PULL_REQUEST=false + export CI_BRANCH=4.3.x export STABLE_BRANCH=4.3.x - export TRAVIS_COMMIT=$(git ls-remote origin 4.3.x | cut -c-40) - export FIREBASE_TOKEN=XXXXX + export CI_COMMIT=$(git ls-remote origin 4.3.x | cut -c-40) + export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX `dirname $0`/deploy-to-firebase.sh --dry-run ) expected="Git branch : 4.3.x @@ -72,10 +72,10 @@ Deployment URL : https://angular.io/" ( echo ===== stable - skip deploy - commit not HEAD actual=$( - export TRAVIS_PULL_REQUEST=false - export TRAVIS_BRANCH=4.3.x + export CI_PULL_REQUEST=false + export CI_BRANCH=4.3.x export STABLE_BRANCH=4.3.x - export TRAVIS_COMMIT=DUMMY_TEST_COMMIT + export CI_COMMIT=DUMMY_TEST_COMMIT `dirname $0`/deploy-to-firebase.sh --dry-run ) expected="Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ($(git ls-remote origin 4.3.x | cut -c1-40))." @@ -85,11 +85,11 @@ Deployment URL : https://angular.io/" ( echo ===== archive - deploy success actual=$( - export TRAVIS_PULL_REQUEST=false - export TRAVIS_BRANCH=2.4.x + export CI_PULL_REQUEST=false + export CI_BRANCH=2.4.x export STABLE_BRANCH=4.3.x - export TRAVIS_COMMIT=$(git ls-remote origin 2.4.x | cut -c-40) - export FIREBASE_TOKEN=XXXXX + export CI_COMMIT=$(git ls-remote origin 2.4.x | cut -c-40) + export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX `dirname $0`/deploy-to-firebase.sh --dry-run ) expected="Git branch : 2.4.x @@ -102,11 +102,11 @@ Deployment URL : https://v2.angular.io/" ( echo ===== archive - skip deploy - commit not HEAD actual=$( - export TRAVIS_PULL_REQUEST=false - export TRAVIS_BRANCH=2.4.x + export CI_PULL_REQUEST=false + export CI_BRANCH=2.4.x export STABLE_BRANCH=4.3.x - export TRAVIS_COMMIT=DUMMY_TEST_COMMIT - export FIREBASE_TOKEN=XXXXX + export CI_COMMIT=DUMMY_TEST_COMMIT + export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX `dirname $0`/deploy-to-firebase.sh --dry-run ) expected="Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ($(git ls-remote origin 2.4.x | cut -c1-40))." @@ -116,11 +116,11 @@ Deployment URL : https://v2.angular.io/" ( echo ===== archive - skip deploy - major version too high, lower minor actual=$( - export TRAVIS_PULL_REQUEST=false - export TRAVIS_BRANCH=2.1.x + export CI_PULL_REQUEST=false + export CI_BRANCH=2.1.x export STABLE_BRANCH=2.2.x - export TRAVIS_COMMIT=$(git ls-remote origin 2.1.x | cut -c-40) - export FIREBASE_TOKEN=XXXXX + export CI_COMMIT=$(git ls-remote origin 2.1.x | cut -c-40) + export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX `dirname $0`/deploy-to-firebase.sh --dry-run ) expected="Skipping deploy of branch \"2.1.x\" to firebase. @@ -131,11 +131,11 @@ We only deploy archive branches with the major version less than the stable bran ( echo ===== archive - skip deploy - major version too high, higher minor actual=$( - export TRAVIS_PULL_REQUEST=false - export TRAVIS_BRANCH=2.4.x + export CI_PULL_REQUEST=false + export CI_BRANCH=2.4.x export STABLE_BRANCH=2.2.x - export TRAVIS_COMMIT=$(git ls-remote origin 2.4.x | cut -c-40) - export FIREBASE_TOKEN=XXXXX + export CI_COMMIT=$(git ls-remote origin 2.4.x | cut -c-40) + export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX `dirname $0`/deploy-to-firebase.sh --dry-run ) expected="Skipping deploy of branch \"2.4.x\" to firebase. @@ -146,11 +146,11 @@ We only deploy archive branches with the major version less than the stable bran ( echo ===== archive - skip deploy - minor version too low actual=$( - export TRAVIS_PULL_REQUEST=false - export TRAVIS_BRANCH=2.1.x + export CI_PULL_REQUEST=false + export CI_BRANCH=2.1.x export STABLE_BRANCH=4.3.x - export TRAVIS_COMMIT=$(git ls-remote origin 2.1.x | cut -c-40) - export FIREBASE_TOKEN=XXXXX + export CI_COMMIT=$(git ls-remote origin 2.1.x | cut -c-40) + export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX `dirname $0`/deploy-to-firebase.sh --dry-run ) expected="Skipping deploy of branch \"2.1.x\" to firebase. diff --git a/scripts/build-packages-dist.sh b/scripts/build-packages-dist.sh index 32d5d3623b..ae52da383e 100755 --- a/scripts/build-packages-dist.sh +++ b/scripts/build-packages-dist.sh @@ -56,9 +56,9 @@ buildTargetPackages "$BAZEL_TARGETS" "dist/packages-dist" "legacy" "Production" # snapshots. # This logic matches what we use in the .circleci/config.yml file to short- # circuit execution of the publish-packages job. -[[ "${CIRCLE_PR_NUMBER-}" != "" - || "${CIRCLE_PROJECT_USERNAME-}" != "angular" - || "${CIRCLE_PROJECT_REPONAME-}" != "angular" +[[ "${CI_PULL_REQUEST-}" != "false" + || "${CI_REPO_OWNER-}" != "angular" + || "${CI_REPO_NAME-}" != "angular" ]] && exit 0 buildTargetPackages "$BAZEL_TARGETS" "dist/packages-dist-ivy-aot" "aot" "Ivy AOT" diff --git a/scripts/ci/env.sh b/scripts/ci/env.sh index b90fc4e47b..5bad3624e3 100755 --- a/scripts/ci/env.sh +++ b/scripts/ci/env.sh @@ -40,8 +40,15 @@ setEnvVar CHROMIUM_VERSION 561733 # Chrome 68 linux stable, see https://www.chr setEnvVar CHROMEDRIVER_VERSION_ARG "--versions.chrome 2.41" setEnvVar SAUCE_CONNECT_VERSION 4.4.9 setEnvVar ANGULAR_CLI_VERSION 1.6.3 -setEnvVar AIO_MIN_PWA_SCORE 95 +setEnvVar CI_AIO_MIN_PWA_SCORE 95 +setEnvVar CI_BRANCH $TRAVIS_BRANCH +setEnvVar CI_COMMIT $TRAVIS_COMMIT +setEnvVar CI_COMMIT_RANGE $TRAVIS_COMMIT_RANGE +setEnvVar CI_PULL_REQUEST $TRAVIS_PULL_REQUEST setEnvVar PROJECT_ROOT $(cd ${thisDir}/../..; pwd) +# WARNING: Secrets (do not print). +export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=$FIREBASE_TOKEN +export CI_SECRET_PAYLOAD_FIREBASE_TOKEN=$ANGULAR_PAYLOAD_FIREBASE_TOKEN if [[ ${TRAVIS:-} ]]; then case ${CI_MODE} in @@ -83,7 +90,7 @@ if [[ ${TRAVIS:-} ]]; then # In order to have a meaningful SauceLabs badge on the repo page, # the angular2-ci account is used only when pushing commits to master; # in all other cases, the regular angular-ci account is used. - if [ "${TRAVIS_PULL_REQUEST}" = "false" ] && [ "${TRAVIS_BRANCH}" = "master" ]; then + if [ "${CI_PULL_REQUEST}" = "false" ] && [ "${CI_BRANCH}" = "master" ]; then setEnvVar SAUCE_USERNAME angular2-ci # Not using use `setEnvVar` so that we don't print the key. export SAUCE_ACCESS_KEY=693ebc16208a-0b5b-1614-8d66-a2662f4e diff --git a/scripts/ci/payload-size.sh b/scripts/ci/payload-size.sh index 28dfd7346e..3c0e410bf1 100644 --- a/scripts/ci/payload-size.sh +++ b/scripts/ci/payload-size.sh @@ -28,7 +28,10 @@ calculateSize() { checkSize() { name="$1" limitFile="$2" - node ${PROJECT_ROOT}/scripts/ci/payload-size.js $limitFile $name $TRAVIS_BRANCH $TRAVIS_COMMIT + + # In non-PR builds, `CI_BRANCH` is the branch being built (e.g. `pull/12345`), not the targeted branch. + # Thus, PRs will fall back to using the size limits for `master`. + node ${PROJECT_ROOT}/scripts/ci/payload-size.js $limitFile $name $CI_BRANCH $CI_COMMIT } # Write timestamp to global variable `$payloadData`. @@ -41,9 +44,9 @@ addTimestamp() { # Write travis commit message to global variable `$payloadData`. addMessage() { # Grab the set of SHAs for the message. This can fail when you force push or do initial build - # because $TRAVIS_COMMIT_RANGE will contain the previous SHA which will not be in the + # because $CI_COMMIT_RANGE may contain the previous SHA which will not be in the # force push or commit, hence we default to last commit. - message=$(git log --oneline $TRAVIS_COMMIT_RANGE -- || git log --oneline -n1) + message=$(git log --oneline $CI_COMMIT_RANGE -- || git log --oneline -n1) message=$(echo $message | sed 's/\\/\\\\/g' | sed 's/"/\\"/g') payloadData="$payloadData\"message\": \"$message\"" } @@ -53,8 +56,8 @@ addMessage() { # Update the change source in global variable `$payloadData`. addChange() { yarnChanged=false - allChangedFiles=$(git diff --name-only $TRAVIS_COMMIT_RANGE $parentDir | wc -l) - allChangedFileNames=$(git diff --name-only $TRAVIS_COMMIT_RANGE $parentDir) + allChangedFiles=$(git diff --name-only $CI_COMMIT_RANGE $parentDir | wc -l) + allChangedFileNames=$(git diff --name-only $CI_COMMIT_RANGE $parentDir) if [[ $allChangedFileNames == *"yarn.lock"* ]]; then yarnChanged=true @@ -82,14 +85,14 @@ uploadData() { echo $payloadData > /tmp/current.log - readonly safeBranchName=$(echo $TRAVIS_BRANCH | sed -e 's/\./_/g') + readonly safeBranchName=$(echo $CI_BRANCH | sed -e 's/\./_/g') - if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]; then - readonly dbPath=/payload/$name/$safeBranchName/$TRAVIS_COMMIT + if [[ "$CI_PULL_REQUEST" == "false" ]]; then + readonly dbPath=/payload/$name/$safeBranchName/$CI_COMMIT - # WARNING: FIREBASE_TOKEN should NOT be printed. + # WARNING: CI_SECRET_PAYLOAD_FIREBASE_TOKEN should NOT be printed. set +x - $NODE_MODULES_BIN/firebase database:update --data "$payloadData" --project $PROJECT_NAME --confirm --token "$ANGULAR_PAYLOAD_FIREBASE_TOKEN" $dbPath + $NODE_MODULES_BIN/firebase database:update --data "$payloadData" --project $PROJECT_NAME --confirm --token "$CI_SECRET_PAYLOAD_FIREBASE_TOKEN" $dbPath fi } diff --git a/scripts/ci/publish-build-artifacts.sh b/scripts/ci/publish-build-artifacts.sh index 443cbaffda..ebf673c1ed 100755 --- a/scripts/ci/publish-build-artifacts.sh +++ b/scripts/ci/publish-build-artifacts.sh @@ -127,7 +127,7 @@ function publishAllBuilds() { } # See docs/DEVELOPER.md for help -CUR_BRANCH=${CIRCLE_BRANCH:-$(git symbolic-ref --short HEAD)} +CUR_BRANCH=${CI_BRANCH:-$(git symbolic-ref --short HEAD)} if [ $# -gt 0 ]; then ORG=$1 publishAllBuilds "ssh" diff --git a/scripts/ci/test-aio-local.sh b/scripts/ci/test-aio-local.sh index 7b68bad9df..f275ebca72 100755 --- a/scripts/ci/test-aio-local.sh +++ b/scripts/ci/test-aio-local.sh @@ -15,7 +15,7 @@ source ${thisDir}/_travis-fold.sh # Run PWA-score tests # (Run before unit and e2e tests, which destroy the `dist/` directory.) travisFoldStart "test.aio.pwaScore" - yarn test-pwa-score-localhost $AIO_MIN_PWA_SCORE + yarn test-pwa-score-localhost $CI_AIO_MIN_PWA_SCORE travisFoldEnd "test.aio.pwaScore" # Run unit tests diff --git a/scripts/ci/test-aio.sh b/scripts/ci/test-aio.sh index 858a91a5dc..1c557050b9 100755 --- a/scripts/ci/test-aio.sh +++ b/scripts/ci/test-aio.sh @@ -21,7 +21,7 @@ source ${thisDir}/_travis-fold.sh # Run PWA-score tests # (Run before unit and e2e tests, which destroy the `dist/` directory.) travisFoldStart "test.aio.pwaScore" - yarn test-pwa-score-localhost $AIO_MIN_PWA_SCORE + yarn test-pwa-score-localhost $CI_AIO_MIN_PWA_SCORE travisFoldEnd "test.aio.pwaScore" # Check the bundle sizes.