diff --git a/.circleci/config.yml b/.circleci/config.yml index 04bf08554a..5a598253fc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -162,7 +162,7 @@ jobs: - *setup_bazel_remote_execution - run: bazel query --output=label //... | xargs bazel test --define=compile=local --build_tag_filters=ivy-local --test_tag_filters=-manual,ivy-local - test_aio: + test_and_deploy_aio: <<: *job_defaults steps: - *define_env_vars @@ -188,6 +188,9 @@ jobs: - run: xvfb-run --auto-servernum yarn --cwd aio e2e # Run unit tests for Firebase redirects - run: yarn --cwd aio redirects-test + # Deploy angular.io to production (if necessary) + - run: echo "export CI_STABLE_BRANCH=$(npm info @angular/core dist-tags.latest | sed -r 's/^\s*([0-9]+\.[0-9]+)\.[0-9]+.*$/\1.x/')" | tee -a $BASH_ENV + - run: yarn --cwd aio deploy-production test_aio_local: <<: *job_defaults @@ -393,7 +396,7 @@ workflows: - test_ivy_jit - test_ivy_aot - build-packages-dist - - test_aio + - test_and_deploy_aio - test_aio_local: requires: - build-packages-dist diff --git a/.travis.yml b/.travis.yml index c9a19c018e..55a0a5227b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,10 +30,6 @@ env: # GITHUB_TOKEN_ANGULAR= # This is needed for the e2e Travis matrix task to publish packages to github for continuous packages delivery. - secure: "aCdHveZuY8AT4Jr1JoJB4LxZsnGWRe/KseZh1YXYe5UtufFCtTVHvUcLn0j2aLBF0KpdyS+hWf0i4np9jthKu2xPKriefoPgCMpisYeC0MFkwbmv+XlgkUbgkgVZMGiVyX7DCYXVahxIoOUjVMEDCbNiHTIrfEuyq24U3ok2tHc=" - # FIREBASE_TOKEN - # This is needed for publishing builds to the "aio-staging" and "angular-io" firebase projects. - # This token was generated using the aio-deploy@angular.io account using `firebase login:ci` and password from valentine - - secure: "L5CyQmpwWtoR4Qi4xlWQh/cL1M6ZeJL4W4QAr4HdKFMgYt9h+Whqkymyh2NxwmCbPvWa7yUd+OiLQUDCY7L2VIg16hTwoe2CgYDyQA0BEwLzxtRrJXl93TfwMlrUx5JSIzAccD6D4sjtz8kSFMomK2Nls33xOXOukwyhVMjd0Cg=" matrix: # Order: a slower build first, so that we don't occupy an idle travis worker waiting for others to complete. - CI_MODE=e2e @@ -66,8 +62,6 @@ install: script: - ./scripts/ci/build.sh - ./scripts/ci/test.sh - # deploy is part of 'script' and not 'after_success' so that we fail the build if the deployment fails - - ./scripts/ci/deploy.sh - ./scripts/ci/angular.sh # all the scripts under this line will not quickly abort in case ${TRAVIS_TEST_RESULT} is 1 (job failure) - ./scripts/ci/cleanup.sh diff --git a/aio/scripts/deploy-to-firebase.sh b/aio/scripts/deploy-to-firebase.sh index 81507fd4d3..bae80dcf07 100755 --- a/aio/scripts/deploy-to-firebase.sh +++ b/aio/scripts/deploy-to-firebase.sh @@ -3,33 +3,39 @@ # 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`. +# Do not deploy if we are running in a fork. +if [[ "$CI_REPO_OWNER/$CI_REPO_NAME" != "angular/angular" ]]; then + echo "Skipping deploy because this is not angular/angular." + exit 0 +fi + +# Do not deploy if this is a PR. PRs are deployed in the `aio_preview` CircleCI job. 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 $CI_BRANCH | cut -c1-40) -if [[ $CI_COMMIT != $LATEST_COMMIT ]]; then - echo "Skipping deploy because $CI_COMMIT is not the latest commit ($LATEST_COMMIT)." +readonly latestCommit=$(git ls-remote origin $CI_BRANCH | cut -c1-40) +if [[ $CI_COMMIT != $latestCommit ]]; then + echo "Skipping deploy because $CI_COMMIT is not the latest commit ($latestCommit)." exit 0 fi # The deployment mode is computed based on the branch we are building if [[ $CI_BRANCH == master ]]; then readonly deployEnv=next -elif [[ $CI_BRANCH == $STABLE_BRANCH ]]; then +elif [[ $CI_BRANCH == $CI_STABLE_BRANCH ]]; then readonly deployEnv=stable else # Extract the major versions from the branches, e.g. the 4 from 4.3.x readonly majorVersion=${CI_BRANCH%%.*} - readonly majorVersionStable=${STABLE_BRANCH%%.*} + readonly majorVersionStable=${CI_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 \"$CI_BRANCH\" to firebase." - echo "We only deploy archive branches with the major version less than the stable branch: \"$STABLE_BRANCH\"" + echo "We only deploy archive branches with the major version less than the stable branch: \"$CI_STABLE_BRANCH\"" exit 0 fi diff --git a/aio/scripts/deploy-to-firebase.test.sh b/aio/scripts/deploy-to-firebase.test.sh index b3586138f5..575cab280d 100755 --- a/aio/scripts/deploy-to-firebase.test.sh +++ b/aio/scripts/deploy-to-firebase.test.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash set +x -eu -o pipefail +readonly deployToFirebaseDryRun="`dirname $0`/deploy-to-firebase.sh --dry-run" + function check { if [[ $1 == $2 ]]; then echo Pass @@ -14,11 +16,38 @@ function check { exit 1 } +( + echo ===== master - skip deploy - not angular + actual=$( + export BASH_ENV=/dev/null + export CI_REPO_OWNER=angular + export CI_REPO_NAME=notangular + $deployToFirebaseDryRun + ) + expected="Skipping deploy because this is not angular/angular." + check "$actual" "$expected" +) + +( + echo ===== master - skip deploy - angular fork + actual=$( + export BASH_ENV=/dev/null + export CI_REPO_OWNER=notangular + export CI_REPO_NAME=angular + $deployToFirebaseDryRun + ) + expected="Skipping deploy because this is not angular/angular." + check "$actual" "$expected" +) + ( echo ===== master - skip deploy - pull request actual=$( + export BASH_ENV=/dev/null + export CI_REPO_OWNER=angular + export CI_REPO_NAME=angular export CI_PULL_REQUEST=true - `dirname $0`/deploy-to-firebase.sh --dry-run + $deployToFirebaseDryRun ) expected="Skipping deploy because this is a PR build." check "$actual" "$expected" @@ -27,11 +56,14 @@ function check { ( echo ===== master - deploy success actual=$( + export BASH_ENV=/dev/null + export CI_REPO_OWNER=angular + export CI_REPO_NAME=angular export CI_PULL_REQUEST=false export CI_BRANCH=master - export CI_COMMIT=$(git ls-remote origin master | cut -c-40) + export CI_COMMIT=$(git ls-remote origin master | cut -c1-40) export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX - `dirname $0`/deploy-to-firebase.sh --dry-run + $deployToFirebaseDryRun ) expected="Git branch : master Build/deploy mode : next @@ -43,10 +75,13 @@ Deployment URL : https://next.angular.io/" ( echo ===== master - skip deploy - commit not HEAD actual=$( + export BASH_ENV=/dev/null + export CI_REPO_OWNER=angular + export CI_REPO_NAME=angular export CI_PULL_REQUEST=false export CI_BRANCH=master export CI_COMMIT=DUMMY_TEST_COMMIT - `dirname $0`/deploy-to-firebase.sh --dry-run + $deployToFirebaseDryRun ) expected="Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ($(git ls-remote origin master | cut -c1-40))." check "$actual" "$expected" @@ -55,12 +90,15 @@ Deployment URL : https://next.angular.io/" ( echo ===== stable - deploy success actual=$( + export BASH_ENV=/dev/null + export CI_REPO_OWNER=angular + export CI_REPO_NAME=angular export CI_PULL_REQUEST=false export CI_BRANCH=4.3.x - export STABLE_BRANCH=4.3.x - export CI_COMMIT=$(git ls-remote origin 4.3.x | cut -c-40) + export CI_STABLE_BRANCH=4.3.x + export CI_COMMIT=$(git ls-remote origin 4.3.x | cut -c1-40) export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX - `dirname $0`/deploy-to-firebase.sh --dry-run + $deployToFirebaseDryRun ) expected="Git branch : 4.3.x Build/deploy mode : stable @@ -72,11 +110,14 @@ Deployment URL : https://angular.io/" ( echo ===== stable - skip deploy - commit not HEAD actual=$( + export BASH_ENV=/dev/null + export CI_REPO_OWNER=angular + export CI_REPO_NAME=angular export CI_PULL_REQUEST=false export CI_BRANCH=4.3.x - export STABLE_BRANCH=4.3.x + export CI_STABLE_BRANCH=4.3.x export CI_COMMIT=DUMMY_TEST_COMMIT - `dirname $0`/deploy-to-firebase.sh --dry-run + $deployToFirebaseDryRun ) expected="Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ($(git ls-remote origin 4.3.x | cut -c1-40))." check "$actual" "$expected" @@ -85,12 +126,15 @@ Deployment URL : https://angular.io/" ( echo ===== archive - deploy success actual=$( + export BASH_ENV=/dev/null + export CI_REPO_OWNER=angular + export CI_REPO_NAME=angular export CI_PULL_REQUEST=false export CI_BRANCH=2.4.x - export STABLE_BRANCH=4.3.x - export CI_COMMIT=$(git ls-remote origin 2.4.x | cut -c-40) + export CI_STABLE_BRANCH=4.3.x + export CI_COMMIT=$(git ls-remote origin 2.4.x | cut -c1-40) export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX - `dirname $0`/deploy-to-firebase.sh --dry-run + $deployToFirebaseDryRun ) expected="Git branch : 2.4.x Build/deploy mode : archive @@ -102,12 +146,15 @@ Deployment URL : https://v2.angular.io/" ( echo ===== archive - skip deploy - commit not HEAD actual=$( + export BASH_ENV=/dev/null + export CI_REPO_OWNER=angular + export CI_REPO_NAME=angular export CI_PULL_REQUEST=false export CI_BRANCH=2.4.x - export STABLE_BRANCH=4.3.x + export CI_STABLE_BRANCH=4.3.x export CI_COMMIT=DUMMY_TEST_COMMIT export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX - `dirname $0`/deploy-to-firebase.sh --dry-run + $deployToFirebaseDryRun ) expected="Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ($(git ls-remote origin 2.4.x | cut -c1-40))." check "$actual" "$expected" @@ -116,12 +163,15 @@ Deployment URL : https://v2.angular.io/" ( echo ===== archive - skip deploy - major version too high, lower minor actual=$( + export BASH_ENV=/dev/null + export CI_REPO_OWNER=angular + export CI_REPO_NAME=angular export CI_PULL_REQUEST=false export CI_BRANCH=2.1.x - export STABLE_BRANCH=2.2.x + export CI_STABLE_BRANCH=2.2.x 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 + $deployToFirebaseDryRun ) expected="Skipping deploy of branch \"2.1.x\" to firebase. We only deploy archive branches with the major version less than the stable branch: \"2.2.x\"" @@ -131,12 +181,15 @@ 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 BASH_ENV=/dev/null + export CI_REPO_OWNER=angular + export CI_REPO_NAME=angular export CI_PULL_REQUEST=false export CI_BRANCH=2.4.x - export STABLE_BRANCH=2.2.x + export CI_STABLE_BRANCH=2.2.x 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 + $deployToFirebaseDryRun ) expected="Skipping deploy of branch \"2.4.x\" to firebase. We only deploy archive branches with the major version less than the stable branch: \"2.2.x\"" @@ -146,12 +199,15 @@ We only deploy archive branches with the major version less than the stable bran ( echo ===== archive - skip deploy - minor version too low actual=$( + export BASH_ENV=/dev/null + export CI_REPO_OWNER=angular + export CI_REPO_NAME=angular export CI_PULL_REQUEST=false export CI_BRANCH=2.1.x - export STABLE_BRANCH=4.3.x + export CI_STABLE_BRANCH=4.3.x 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 + $deployToFirebaseDryRun ) expected="Skipping deploy of branch \"2.1.x\" to firebase. There is a more recent branch with the same major version: \"2.4.x\"" diff --git a/scripts/ci/deploy.sh b/scripts/ci/deploy.sh deleted file mode 100755 index ba674a265d..0000000000 --- a/scripts/ci/deploy.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash - -set -u -e -o pipefail - -# Setup environment -readonly thisDir=$(cd $(dirname $0); pwd) -source ${thisDir}/_travis-fold.sh - - -# If the previous commands in the `script` section of .travis.yaml failed, then abort. -# The variable is not set in early stages of the build, so we default to 0 there. -# https://docs.travis-ci.com/user/environment-variables/ -if [[ ${TRAVIS_TEST_RESULT=0} == 1 ]]; then - exit 1; -fi - - -# Don't deploy Angular.io if we are running in a fork -if [[ ${TRAVIS_REPO_SLUG} != "angular/angular" ]]; then - echo "Skipping deploy because this is not angular/angular." - exit 0 -fi - - -case ${CI_MODE} in - aio) - travisFoldStart "deploy.aio" - ( - cd ${TRAVIS_BUILD_DIR}/aio - yarn deploy-production - ) - travisFoldEnd "deploy.aio" - ;; -esac diff --git a/scripts/ci/env.sh b/scripts/ci/env.sh index 75cb3b99c3..ecd31c4f5e 100755 --- a/scripts/ci/env.sh +++ b/scripts/ci/env.sh @@ -46,8 +46,6 @@ 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 if [[ ${TRAVIS:-} ]]; then case ${CI_MODE} in @@ -66,11 +64,6 @@ if [[ ${TRAVIS:-} ]]; then browserstack_optional) setEnvVar KARMA_JS_BROWSERS `node -e "console.log(require('/home/travis/build/angular/angular/browser-providers.conf').browserstackAliases.CI_OPTIONAL.join(','))"` ;; - aio) - # Determine the current stable branch. - readonly versionRe="^\s*([0-9]+\.[0-9]+)\.[0-9]+.*$" - setEnvVar STABLE_BRANCH `npm info @angular/core dist-tags.latest | sed -r "s/$versionRe/\1.x/"` - ;; esac else setEnvVar KARMA_JS_BROWSERS Chrome