ci(docs-infra): move deployment to CircleCI (#26377)

PR Close #26377
This commit is contained in:
George Kalpakas 2018-10-18 14:49:30 +03:00 committed by Alex Rickabaugh
parent 9b8a244a15
commit 38d626a3fa
6 changed files with 94 additions and 76 deletions

View File

@ -154,7 +154,7 @@ jobs:
- *setup_bazel_remote_execution
- run: bazel test //... --define=compile=aot --build_tag_filters=ivy-aot --test_tag_filters=ivy-aot
test_aio:
test_and_deploy_aio:
<<: *job_defaults
steps:
- *define_env_vars
@ -180,6 +180,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
@ -385,7 +388,7 @@ workflows:
- test_ivy_jit
- test_ivy_aot
- build-packages-dist
- test_aio
- test_and_deploy_aio
- test_aio_local:
requires:
- build-packages-dist

View File

@ -30,10 +30,6 @@ env:
# GITHUB_TOKEN_ANGULAR=<github token, a personal access token of the angular-builds account, account access in valentine>
# 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

View File

@ -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

View File

@ -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\""

View File

@ -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

View File

@ -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