2017-07-28 06:57:44 -04:00
|
|
|
#!/usr/bin/env bash
|
2017-08-08 19:22:12 -04:00
|
|
|
set +x -eu -o pipefail
|
2017-07-28 06:57:44 -04:00
|
|
|
|
|
|
|
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=$(
|
2018-10-17 12:19:15 -04:00
|
|
|
export CI_PULL_REQUEST=true
|
2017-07-28 06:57:44 -04:00
|
|
|
`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=$(
|
2018-10-17 12:19:15 -04:00
|
|
|
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
|
2017-07-28 06:57:44 -04:00
|
|
|
`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=$(
|
2018-10-17 12:19:15 -04:00
|
|
|
export CI_PULL_REQUEST=false
|
|
|
|
export CI_BRANCH=master
|
|
|
|
export CI_COMMIT=DUMMY_TEST_COMMIT
|
2017-07-28 06:57:44 -04:00
|
|
|
`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=$(
|
2018-10-17 12:19:15 -04:00
|
|
|
export CI_PULL_REQUEST=false
|
|
|
|
export CI_BRANCH=4.3.x
|
2017-07-28 06:57:44 -04:00
|
|
|
export STABLE_BRANCH=4.3.x
|
2018-10-17 12:19:15 -04:00
|
|
|
export CI_COMMIT=$(git ls-remote origin 4.3.x | cut -c-40)
|
|
|
|
export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX
|
2017-07-28 06:57:44 -04:00
|
|
|
`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=$(
|
2018-10-17 12:19:15 -04:00
|
|
|
export CI_PULL_REQUEST=false
|
|
|
|
export CI_BRANCH=4.3.x
|
2017-07-28 06:57:44 -04:00
|
|
|
export STABLE_BRANCH=4.3.x
|
2018-10-17 12:19:15 -04:00
|
|
|
export CI_COMMIT=DUMMY_TEST_COMMIT
|
2017-07-28 06:57:44 -04:00
|
|
|
`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=$(
|
2018-10-17 12:19:15 -04:00
|
|
|
export CI_PULL_REQUEST=false
|
|
|
|
export CI_BRANCH=2.4.x
|
2017-07-28 06:57:44 -04:00
|
|
|
export STABLE_BRANCH=4.3.x
|
2018-10-17 12:19:15 -04:00
|
|
|
export CI_COMMIT=$(git ls-remote origin 2.4.x | cut -c-40)
|
|
|
|
export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX
|
2017-07-28 06:57:44 -04:00
|
|
|
`dirname $0`/deploy-to-firebase.sh --dry-run
|
|
|
|
)
|
|
|
|
expected="Git branch : 2.4.x
|
|
|
|
Build/deploy mode : archive
|
2018-05-04 18:08:17 -04:00
|
|
|
Firebase project : v2-angular-io
|
2017-07-28 06:57:44 -04:00
|
|
|
Deployment URL : https://v2.angular.io/"
|
|
|
|
check "$actual" "$expected"
|
|
|
|
)
|
|
|
|
|
|
|
|
(
|
|
|
|
echo ===== archive - skip deploy - commit not HEAD
|
|
|
|
actual=$(
|
2018-10-17 12:19:15 -04:00
|
|
|
export CI_PULL_REQUEST=false
|
|
|
|
export CI_BRANCH=2.4.x
|
2017-07-28 06:57:44 -04:00
|
|
|
export STABLE_BRANCH=4.3.x
|
2018-10-17 12:19:15 -04:00
|
|
|
export CI_COMMIT=DUMMY_TEST_COMMIT
|
|
|
|
export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX
|
2017-07-28 06:57:44 -04:00
|
|
|
`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=$(
|
2018-10-17 12:19:15 -04:00
|
|
|
export CI_PULL_REQUEST=false
|
|
|
|
export CI_BRANCH=2.1.x
|
2017-07-28 06:57:44 -04:00
|
|
|
export STABLE_BRANCH=2.2.x
|
2018-10-17 12:19:15 -04:00
|
|
|
export CI_COMMIT=$(git ls-remote origin 2.1.x | cut -c-40)
|
|
|
|
export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX
|
2017-07-28 06:57:44 -04:00
|
|
|
`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=$(
|
2018-10-17 12:19:15 -04:00
|
|
|
export CI_PULL_REQUEST=false
|
|
|
|
export CI_BRANCH=2.4.x
|
2017-07-28 06:57:44 -04:00
|
|
|
export STABLE_BRANCH=2.2.x
|
2018-10-17 12:19:15 -04:00
|
|
|
export CI_COMMIT=$(git ls-remote origin 2.4.x | cut -c-40)
|
|
|
|
export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX
|
2017-07-28 06:57:44 -04:00
|
|
|
`dirname $0`/deploy-to-firebase.sh --dry-run
|
|
|
|
)
|
2017-08-08 19:22:12 -04:00
|
|
|
expected="Skipping deploy of branch \"2.4.x\" to firebase.
|
2017-07-28 06:57:44 -04:00
|
|
|
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=$(
|
2018-10-17 12:19:15 -04:00
|
|
|
export CI_PULL_REQUEST=false
|
|
|
|
export CI_BRANCH=2.1.x
|
2017-07-28 06:57:44 -04:00
|
|
|
export STABLE_BRANCH=4.3.x
|
2018-10-17 12:19:15 -04:00
|
|
|
export CI_COMMIT=$(git ls-remote origin 2.1.x | cut -c-40)
|
|
|
|
export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX
|
2017-07-28 06:57:44 -04:00
|
|
|
`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"
|
|
|
|
)
|