refactor(docs-infra): break up `deploy-to-firebase.js` script into functions (#39470)
This commit breaks up the code in `deploy-to-firebase.js` script, that we use for deploying angular.io to production, to smaller functions (instead of a monolithic block). This makes the script easier to maintain and also makes testing individual operations easier. The commit also updates the `deploy-to-firebase.spec.js` spec file to take advantage of the standalone functions to speed up testing by calling the corresponding function instead of having to spawn a new process and run the `deploy-to-firebase.js` script with the `--dry-run` flag. NOTE: Before updating the tests, I verified that the updated `deploy-to-firebase.js` script passed the old tests. PR Close #39470
This commit is contained in:
parent
1aaf556815
commit
699824a2a5
|
@ -9,49 +9,65 @@ const {cd, cp, exec: _exec, set} = require('shelljs');
|
||||||
set('-e');
|
set('-e');
|
||||||
|
|
||||||
|
|
||||||
// Arguments, environment variables and constants.
|
// Constants
|
||||||
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;
|
|
||||||
|
|
||||||
const REPO_SLUG = 'angular/angular';
|
const REPO_SLUG = 'angular/angular';
|
||||||
const NG_REMOTE_URL = `https://github.com/${REPO_SLUG}.git`;
|
const NG_REMOTE_URL = `https://github.com/${REPO_SLUG}.git`;
|
||||||
|
|
||||||
|
// Exports
|
||||||
|
module.exports = {
|
||||||
|
computeDeploymentInfo,
|
||||||
|
computeInputVars,
|
||||||
|
getLatestCommit,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Run
|
||||||
|
if (require.main === module) {
|
||||||
|
const isDryRun = process.argv[2] === '--dry-run';
|
||||||
|
const inputVars = computeInputVars(process.env);
|
||||||
|
const deploymentInfo = computeDeploymentInfo(inputVars);
|
||||||
|
|
||||||
|
if (deploymentInfo.skipped) {
|
||||||
|
console.log(deploymentInfo.reason);
|
||||||
|
} else {
|
||||||
|
console.log(
|
||||||
|
`Git branch : ${currentBranch}\n` +
|
||||||
|
`Build/deploy mode : ${deploymentInfo.deployEnv}\n` +
|
||||||
|
`Firebase project : ${deploymentInfo.projectId}\n` +
|
||||||
|
`Firebase site : ${deploymentInfo.siteId}\n` +
|
||||||
|
`Deployment URLs : ${deploymentInfo.deployedUrl}\n`);
|
||||||
|
|
||||||
|
if (!isDryRun) {
|
||||||
|
deploy({...inputVars, ...deploymentInfo});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helpers
|
||||||
|
function computeDeploymentInfo(
|
||||||
|
{currentBranch, currentCommit, isPullRequest, repoName, repoOwner, stableBranch}) {
|
||||||
// Do not deploy if we are running in a fork.
|
// Do not deploy if we are running in a fork.
|
||||||
if (`${CI_REPO_OWNER}/${CI_REPO_NAME}` !== REPO_SLUG) {
|
if (`${repoOwner}/${repoName}` !== REPO_SLUG) {
|
||||||
console.log(`Skipping deploy because this is not ${REPO_SLUG}.`);
|
return skipDeployment(`Skipping deploy because this is not ${REPO_SLUG}.`);
|
||||||
process.exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not deploy if this is a PR. PRs are deployed in the `aio_preview` CircleCI job.
|
// Do not deploy if this is a PR. PRs are deployed in the `aio_preview` CircleCI job.
|
||||||
if (CI_PULL_REQUEST !== 'false') {
|
if (isPullRequest) {
|
||||||
console.log('Skipping deploy because this is a PR build.');
|
return skipDeployment('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.
|
// Do not deploy if the current commit is not the latest on its branch.
|
||||||
const latestCommit = exec(`git ls-remote ${NG_REMOTE_URL} ${CI_BRANCH}`).slice(0, 40);
|
const latestCommit = getLatestCommit(currentBranch);
|
||||||
if (CI_COMMIT !== latestCommit) {
|
if (currentCommit !== latestCommit) {
|
||||||
console.log(`Skipping deploy because ${CI_COMMIT} is not the latest commit (${latestCommit}).`);
|
return skipDeployment(
|
||||||
process.exit(0);
|
`Skipping deploy because ${currentCommit} is not the latest commit (${latestCommit}).`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The deployment mode is computed based on the branch we are building.
|
// The deployment mode is computed based on the branch we are building.
|
||||||
const currentBranchMajorVersion = computeMajorVersion(CI_BRANCH);
|
const currentBranchMajorVersion = computeMajorVersion(currentBranch);
|
||||||
// Special-case v9, because it is piloting the Firebase hosting "multisites" setup.
|
// Special-case v9, because it is piloting the Firebase hosting "multisites" setup.
|
||||||
// See https://angular-team.atlassian.net/browse/DEV-125 for more info.
|
// See https://angular-team.atlassian.net/browse/DEV-125 for more info.
|
||||||
const isV9 = currentBranchMajorVersion === 9;
|
const isV9 = currentBranchMajorVersion === 9;
|
||||||
const deployInfoPerTarget = {
|
const deploymentInfoPerTarget = {
|
||||||
next: {
|
next: {
|
||||||
deployEnv: 'next',
|
deployEnv: 'next',
|
||||||
projectId: 'aio-staging',
|
projectId: 'aio-staging',
|
||||||
|
@ -77,19 +93,18 @@ const deployInfoPerTarget = {
|
||||||
deployedUrl: `https://v${currentBranchMajorVersion}.angular.io/`,
|
deployedUrl: `https://v${currentBranchMajorVersion}.angular.io/`,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
let deployInfo = null;
|
|
||||||
|
|
||||||
if (CI_BRANCH === 'master') {
|
if (currentBranch === 'master') {
|
||||||
deployInfo = deployInfoPerTarget.next;
|
return deploymentInfoPerTarget.next;
|
||||||
} else if (CI_BRANCH === CI_STABLE_BRANCH) {
|
} else if (currentBranch === stableBranch) {
|
||||||
deployInfo = deployInfoPerTarget.stable;
|
return deploymentInfoPerTarget.stable;
|
||||||
} else {
|
} else {
|
||||||
const stableBranchMajorVersion = computeMajorVersion(CI_STABLE_BRANCH);
|
const stableBranchMajorVersion = computeMajorVersion(stableBranch);
|
||||||
|
|
||||||
// Find the branch that has highest minor version for the given `currentBranchMajorVersion`.
|
// Find the branch that has highest minor version for the given `currentBranchMajorVersion`.
|
||||||
const mostRecentMinorVersionBranch =
|
const mostRecentMinorVersionBranch =
|
||||||
// List the branches that start with the major version.
|
// List the branches that start with the major version.
|
||||||
exec(`git ls-remote ${NG_REMOTE_URL} refs/heads/${currentBranchMajorVersion}.*.x`).split('\n')
|
getRemoteRefs(`refs/heads/${currentBranchMajorVersion}.*.x`)
|
||||||
// Extract the version number.
|
// Extract the version number.
|
||||||
.map(line => line.split('/')[2])
|
.map(line => line.split('/')[2])
|
||||||
// Sort by the minor version.
|
// Sort by the minor version.
|
||||||
|
@ -99,37 +114,55 @@ if (CI_BRANCH === 'master') {
|
||||||
|
|
||||||
// Do not deploy if it is not the latest branch for the given major version.
|
// Do not deploy if it is not the latest branch for the given major version.
|
||||||
// NOTE: At this point, we know the current branch is not the stable branch.
|
// NOTE: At this point, we know the current branch is not the stable branch.
|
||||||
if (CI_BRANCH !== mostRecentMinorVersionBranch) {
|
if (currentBranch !== mostRecentMinorVersionBranch) {
|
||||||
console.log(
|
return skipDeployment(
|
||||||
`Skipping deploy of branch "${CI_BRANCH}" to Firebase.\n` +
|
`Skipping deploy of branch "${currentBranch}" to Firebase.\n` +
|
||||||
'There is a more recent branch with the same major version: ' +
|
'There is a more recent branch with the same major version: ' +
|
||||||
`"${mostRecentMinorVersionBranch}"`);
|
`"${mostRecentMinorVersionBranch}"`);
|
||||||
process.exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deployInfo = (currentBranchMajorVersion < stableBranchMajorVersion) ?
|
return (currentBranchMajorVersion < stableBranchMajorVersion) ?
|
||||||
// This is the latest minor version for a major that is less than the stable major version:
|
// This is the latest minor version for a major that is less than the stable major version:
|
||||||
// Deploy as `archive`.
|
// Deploy as `archive`.
|
||||||
deployInfoPerTarget.archive :
|
deploymentInfoPerTarget.archive :
|
||||||
// This is the latest minor version for a major that is equal or greater than the stable major
|
// This is the latest minor version for a major that is equal or greater than the stable
|
||||||
// version, but not the stable version itself:
|
// major version, but not the stable version itself:
|
||||||
// Deploy as `rc`.
|
// Deploy as `rc`.
|
||||||
deployInfoPerTarget.rc;
|
deploymentInfoPerTarget.rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
const {deployEnv, projectId, siteId, deployedUrl} = deployInfo;
|
// We should never get here.
|
||||||
console.log(
|
throw new Error('Failed to determine deployment info.');
|
||||||
`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
|
function computeInputVars({
|
||||||
|
CI_AIO_MIN_PWA_SCORE: minPwaScore,
|
||||||
|
CI_BRANCH: currentBranch,
|
||||||
|
CI_COMMIT: currentCommit,
|
||||||
|
CI_PULL_REQUEST,
|
||||||
|
CI_REPO_NAME: repoName,
|
||||||
|
CI_REPO_OWNER: repoOwner,
|
||||||
|
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: firebaseToken,
|
||||||
|
CI_STABLE_BRANCH: stableBranch,
|
||||||
|
}) {
|
||||||
|
return {
|
||||||
|
currentBranch,
|
||||||
|
currentCommit,
|
||||||
|
firebaseToken,
|
||||||
|
isPullRequest: CI_PULL_REQUEST !== 'false',
|
||||||
|
minPwaScore,
|
||||||
|
repoName,
|
||||||
|
repoOwner,
|
||||||
|
stableBranch,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function computeMajorVersion(branchName) {
|
||||||
|
return +branchName.split('.', 1)[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
function deploy(
|
||||||
|
{currentCommit, deployedUrl, deployEnv, firebaseToken, minPwaScore, projectId, siteId}) {
|
||||||
cd(`${__dirname}/..`);
|
cd(`${__dirname}/..`);
|
||||||
|
|
||||||
console.log('\n\n\n==== Build the AIO app. ====\n');
|
console.log('\n\n\n==== Build the AIO app. ====\n');
|
||||||
|
@ -138,7 +171,6 @@ yarn(`build --configuration=${deployEnv} --progress=false`);
|
||||||
console.log('\n\n\n==== Add any mode-specific files into the AIO distribution. ====\n');
|
console.log('\n\n\n==== Add any mode-specific files into the AIO distribution. ====\n');
|
||||||
cp('-rf', `src/extra-files/${deployEnv}/.`, 'dist/');
|
cp('-rf', `src/extra-files/${deployEnv}/.`, 'dist/');
|
||||||
|
|
||||||
|
|
||||||
console.log('\n\n\n==== Update opensearch descriptor for AIO with `deployedUrl`. ====\n');
|
console.log('\n\n\n==== Update opensearch descriptor for AIO with `deployedUrl`. ====\n');
|
||||||
yarn(`set-opensearch-url ${deployedUrl.replace(/[^/]$/, '$&/')}`); // The URL must end with `/`.
|
yarn(`set-opensearch-url ${deployedUrl.replace(/[^/]$/, '$&/')}`); // The URL must end with `/`.
|
||||||
|
|
||||||
|
@ -146,21 +178,14 @@ console.log('\n\n\n==== Check payload size and upload the numbers to Firebase DB
|
||||||
yarn('payload-size');
|
yarn('payload-size');
|
||||||
|
|
||||||
console.log('\n\n\n==== Deploy AIO to Firebase hosting. ====\n');
|
console.log('\n\n\n==== Deploy AIO to Firebase hosting. ====\n');
|
||||||
yarn(`firebase use "${projectId}" --token "${CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN}"`);
|
yarn(`firebase use "${projectId}" --token "${firebaseToken}"`);
|
||||||
|
yarn(`firebase target:apply hosting aio "${siteId}" --token "${firebaseToken}"`);
|
||||||
yarn(
|
yarn(
|
||||||
`firebase target:apply hosting aio "${siteId}" --token ` +
|
`firebase deploy --only hosting:aio --message "Commit: ${currentCommit}" --non-interactive ` +
|
||||||
`"${CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN}"`);
|
`--token "${firebaseToken}"`);
|
||||||
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');
|
console.log('\n\n\n==== Run PWA-score tests. ====\n');
|
||||||
yarn(`test-pwa-score "${deployedUrl}" "${CI_AIO_MIN_PWA_SCORE}"`);
|
yarn(`test-pwa-score "${deployedUrl}" "${minPwaScore}"`);
|
||||||
|
|
||||||
|
|
||||||
// Helpers
|
|
||||||
function computeMajorVersion(branchName) {
|
|
||||||
return +branchName.split('.', 1)[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function exec(cmd, opts) {
|
function exec(cmd, opts) {
|
||||||
|
@ -168,6 +193,18 @@ function exec(cmd, opts) {
|
||||||
return _exec(cmd, {silent: true, ...opts}).trim();
|
return _exec(cmd, {silent: true, ...opts}).trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRemoteRefs(refOrPattern, remote = NG_REMOTE_URL) {
|
||||||
|
return exec(`git ls-remote ${remote} ${refOrPattern}`).split('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLatestCommit(branchName, remote = undefined) {
|
||||||
|
return getRemoteRefs(branchName, remote)[0].slice(0, 40);
|
||||||
|
}
|
||||||
|
|
||||||
|
function skipDeployment(reason) {
|
||||||
|
return {reason, skipped: true};
|
||||||
|
}
|
||||||
|
|
||||||
function yarn(cmd) {
|
function yarn(cmd) {
|
||||||
// Using `--silent` to ensure no secret env variables are printed.
|
// Using `--silent` to ensure no secret env variables are printed.
|
||||||
return exec(`yarn --silent ${cmd}`);
|
return exec(`yarn --silent ${cmd}`);
|
||||||
|
|
|
@ -1,248 +1,260 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const {execSync} = require('child_process');
|
const {computeDeploymentInfo, computeInputVars, getLatestCommit} = require('./deploy-to-firebase');
|
||||||
|
|
||||||
|
|
||||||
describe('deploy-to-firebase:', () => {
|
describe('deploy-to-firebase:', () => {
|
||||||
const deployToFirebaseCmd = `"${process.execPath}" "${__dirname}/deploy-to-firebase" --dry-run`;
|
|
||||||
const ngRemoteUrl = 'https://github.com/angular/angular.git';
|
|
||||||
|
|
||||||
// Helpers
|
|
||||||
const deployToFirebaseDryRun =
|
|
||||||
env => execSync(deployToFirebaseCmd, {encoding: 'utf8', env}).toString().trim();
|
|
||||||
const getLatestCommitForBranch =
|
|
||||||
branch => execSync(`git ls-remote ${ngRemoteUrl} ${branch}`).slice(0, 40);
|
|
||||||
|
|
||||||
it('master - skip deploy - not angular', () => {
|
it('master - skip deploy - not angular', () => {
|
||||||
expect(deployToFirebaseDryRun({
|
expect(computeDeploymentInfo(computeInputVars({
|
||||||
CI_REPO_OWNER: 'angular',
|
CI_REPO_OWNER: 'angular',
|
||||||
CI_REPO_NAME: 'notangular',
|
CI_REPO_NAME: 'notangular',
|
||||||
})).toBe('Skipping deploy because this is not angular/angular.');
|
}))).toEqual({
|
||||||
|
skipped: true,
|
||||||
|
reason: 'Skipping deploy because this is not angular/angular.',
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('master - skip deploy - angular fork', () => {
|
it('master - skip deploy - angular fork', () => {
|
||||||
expect(deployToFirebaseDryRun({
|
expect(computeDeploymentInfo(computeInputVars({
|
||||||
CI_REPO_OWNER: 'notangular',
|
CI_REPO_OWNER: 'notangular',
|
||||||
CI_REPO_NAME: 'angular',
|
CI_REPO_NAME: 'angular',
|
||||||
})).toBe('Skipping deploy because this is not angular/angular.');
|
}))).toEqual({
|
||||||
|
skipped: true,
|
||||||
|
reason: 'Skipping deploy because this is not angular/angular.',
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('master - skip deploy - pull request', () => {
|
it('master - skip deploy - pull request', () => {
|
||||||
expect(deployToFirebaseDryRun({
|
expect(computeDeploymentInfo(computeInputVars({
|
||||||
CI_REPO_OWNER: 'angular',
|
CI_REPO_OWNER: 'angular',
|
||||||
CI_REPO_NAME: 'angular',
|
CI_REPO_NAME: 'angular',
|
||||||
CI_PULL_REQUEST: 'true',
|
CI_PULL_REQUEST: 'true',
|
||||||
})).toBe('Skipping deploy because this is a PR build.');
|
}))).toEqual({
|
||||||
|
skipped: true,
|
||||||
|
reason: 'Skipping deploy because this is a PR build.',
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('master - deploy success', () => {
|
it('master - deploy success', () => {
|
||||||
expect(deployToFirebaseDryRun({
|
expect(computeDeploymentInfo(computeInputVars({
|
||||||
CI_REPO_OWNER: 'angular',
|
CI_REPO_OWNER: 'angular',
|
||||||
CI_REPO_NAME: 'angular',
|
CI_REPO_NAME: 'angular',
|
||||||
CI_PULL_REQUEST: 'false',
|
CI_PULL_REQUEST: 'false',
|
||||||
CI_BRANCH: 'master',
|
CI_BRANCH: 'master',
|
||||||
CI_COMMIT: getLatestCommitForBranch('master'),
|
CI_COMMIT: getLatestCommit('master'),
|
||||||
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
}))).toEqual({
|
||||||
})).toBe(
|
deployEnv: 'next',
|
||||||
'Git branch : master\n' +
|
projectId: 'aio-staging',
|
||||||
'Build/deploy mode : next\n' +
|
siteId: 'aio-staging',
|
||||||
'Firebase project : aio-staging\n' +
|
deployedUrl: 'https://next.angular.io/',
|
||||||
'Firebase site : aio-staging\n' +
|
});
|
||||||
'Deployment URL : https://next.angular.io/');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('master - skip deploy - commit not HEAD', () => {
|
it('master - skip deploy - commit not HEAD', () => {
|
||||||
expect(deployToFirebaseDryRun({
|
expect(computeDeploymentInfo(computeInputVars({
|
||||||
CI_REPO_OWNER: 'angular',
|
CI_REPO_OWNER: 'angular',
|
||||||
CI_REPO_NAME: 'angular',
|
CI_REPO_NAME: 'angular',
|
||||||
CI_PULL_REQUEST: 'false',
|
CI_PULL_REQUEST: 'false',
|
||||||
CI_BRANCH: 'master',
|
CI_BRANCH: 'master',
|
||||||
CI_COMMIT: 'DUMMY_TEST_COMMIT',
|
CI_COMMIT: 'DUMMY_TEST_COMMIT',
|
||||||
})).toBe(
|
}))).toEqual({
|
||||||
|
skipped: true,
|
||||||
|
reason:
|
||||||
'Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ' +
|
'Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ' +
|
||||||
`(${getLatestCommitForBranch('master')}).`);
|
`(${getLatestCommit('master')}).`,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('stable - deploy success', () => {
|
it('stable - deploy success', () => {
|
||||||
expect(deployToFirebaseDryRun({
|
expect(computeDeploymentInfo(computeInputVars({
|
||||||
CI_REPO_OWNER: 'angular',
|
CI_REPO_OWNER: 'angular',
|
||||||
CI_REPO_NAME: 'angular',
|
CI_REPO_NAME: 'angular',
|
||||||
CI_PULL_REQUEST: 'false',
|
CI_PULL_REQUEST: 'false',
|
||||||
CI_BRANCH: '4.3.x',
|
CI_BRANCH: '4.3.x',
|
||||||
CI_STABLE_BRANCH: '4.3.x',
|
CI_STABLE_BRANCH: '4.3.x',
|
||||||
CI_COMMIT: getLatestCommitForBranch('4.3.x'),
|
CI_COMMIT: getLatestCommit('4.3.x'),
|
||||||
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
}))).toEqual({
|
||||||
})).toBe(
|
deployEnv: 'stable',
|
||||||
'Git branch : 4.3.x\n' +
|
projectId: 'angular-io',
|
||||||
'Build/deploy mode : stable\n' +
|
siteId: 'angular-io',
|
||||||
'Firebase project : angular-io\n' +
|
deployedUrl: 'https://angular.io/',
|
||||||
'Firebase site : angular-io\n' +
|
});
|
||||||
'Deployment URL : https://angular.io/');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('stable - skip deploy - commit not HEAD', () => {
|
it('stable - skip deploy - commit not HEAD', () => {
|
||||||
expect(deployToFirebaseDryRun({
|
expect(computeDeploymentInfo(computeInputVars({
|
||||||
CI_REPO_OWNER: 'angular',
|
CI_REPO_OWNER: 'angular',
|
||||||
CI_REPO_NAME: 'angular',
|
CI_REPO_NAME: 'angular',
|
||||||
CI_PULL_REQUEST: 'false',
|
CI_PULL_REQUEST: 'false',
|
||||||
CI_BRANCH: '4.3.x',
|
CI_BRANCH: '4.3.x',
|
||||||
CI_STABLE_BRANCH: '4.3.x',
|
CI_STABLE_BRANCH: '4.3.x',
|
||||||
CI_COMMIT: 'DUMMY_TEST_COMMIT',
|
CI_COMMIT: 'DUMMY_TEST_COMMIT',
|
||||||
})).toBe(
|
}))).toEqual({
|
||||||
|
skipped: true,
|
||||||
|
reason:
|
||||||
'Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ' +
|
'Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ' +
|
||||||
`(${getLatestCommitForBranch('4.3.x')}).`);
|
`(${getLatestCommit('4.3.x')}).`,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('archive - deploy success', () => {
|
it('archive - deploy success', () => {
|
||||||
expect(deployToFirebaseDryRun({
|
expect(computeDeploymentInfo(computeInputVars({
|
||||||
CI_REPO_OWNER: 'angular',
|
CI_REPO_OWNER: 'angular',
|
||||||
CI_REPO_NAME: 'angular',
|
CI_REPO_NAME: 'angular',
|
||||||
CI_PULL_REQUEST: 'false',
|
CI_PULL_REQUEST: 'false',
|
||||||
CI_BRANCH: '2.4.x',
|
CI_BRANCH: '2.4.x',
|
||||||
CI_STABLE_BRANCH: '4.3.x',
|
CI_STABLE_BRANCH: '4.3.x',
|
||||||
CI_COMMIT: getLatestCommitForBranch('2.4.x'),
|
CI_COMMIT: getLatestCommit('2.4.x'),
|
||||||
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
}))).toEqual({
|
||||||
})).toBe(
|
deployEnv: 'archive',
|
||||||
'Git branch : 2.4.x\n' +
|
projectId: 'v2-angular-io',
|
||||||
'Build/deploy mode : archive\n' +
|
siteId: 'v2-angular-io',
|
||||||
'Firebase project : v2-angular-io\n' +
|
deployedUrl: 'https://v2.angular.io/',
|
||||||
'Firebase site : v2-angular-io\n' +
|
});
|
||||||
'Deployment URL : https://v2.angular.io/');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('archive - v9-angular-io multisite special case - deploy success', () => {
|
it('archive - v9-angular-io multisite special case - deploy success', () => {
|
||||||
expect(deployToFirebaseDryRun({
|
expect(computeDeploymentInfo(computeInputVars({
|
||||||
CI_REPO_OWNER: 'angular',
|
CI_REPO_OWNER: 'angular',
|
||||||
CI_REPO_NAME: 'angular',
|
CI_REPO_NAME: 'angular',
|
||||||
CI_PULL_REQUEST: 'false',
|
CI_PULL_REQUEST: 'false',
|
||||||
CI_BRANCH: '9.1.x',
|
CI_BRANCH: '9.1.x',
|
||||||
CI_STABLE_BRANCH: '10.0.x',
|
CI_STABLE_BRANCH: '10.0.x',
|
||||||
CI_COMMIT: getLatestCommitForBranch('9.1.x'),
|
CI_COMMIT: getLatestCommit('9.1.x'),
|
||||||
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
}))).toEqual({
|
||||||
})).toBe(
|
deployEnv: 'archive',
|
||||||
'Git branch : 9.1.x\n' +
|
projectId: 'aio-staging',
|
||||||
'Build/deploy mode : archive\n' +
|
siteId: 'v9-angular-io',
|
||||||
'Firebase project : aio-staging\n' +
|
deployedUrl: 'https://v9.angular.io/',
|
||||||
'Firebase site : v9-angular-io\n' +
|
});
|
||||||
'Deployment URL : https://v9.angular.io/');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('archive - skip deploy - commit not HEAD', () => {
|
it('archive - skip deploy - commit not HEAD', () => {
|
||||||
expect(deployToFirebaseDryRun({
|
expect(computeDeploymentInfo(computeInputVars({
|
||||||
CI_REPO_OWNER: 'angular',
|
CI_REPO_OWNER: 'angular',
|
||||||
CI_REPO_NAME: 'angular',
|
CI_REPO_NAME: 'angular',
|
||||||
CI_PULL_REQUEST: 'false',
|
CI_PULL_REQUEST: 'false',
|
||||||
CI_BRANCH: '2.4.x',
|
CI_BRANCH: '2.4.x',
|
||||||
CI_STABLE_BRANCH: '4.3.x',
|
CI_STABLE_BRANCH: '4.3.x',
|
||||||
CI_COMMIT: 'DUMMY_TEST_COMMIT',
|
CI_COMMIT: 'DUMMY_TEST_COMMIT',
|
||||||
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
}))).toEqual({
|
||||||
})).toBe(
|
skipped: true,
|
||||||
|
reason:
|
||||||
'Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ' +
|
'Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ' +
|
||||||
`(${getLatestCommitForBranch('2.4.x')}).`);
|
`(${getLatestCommit('2.4.x')}).`,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('archive - skip deploy - major same as stable, minor less than stable', () => {
|
it('archive - skip deploy - major same as stable, minor less than stable', () => {
|
||||||
expect(deployToFirebaseDryRun({
|
expect(computeDeploymentInfo(computeInputVars({
|
||||||
CI_REPO_OWNER: 'angular',
|
CI_REPO_OWNER: 'angular',
|
||||||
CI_REPO_NAME: 'angular',
|
CI_REPO_NAME: 'angular',
|
||||||
CI_PULL_REQUEST: 'false',
|
CI_PULL_REQUEST: 'false',
|
||||||
CI_BRANCH: '2.1.x',
|
CI_BRANCH: '2.1.x',
|
||||||
CI_STABLE_BRANCH: '2.2.x',
|
CI_STABLE_BRANCH: '2.2.x',
|
||||||
CI_COMMIT: getLatestCommitForBranch('2.1.x'),
|
CI_COMMIT: getLatestCommit('2.1.x'),
|
||||||
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
}))).toEqual({
|
||||||
})).toBe(
|
skipped: true,
|
||||||
|
reason:
|
||||||
'Skipping deploy of branch "2.1.x" to Firebase.\n' +
|
'Skipping deploy of branch "2.1.x" to Firebase.\n' +
|
||||||
'There is a more recent branch with the same major version: "2.4.x"');
|
'There is a more recent branch with the same major version: "2.4.x"',
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('archive - skip deploy - major lower than stable, minor not latest', () => {
|
it('archive - skip deploy - major lower than stable, minor not latest', () => {
|
||||||
expect(deployToFirebaseDryRun({
|
expect(computeDeploymentInfo(computeInputVars({
|
||||||
CI_REPO_OWNER: 'angular',
|
CI_REPO_OWNER: 'angular',
|
||||||
CI_REPO_NAME: 'angular',
|
CI_REPO_NAME: 'angular',
|
||||||
CI_PULL_REQUEST: 'false',
|
CI_PULL_REQUEST: 'false',
|
||||||
CI_BRANCH: '2.1.x',
|
CI_BRANCH: '2.1.x',
|
||||||
CI_STABLE_BRANCH: '4.3.x',
|
CI_STABLE_BRANCH: '4.3.x',
|
||||||
CI_COMMIT: getLatestCommitForBranch('2.1.x'),
|
CI_COMMIT: getLatestCommit('2.1.x'),
|
||||||
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
}))).toEqual({
|
||||||
})).toBe(
|
skipped: true,
|
||||||
|
reason:
|
||||||
'Skipping deploy of branch "2.1.x" to Firebase.\n' +
|
'Skipping deploy of branch "2.1.x" to Firebase.\n' +
|
||||||
'There is a more recent branch with the same major version: "2.4.x"');
|
'There is a more recent branch with the same major version: "2.4.x"',
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rc - deploy success - major higher than stable', () => {
|
it('rc - deploy success - major higher than stable', () => {
|
||||||
expect(deployToFirebaseDryRun({
|
expect(computeDeploymentInfo(computeInputVars({
|
||||||
CI_REPO_OWNER: 'angular',
|
CI_REPO_OWNER: 'angular',
|
||||||
CI_REPO_NAME: 'angular',
|
CI_REPO_NAME: 'angular',
|
||||||
CI_PULL_REQUEST: 'false',
|
CI_PULL_REQUEST: 'false',
|
||||||
CI_BRANCH: '4.4.x',
|
CI_BRANCH: '4.4.x',
|
||||||
CI_STABLE_BRANCH: '2.2.x',
|
CI_STABLE_BRANCH: '2.2.x',
|
||||||
CI_COMMIT: getLatestCommitForBranch('4.4.x'),
|
CI_COMMIT: getLatestCommit('4.4.x'),
|
||||||
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
}))).toEqual({
|
||||||
})).toBe(
|
deployEnv: 'rc',
|
||||||
'Git branch : 4.4.x\n' +
|
projectId: 'angular-io',
|
||||||
'Build/deploy mode : rc\n' +
|
siteId: 'rc-angular-io-site',
|
||||||
'Firebase project : angular-io\n' +
|
deployedUrl: 'https://rc.angular.io/',
|
||||||
'Firebase site : rc-angular-io-site\n' +
|
});
|
||||||
'Deployment URL : https://rc.angular.io/');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rc - deploy success - major same as stable, minor higher', () => {
|
it('rc - deploy success - major same as stable, minor higher', () => {
|
||||||
expect(deployToFirebaseDryRun({
|
expect(computeDeploymentInfo(computeInputVars({
|
||||||
CI_REPO_OWNER: 'angular',
|
CI_REPO_OWNER: 'angular',
|
||||||
CI_REPO_NAME: 'angular',
|
CI_REPO_NAME: 'angular',
|
||||||
CI_PULL_REQUEST: 'false',
|
CI_PULL_REQUEST: 'false',
|
||||||
CI_BRANCH: '2.4.x',
|
CI_BRANCH: '2.4.x',
|
||||||
CI_STABLE_BRANCH: '2.2.x',
|
CI_STABLE_BRANCH: '2.2.x',
|
||||||
CI_COMMIT: getLatestCommitForBranch('2.4.x'),
|
CI_COMMIT: getLatestCommit('2.4.x'),
|
||||||
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
}))).toEqual({
|
||||||
})).toBe(
|
deployEnv: 'rc',
|
||||||
'Git branch : 2.4.x\n' +
|
projectId: 'angular-io',
|
||||||
'Build/deploy mode : rc\n' +
|
siteId: 'rc-angular-io-site',
|
||||||
'Firebase project : angular-io\n' +
|
deployedUrl: 'https://rc.angular.io/',
|
||||||
'Firebase site : rc-angular-io-site\n' +
|
});
|
||||||
'Deployment URL : https://rc.angular.io/');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rc - skip deploy - commit not HEAD', () => {
|
it('rc - skip deploy - commit not HEAD', () => {
|
||||||
expect(deployToFirebaseDryRun({
|
expect(computeDeploymentInfo(computeInputVars({
|
||||||
CI_REPO_OWNER: 'angular',
|
CI_REPO_OWNER: 'angular',
|
||||||
CI_REPO_NAME: 'angular',
|
CI_REPO_NAME: 'angular',
|
||||||
CI_PULL_REQUEST: 'false',
|
CI_PULL_REQUEST: 'false',
|
||||||
CI_BRANCH: '2.4.x',
|
CI_BRANCH: '2.4.x',
|
||||||
CI_STABLE_BRANCH: '2.2.x',
|
CI_STABLE_BRANCH: '2.2.x',
|
||||||
CI_COMMIT: 'DUMMY_TEST_COMMIT',
|
CI_COMMIT: 'DUMMY_TEST_COMMIT',
|
||||||
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
}))).toEqual({
|
||||||
})).toBe(
|
skipped: true,
|
||||||
|
reason:
|
||||||
'Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ' +
|
'Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ' +
|
||||||
`(${getLatestCommitForBranch('2.4.x')}).`);
|
`(${getLatestCommit('2.4.x')}).`,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rc - skip deploy - major same as stable, minor not latest', () => {
|
it('rc - skip deploy - major same as stable, minor not latest', () => {
|
||||||
expect(deployToFirebaseDryRun({
|
expect(computeDeploymentInfo(computeInputVars({
|
||||||
CI_REPO_OWNER: 'angular',
|
CI_REPO_OWNER: 'angular',
|
||||||
CI_REPO_NAME: 'angular',
|
CI_REPO_NAME: 'angular',
|
||||||
CI_PULL_REQUEST: 'false',
|
CI_PULL_REQUEST: 'false',
|
||||||
CI_BRANCH: '2.1.x',
|
CI_BRANCH: '2.1.x',
|
||||||
CI_STABLE_BRANCH: '2.0.x',
|
CI_STABLE_BRANCH: '2.0.x',
|
||||||
CI_COMMIT: getLatestCommitForBranch('2.1.x'),
|
CI_COMMIT: getLatestCommit('2.1.x'),
|
||||||
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
}))).toEqual({
|
||||||
})).toBe(
|
skipped: true,
|
||||||
|
reason:
|
||||||
'Skipping deploy of branch "2.1.x" to Firebase.\n' +
|
'Skipping deploy of branch "2.1.x" to Firebase.\n' +
|
||||||
'There is a more recent branch with the same major version: "2.4.x"');
|
'There is a more recent branch with the same major version: "2.4.x"',
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rc - skip deploy - major higher than stable, minor not latest', () => {
|
it('rc - skip deploy - major higher than stable, minor not latest', () => {
|
||||||
expect(deployToFirebaseDryRun({
|
expect(computeDeploymentInfo(computeInputVars({
|
||||||
CI_REPO_OWNER: 'angular',
|
CI_REPO_OWNER: 'angular',
|
||||||
CI_REPO_NAME: 'angular',
|
CI_REPO_NAME: 'angular',
|
||||||
CI_PULL_REQUEST: 'false',
|
CI_PULL_REQUEST: 'false',
|
||||||
CI_BRANCH: '4.3.x',
|
CI_BRANCH: '4.3.x',
|
||||||
CI_STABLE_BRANCH: '2.4.x',
|
CI_STABLE_BRANCH: '2.4.x',
|
||||||
CI_COMMIT: getLatestCommitForBranch('4.3.x'),
|
CI_COMMIT: getLatestCommit('4.3.x'),
|
||||||
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
|
}))).toEqual({
|
||||||
})).toBe(
|
skipped: true,
|
||||||
|
reason:
|
||||||
'Skipping deploy of branch "4.3.x" to Firebase.\n' +
|
'Skipping deploy of branch "4.3.x" to Firebase.\n' +
|
||||||
'There is a more recent branch with the same major version: "4.4.x"');
|
'There is a more recent branch with the same major version: "4.4.x"',
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue