build(docs-infra): switch deploy-to-firebase.sh script to JS (#39470)

This commit switches the `deploy-to-firebase.sh` script, that we use for
deploying angular.io to production, from Bash to JavaScript. This makes
the script easier to maintain.

For the same reasons, it also switches the `deploy-to-firebase.test.sh`
script, that we use for testing the `deploy-to-firebase` script, from
Bash to JavaScript (using jasmine as the test runner).

Finally, this commit also updates ShellJS to the latest version to get
better error messages (including the actual error) when `exec()` fails.

NOTE: Before switching the test script to JS, I verified that the new
      `deploy-to-firebase.js` script passed the tests with the old
      `deploy-to-firebase.test.sh` script.

PR Close #39470
This commit is contained in:
George Kalpakas
2020-10-28 12:23:51 +02:00
committed by Joey Perrott
parent 8317042483
commit 5143d52d2b
8 changed files with 368 additions and 383 deletions
+165
View File
@@ -0,0 +1,165 @@
#!/bin/env node
//
// WARNING: `CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN` should NOT be printed.
//
'use strict';
const {cd, cp, exec: _exec, set} = require('shelljs');
set('-e');
// Arguments and environment variables
const args = process.argv.slice(2);
const dryRun = args[0] === '--dry-run';
const {
CI_AIO_MIN_PWA_SCORE,
CI_BRANCH,
CI_COMMIT,
CI_PULL_REQUEST,
CI_REPO_NAME,
CI_REPO_OWNER,
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN,
CI_STABLE_BRANCH,
} = process.env;
// Do not deploy if we are running in a fork.
if (`${CI_REPO_OWNER}/${CI_REPO_NAME}` !== 'angular/angular') {
console.log('Skipping deploy because this is not angular/angular.');
process.exit(0);
}
// Do not deploy if this is a PR. PRs are deployed in the `aio_preview` CircleCI job.
if (CI_PULL_REQUEST !== 'false') {
console.log('Skipping deploy because this is a PR build.');
process.exit(0);
}
// Do not deploy if the current commit is not the latest on its branch.
const latestCommit = exec(`git ls-remote origin ${CI_BRANCH}`).slice(0, 40);
if (CI_COMMIT !== latestCommit) {
console.log(`Skipping deploy because ${CI_COMMIT} is not the latest commit (${latestCommit}).`);
process.exit(0);
}
// The deployment mode is computed based on the branch we are building.
const currentBranchMajorVersion = computeMajorVersion(CI_BRANCH);
// Special-case v9, because it is piloting the Firebase hosting "multisites" setup.
// See https://angular-team.atlassian.net/browse/DEV-125 for more info.
const isV9 = currentBranchMajorVersion === 9;
const deployInfoPerTarget = {
next: {
deployEnv: 'next',
projectId: 'aio-staging',
siteId: 'aio-staging',
deployedUrl: 'https://next.angular.io/',
},
stable: {
deployEnv: 'stable',
projectId: 'angular-io',
siteId: 'angular-io',
deployedUrl: 'https://angular.io/',
},
archive: {
deployEnv: 'archive',
projectId: isV9 ? 'aio-staging' : `v${currentBranchMajorVersion}-angular-io`,
siteId: isV9 ? 'v9-angular-io' : `v${currentBranchMajorVersion}-angular-io`,
deployedUrl: `https://v${currentBranchMajorVersion}.angular.io/`,
},
};
let deployInfo = null;
if (CI_BRANCH === 'master') {
deployInfo = deployInfoPerTarget.next;
} else if (CI_BRANCH === CI_STABLE_BRANCH) {
deployInfo = deployInfoPerTarget.stable;
} else {
const stableBranchMajorVersion = computeMajorVersion(CI_STABLE_BRANCH);
// Do not deploy if the major version is not less than the stable branch major version.
if (currentBranchMajorVersion >= stableBranchMajorVersion) {
console.log(
`Skipping deploy of branch "${CI_BRANCH}" to Firebase.\n` +
'We only deploy archive branches with the major version less than the stable branch: ' +
`"${CI_STABLE_BRANCH}"`);
process.exit(0);
}
// Find the branch that has highest minor version for the given `currentBranchMajorVersion`.
const mostRecentMinorVersion =
// List the branches that start with the major version.
exec(`git ls-remote origin refs/heads/${currentBranchMajorVersion}.*.x`).split('\n')
// Extract the version number.
.map(line => line.split('/')[2])
// Sort by the minor version.
.sort((a, b) => a.split('.')[1] - b.split('.')[1])
// Get the highest version.
.pop();
// Do not deploy as it is not the latest branch for the given major version.
if (CI_BRANCH !== mostRecentMinorVersion) {
console.log(
`Skipping deploy of branch "${CI_BRANCH}" to Firebase.\n` +
`There is a more recent branch with the same major version: "${mostRecentMinorVersion}"`);
process.exit(0);
}
deployInfo = deployInfoPerTarget.archive;
}
const {deployEnv, projectId, siteId, deployedUrl} = deployInfo;
console.log(
`Git branch : ${CI_BRANCH}\n` +
`Build/deploy mode : ${deployEnv}\n` +
`Firebase project : ${projectId}\n` +
`Firebase site : ${siteId}\n` +
`Deployment URL : ${deployedUrl}\n`);
if (dryRun) {
process.exit(0);
}
// Deploy
cd(`${__dirname}/..`);
console.log('\n\n\n==== Build the AIO app. ====\n');
yarn(`build --configuration=${deployEnv} --progress=false`);
console.log('\n\n\n==== Add any mode-specific files into the AIO distribution. ====\n');
cp('-rf', `src/extra-files/${deployEnv}/.`, 'dist/');
console.log('\n\n\n==== Update opensearch descriptor for AIO with `deployedUrl`. ====\n');
yarn(`set-opensearch-url ${deployedUrl.replace(/[^/]$/, '$&/')}`); // The URL must end with `/`.
console.log('\n\n\n==== Check payload size and upload the numbers to Firebase DB. ====\n');
yarn('payload-size');
console.log('\n\n\n==== Deploy AIO to Firebase hosting. ====\n');
yarn(`firebase use "${projectId}" --token "${CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN}"`);
yarn(
`firebase target:apply hosting aio "${siteId}" --token ` +
`"${CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN}"`);
yarn(
`firebase deploy --only hosting:aio --message "Commit: ${CI_COMMIT}" --non-interactive ` +
`--token ${CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN}`);
console.log('\n\n\n==== Run PWA-score tests. ====\n');
yarn(`test-pwa-score "${deployedUrl}" "${CI_AIO_MIN_PWA_SCORE}"`);
// Helpers
function computeMajorVersion(branchName) {
return +branchName.split('.', 1)[0];
}
function exec(cmd, opts) {
// Using `silent: true` to ensure no secret env variables are printed.
return _exec(cmd, {silent: true, ...opts}).trim();
}
function yarn(cmd) {
// Using `--silent` to ensure no secret env variables are printed.
return exec(`yarn --silent ${cmd}`);
}
-132
View File
@@ -1,132 +0,0 @@
#!/usr/bin/env bash
# WARNING: CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN should NOT be printed.
set +x -eu -o pipefail
# 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 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 == $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=${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: \"$CI_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
git ls-remote origin refs/heads/${majorVersion}.*.x |
# Extract the version number
awk -F'/' '{print $3}' |
# Sort by the minor version
sort -t. -k 2,2n |
# Get the highest version
tail -n1
)
# Do not deploy as it is not the latest branch for the given major version
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
readonly deployEnv=archive
fi
case $deployEnv in
next)
readonly projectId=aio-staging
readonly siteId=$projectId
readonly deployedUrl=https://next.angular.io/
readonly firebaseToken=$CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN
;;
stable)
readonly projectId=angular-io
readonly siteId=$projectId
readonly deployedUrl=https://angular.io/
readonly firebaseToken=$CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN
;;
archive)
# Special case v9-angular-io because its piloting the firebase hosting "multisites" setup
# See https://angular-team.atlassian.net/browse/DEV-125 for more info.
if [[ "$majorVersion" == "9" ]]; then
readonly projectId=aio-staging
readonly siteId=v9-angular-io
else
readonly projectId=v${majorVersion}-angular-io
readonly siteId=$projectId
fi
readonly deployedUrl=https://v${majorVersion}.angular.io/
readonly firebaseToken=$CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN
;;
esac
echo "Git branch : $CI_BRANCH"
echo "Build/deploy mode : $deployEnv"
echo "Firebase project : $projectId"
echo "Firebase site : $siteId"
echo "Deployment URL : $deployedUrl"
if [[ ${1:-} == "--dry-run" ]]; then
exit 0
fi
# Deploy
(
cd "`dirname $0`/.."
echo "\n\n\n==== Build the aio app ====\n"
yarn build --configuration=$deployEnv --progress=false
echo "\n\n\n==== Add any mode-specific files into the aio distribution ====\n"
cp -rf src/extra-files/$deployEnv/. dist/
echo "\n\n\n==== Update opensearch descriptor for aio with the deployedUrl ====\n"
# deployedUrl must end with /
yarn set-opensearch-url $deployedUrl
echo "\n\n\n==== Check payload size and upload the numbers to firebase db ====\n"
yarn payload-size
echo "\n\n\n==== Deploy aio to firebase hosting ====\n"
yarn firebase use "${projectId}" --token "$firebaseToken"
yarn firebase target:apply hosting aio $siteId --token "$firebaseToken"
yarn firebase deploy --only hosting:aio --message "Commit: $CI_COMMIT" --non-interactive --token "$firebaseToken"
echo "\n\n\n==== Run PWA-score tests ====\n"
yarn test-pwa-score "$deployedUrl" "$CI_AIO_MIN_PWA_SCORE"
)
+187
View File
@@ -0,0 +1,187 @@
#!/usr/bin/env node
'use strict';
const {execSync} = require('child_process');
describe('deploy-to-firebase:', () => {
const deployToFirebaseCmd = `"${process.execPath}" "${__dirname}/deploy-to-firebase" --dry-run`;
// Helpers
const deployToFirebaseDryRun =
env => execSync(deployToFirebaseCmd, {encoding: 'utf8', env}).toString().trim();
const getLatestCommitForBranch =
branch => execSync(`git ls-remote origin ${branch}`).slice(0, 40);
it('master - skip deploy - not angular', () => {
expect(deployToFirebaseDryRun({
CI_REPO_OWNER: 'angular',
CI_REPO_NAME: 'notangular',
})).toBe('Skipping deploy because this is not angular/angular.');
});
it('master - skip deploy - angular fork', () => {
expect(deployToFirebaseDryRun({
CI_REPO_OWNER: 'notangular',
CI_REPO_NAME: 'angular',
})).toBe('Skipping deploy because this is not angular/angular.');
});
it('master - skip deploy - pull request', () => {
expect(deployToFirebaseDryRun({
CI_REPO_OWNER: 'angular',
CI_REPO_NAME: 'angular',
CI_PULL_REQUEST: 'true',
})).toBe('Skipping deploy because this is a PR build.');
});
it('master - deploy success', () => {
expect(deployToFirebaseDryRun({
CI_REPO_OWNER: 'angular',
CI_REPO_NAME: 'angular',
CI_PULL_REQUEST: 'false',
CI_BRANCH: 'master',
CI_COMMIT: getLatestCommitForBranch('master'),
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
})).toBe(
'Git branch : master\n' +
'Build/deploy mode : next\n' +
'Firebase project : aio-staging\n' +
'Firebase site : aio-staging\n' +
'Deployment URL : https://next.angular.io/');
});
it('master - skip deploy - commit not HEAD', () => {
expect(deployToFirebaseDryRun({
CI_REPO_OWNER: 'angular',
CI_REPO_NAME: 'angular',
CI_PULL_REQUEST: 'false',
CI_BRANCH: 'master',
CI_COMMIT: 'DUMMY_TEST_COMMIT',
})).toBe(
'Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ' +
`(${getLatestCommitForBranch('master')}).`);
});
it('stable - deploy success', () => {
expect(deployToFirebaseDryRun({
CI_REPO_OWNER: 'angular',
CI_REPO_NAME: 'angular',
CI_PULL_REQUEST: 'false',
CI_BRANCH: '4.3.x',
CI_STABLE_BRANCH: '4.3.x',
CI_COMMIT: getLatestCommitForBranch('4.3.x'),
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
})).toBe(
'Git branch : 4.3.x\n' +
'Build/deploy mode : stable\n' +
'Firebase project : angular-io\n' +
'Firebase site : angular-io\n' +
'Deployment URL : https://angular.io/');
});
it('stable - skip deploy - commit not HEAD', () => {
expect(deployToFirebaseDryRun({
CI_REPO_OWNER: 'angular',
CI_REPO_NAME: 'angular',
CI_PULL_REQUEST: 'false',
CI_BRANCH: '4.3.x',
CI_STABLE_BRANCH: '4.3.x',
CI_COMMIT: 'DUMMY_TEST_COMMIT',
})).toBe(
'Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ' +
`(${getLatestCommitForBranch('4.3.x')}).`);
});
it('archive - deploy success', () => {
expect(deployToFirebaseDryRun({
CI_REPO_OWNER: 'angular',
CI_REPO_NAME: 'angular',
CI_PULL_REQUEST: 'false',
CI_BRANCH: '2.4.x',
CI_STABLE_BRANCH: '4.3.x',
CI_COMMIT: getLatestCommitForBranch('2.4.x'),
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
})).toBe(
'Git branch : 2.4.x\n' +
'Build/deploy mode : archive\n' +
'Firebase project : v2-angular-io\n' +
'Firebase site : v2-angular-io\n' +
'Deployment URL : https://v2.angular.io/');
});
it('archive - v9-angular-io multisite special case - deploy success', () => {
expect(deployToFirebaseDryRun({
CI_REPO_OWNER: 'angular',
CI_REPO_NAME: 'angular',
CI_PULL_REQUEST: 'false',
CI_BRANCH: '9.1.x',
CI_STABLE_BRANCH: '10.0.x',
CI_COMMIT: getLatestCommitForBranch('9.1.x'),
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
})).toBe(
'Git branch : 9.1.x\n' +
'Build/deploy mode : archive\n' +
'Firebase project : aio-staging\n' +
'Firebase site : v9-angular-io\n' +
'Deployment URL : https://v9.angular.io/');
});
it('archive - skip deploy - commit not HEAD', () => {
expect(deployToFirebaseDryRun({
CI_REPO_OWNER: 'angular',
CI_REPO_NAME: 'angular',
CI_PULL_REQUEST: 'false',
CI_BRANCH: '2.4.x',
CI_STABLE_BRANCH: '4.3.x',
CI_COMMIT: 'DUMMY_TEST_COMMIT',
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
})).toBe(
'Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ' +
`(${getLatestCommitForBranch('2.4.x')}).`);
});
it('archive - skip deploy - major version too high, lower minor', () => {
expect(deployToFirebaseDryRun({
CI_REPO_OWNER: 'angular',
CI_REPO_NAME: 'angular',
CI_PULL_REQUEST: 'false',
CI_BRANCH: '2.1.x',
CI_STABLE_BRANCH: '2.2.x',
CI_COMMIT: getLatestCommitForBranch('2.1.x'),
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
})).toBe(
'Skipping deploy of branch "2.1.x" to Firebase.\n' +
'We only deploy archive branches with the major version less than the stable branch: ' +
'"2.2.x"');
});
it('archive - skip deploy - major version too high, higher minor', () => {
expect(deployToFirebaseDryRun({
CI_REPO_OWNER: 'angular',
CI_REPO_NAME: 'angular',
CI_PULL_REQUEST: 'false',
CI_BRANCH: '2.4.x',
CI_STABLE_BRANCH: '2.2.x',
CI_COMMIT: getLatestCommitForBranch('2.4.x'),
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
})).toBe(
'Skipping deploy of branch "2.4.x" to Firebase.\n' +
'We only deploy archive branches with the major version less than the stable branch: ' +
'"2.2.x"');
});
it('archive - skip deploy - minor version too low', () => {
expect(deployToFirebaseDryRun({
CI_REPO_OWNER: 'angular',
CI_REPO_NAME: 'angular',
CI_PULL_REQUEST: 'false',
CI_BRANCH: '2.1.x',
CI_STABLE_BRANCH: '4.3.x',
CI_COMMIT: getLatestCommitForBranch('2.1.x'),
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
})).toBe(
'Skipping deploy of branch "2.1.x" to Firebase.\n' +
'There is a more recent branch with the same major version: "2.4.x"');
});
});
-244
View File
@@ -1,244 +0,0 @@
#!/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
exit 0
fi
echo Fail
echo ---- Expected ----
echo "$2"
echo ---- Actual ----
echo "$1"
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
$deployToFirebaseDryRun
)
expected="Skipping deploy because this is a PR build."
check "$actual" "$expected"
)
(
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 -c1-40)
export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX
$deployToFirebaseDryRun
)
expected="Git branch : master
Build/deploy mode : next
Firebase project : aio-staging
Firebase site : aio-staging
Deployment URL : https://next.angular.io/"
check "$actual" "$expected"
)
(
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
$deployToFirebaseDryRun
)
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 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 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
$deployToFirebaseDryRun
)
expected="Git branch : 4.3.x
Build/deploy mode : stable
Firebase project : angular-io
Firebase site : angular-io
Deployment URL : https://angular.io/"
check "$actual" "$expected"
)
(
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 CI_STABLE_BRANCH=4.3.x
export CI_COMMIT=DUMMY_TEST_COMMIT
$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"
)
(
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 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
$deployToFirebaseDryRun
)
expected="Git branch : 2.4.x
Build/deploy mode : archive
Firebase project : v2-angular-io
Firebase site : v2-angular-io
Deployment URL : https://v2.angular.io/"
check "$actual" "$expected"
)
(
echo ===== archive - v9-angular-io multisite special case - 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=9.1.x
export CI_STABLE_BRANCH=10.0.x
export CI_COMMIT=$(git ls-remote origin 9.1.x | cut -c1-40)
export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX
$deployToFirebaseDryRun
)
expected="Git branch : 9.1.x
Build/deploy mode : archive
Firebase project : aio-staging
Firebase site : v9-angular-io
Deployment URL : https://v9.angular.io/"
# TODO: This test incorrectly expects the Firebase project to be v9-angular-io.
# v9-angular-io is a "multisites" project currently within the aio-staging project
# This setup is temporary and was created in order to deploy v9.angular.io without
# disruptions.
# See https://angular-team.atlassian.net/browse/DEV-125 for more info.
check "$actual" "$expected"
)
(
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 CI_STABLE_BRANCH=4.3.x
export CI_COMMIT=DUMMY_TEST_COMMIT
export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=XXXXX
$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"
)
(
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 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
$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\""
check "$actual" "$expected"
)
(
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 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
$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\""
check "$actual" "$expected"
)
(
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 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
$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\""
check "$actual" "$expected"
)