ci(aio): compute AIO deployment mode
There are now 3 modes for deployment: next, stable, archive. We compute which mode (and other deployment properties) from the `TRAVIS_BRANCH` and the `STABLE_BRANCH`. If the TRAVIS_BRANCH is master we deploy as "next". If the `TRAVIS_BRANCH` matches the `STABLE_BRANCH` we deploy as "stable". Otherwise if the branch has a major version lower than the stable version and its minor version is highest of similar branches we deploy as "archive". For "archive" deployments we compute the firebase project and deployment url based on the major version of the `TRAVIS_BRANCH`. As well as choosing where to deploy the build, we also use this to select the environment file for the AIO Angular app. This will enable the app to change its rendering and behaviour based on its mode. See #18287 Closes #18297
This commit is contained in:
parent
340837aa46
commit
10897d6473
|
@ -53,7 +53,7 @@ env:
|
|||
- CI_MODE=browserstack_required
|
||||
- CI_MODE=saucelabs_optional
|
||||
- CI_MODE=browserstack_optional
|
||||
- CI_MODE=docs_test
|
||||
- CI_MODE=aio_tools_test
|
||||
- CI_MODE=aio
|
||||
- CI_MODE=aio_e2e AIO_SHARD=0
|
||||
- CI_MODE=aio_e2e AIO_SHARD=1
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
"docs-watch": "node tools/transforms/authors-package/watchr.js",
|
||||
"docs-lint": "eslint --ignore-path=\"tools/transforms/.eslintignore\" tools/transforms",
|
||||
"docs-test": "node tools/transforms/test.js",
|
||||
"tools-test": "./scripts/deploy-to-firebase.test.sh && yarn docs-test",
|
||||
"serve-and-sync": "concurrently --kill-others \"yarn docs-watch\" \"yarn start\"",
|
||||
"~~update-webdriver": "webdriver-manager update --standalone false --gecko false",
|
||||
"boilerplate:add": "node ./tools/examples/example-boilerplate add",
|
||||
|
|
|
@ -11,17 +11,28 @@ 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
|
||||
if [[ $TRAVIS_COMMIT != $LATEST_COMMIT ]]; then
|
||||
echo "Skipping deploy because $TRAVIS_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 [[ $TRAVIS_BRANCH == master ]]; then
|
||||
readonly deployEnv=next
|
||||
elif [[ $TRAVIS_BRANCH == $STABLE_BRANCH ]]; then
|
||||
readonly deployEnv=stable
|
||||
else
|
||||
# Extract the major version from the branch that we are deploying, e.g. the 4 from 4.3.x
|
||||
# Extract the major versions from the branches, e.g. the 4 from 4.3.x
|
||||
readonly majorVersion=${TRAVIS_BRANCH%%.*}
|
||||
readonly majorVersionStable=${STABLE_BRANCH%%.*}
|
||||
|
||||
# Do not deploy if the major version is not less than the stable branch major version
|
||||
if [[ $majorVersion -ge $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}\""
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Find the branch that has highest minor version for the given `$majorVersion`
|
||||
readonly mostRecentMinorVersion=$(
|
||||
# List the branches that start with the major version
|
||||
|
@ -35,23 +46,19 @@ else
|
|||
)
|
||||
|
||||
# Do not deploy as it is not the latest branch for the given major version
|
||||
if [ $TRAVIS_BRANCH != $mostRecentMinorVersion ]; then
|
||||
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}\""
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ $TRAVIS_BRANCH == $STABLE_BRANCH ]; then
|
||||
readonly deployEnv=stable
|
||||
else
|
||||
readonly deployEnv=archive
|
||||
fi
|
||||
fi
|
||||
|
||||
case $deployEnv in
|
||||
next)
|
||||
readonly projectId=aio-staging
|
||||
readonly deployedUrl=https://$projectId.firebaseapp.com/
|
||||
readonly deployedUrl=https://next.angular.io/
|
||||
readonly firebaseToken=$FIREBASE_TOKEN
|
||||
;;
|
||||
stable)
|
||||
|
@ -71,6 +78,10 @@ echo "Build/deploy mode : $deployEnv"
|
|||
echo "Firebase project : $projectId"
|
||||
echo "Deployment URL : $deployedUrl"
|
||||
|
||||
if [[ $1 == "--dry-run" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Deploy
|
||||
(
|
||||
cd "`dirname $0`/.."
|
||||
|
|
|
@ -0,0 +1,158 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
function check {
|
||||
if [[ $1 == $2 ]]; then
|
||||
echo Pass
|
||||
exit 0
|
||||
fi
|
||||
echo Fail
|
||||
echo ---- Expected ----
|
||||
echo "$2"
|
||||
echo ---- Actual ----
|
||||
echo "$1"
|
||||
exit 1
|
||||
}
|
||||
|
||||
(
|
||||
echo ===== master - skip deploy - pull request
|
||||
actual=$(
|
||||
export TRAVIS_PULL_REQUEST=true
|
||||
`dirname $0`/deploy-to-firebase.sh --dry-run
|
||||
)
|
||||
expected="Skipping deploy because this is a PR build."
|
||||
check "$actual" "$expected"
|
||||
)
|
||||
|
||||
(
|
||||
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
|
||||
`dirname $0`/deploy-to-firebase.sh --dry-run
|
||||
)
|
||||
expected="Git branch : master
|
||||
Build/deploy mode : next
|
||||
Firebase project : aio-staging
|
||||
Deployment URL : https://next.angular.io/"
|
||||
check "$actual" "$expected"
|
||||
)
|
||||
|
||||
(
|
||||
echo ===== master - skip deploy - commit not HEAD
|
||||
actual=$(
|
||||
export TRAVIS_PULL_REQUEST=false
|
||||
export TRAVIS_BRANCH=master
|
||||
export TRAVIS_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))."
|
||||
check "$actual" "$expected"
|
||||
)
|
||||
|
||||
(
|
||||
echo ===== stable - deploy success
|
||||
actual=$(
|
||||
export TRAVIS_PULL_REQUEST=false
|
||||
export TRAVIS_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
|
||||
`dirname $0`/deploy-to-firebase.sh --dry-run
|
||||
)
|
||||
expected="Git branch : 4.3.x
|
||||
Build/deploy mode : stable
|
||||
Firebase project : angular-io
|
||||
Deployment URL : https://angular.io/"
|
||||
check "$actual" "$expected"
|
||||
)
|
||||
|
||||
(
|
||||
echo ===== stable - skip deploy - commit not HEAD
|
||||
actual=$(
|
||||
export TRAVIS_PULL_REQUEST=false
|
||||
export TRAVIS_BRANCH=4.3.x
|
||||
export STABLE_BRANCH=4.3.x
|
||||
export TRAVIS_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))."
|
||||
check "$actual" "$expected"
|
||||
)
|
||||
|
||||
(
|
||||
echo ===== archive - deploy success
|
||||
actual=$(
|
||||
export TRAVIS_PULL_REQUEST=false
|
||||
export TRAVIS_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
|
||||
`dirname $0`/deploy-to-firebase.sh --dry-run
|
||||
)
|
||||
expected="Git branch : 2.4.x
|
||||
Build/deploy mode : archive
|
||||
Firebase project : angular-io-2
|
||||
Deployment URL : https://v2.angular.io/"
|
||||
check "$actual" "$expected"
|
||||
)
|
||||
|
||||
(
|
||||
echo ===== archive - skip deploy - commit not HEAD
|
||||
actual=$(
|
||||
export TRAVIS_PULL_REQUEST=false
|
||||
export TRAVIS_BRANCH=2.4.x
|
||||
export STABLE_BRANCH=4.3.x
|
||||
export TRAVIS_COMMIT=DUMMY_TEST_COMMIT
|
||||
export 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))."
|
||||
check "$actual" "$expected"
|
||||
)
|
||||
|
||||
(
|
||||
echo ===== archive - skip deploy - major version too high, lower minor
|
||||
actual=$(
|
||||
export TRAVIS_PULL_REQUEST=false
|
||||
export TRAVIS_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
|
||||
`dirname $0`/deploy-to-firebase.sh --dry-run
|
||||
)
|
||||
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\""
|
||||
check "$actual" "$expected"
|
||||
)
|
||||
|
||||
(
|
||||
echo ===== archive - skip deploy - major version too high, higher minor
|
||||
actual=$(
|
||||
export TRAVIS_PULL_REQUEST=false
|
||||
export TRAVIS_BRANCH=2.4.x
|
||||
export STABLE_BRANCH=2.2.x
|
||||
export TRAVIS_COMMIT=$(git ls-remote origin 2.1.x | cut -c-40)
|
||||
export FIREBASE_TOKEN=XXXXX
|
||||
`dirname $0`/deploy-to-firebase.sh --dry-run
|
||||
)
|
||||
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\""
|
||||
check "$actual" "$expected"
|
||||
)
|
||||
|
||||
(
|
||||
echo ===== archive - skip deploy - minor version too low
|
||||
actual=$(
|
||||
export TRAVIS_PULL_REQUEST=false
|
||||
export TRAVIS_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
|
||||
`dirname $0`/deploy-to-firebase.sh --dry-run
|
||||
)
|
||||
expected="Skipping deploy of branch \"2.1.x\" to firebase.
|
||||
There is a more recent branch with the same major version: \"2.4.x\""
|
||||
check "$actual" "$expected"
|
||||
)
|
|
@ -48,6 +48,5 @@ case ${CI_MODE} in
|
|||
yarn deploy-production
|
||||
)
|
||||
travisFoldEnd "deploy.aio"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -42,7 +42,7 @@ if [[ ${CI_MODE} != "aio" && ${CI_MODE} != 'docs_test' ]]; then
|
|||
fi
|
||||
|
||||
|
||||
if [[ ${TRAVIS} && (${CI_MODE} == "e2e" || ${CI_MODE} == "e2e_2" || ${CI_MODE} == "aio" || ${CI_MODE} == "aio_e2e" || ${CI_MODE} == "docs_test") ]]; then
|
||||
if [[ ${TRAVIS} && (${CI_MODE} == "e2e" || ${CI_MODE} == "e2e_2" || ${CI_MODE} == "aio" || ${CI_MODE} == "aio_e2e" || ${CI_MODE} == "aio_tools_test") ]]; then
|
||||
# Install version of yarn that we are locked against
|
||||
travisFoldStart "install-yarn"
|
||||
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version "${YARN_VERSION}"
|
||||
|
@ -50,7 +50,7 @@ if [[ ${TRAVIS} && (${CI_MODE} == "e2e" || ${CI_MODE} == "e2e_2" || ${CI_MODE} =
|
|||
fi
|
||||
|
||||
|
||||
if [[ ${TRAVIS} && (${CI_MODE} == "aio" || ${CI_MODE} == "aio_e2e" || ${CI_MODE} == "docs_test") ]]; then
|
||||
if [[ ${TRAVIS} && (${CI_MODE} == "aio" || ${CI_MODE} == "aio_e2e" || ${CI_MODE} == "aio_tools_test") ]]; then
|
||||
# angular.io: Install all yarn dependencies according to angular.io/yarn.lock
|
||||
travisFoldStart "yarn-install.aio"
|
||||
(
|
||||
|
|
|
@ -10,6 +10,6 @@ source ${thisDir}/_travis-fold.sh
|
|||
travisFoldStart "test.docs"
|
||||
(
|
||||
cd ${PROJECT_ROOT}/aio
|
||||
yarn docs-test
|
||||
yarn tools-test
|
||||
)
|
||||
travisFoldEnd "test.docs"
|
|
@ -37,8 +37,8 @@ case ${CI_MODE} in
|
|||
browserstack_optional)
|
||||
${thisDir}/test-browserstack.sh
|
||||
;;
|
||||
docs_test)
|
||||
${thisDir}/test-docs.sh
|
||||
aio_tools_test)
|
||||
${thisDir}/test-aio-tools.sh
|
||||
;;
|
||||
aio)
|
||||
${thisDir}/test-aio.sh
|
||||
|
|
Loading…
Reference in New Issue