refactor(docs-infra): support multiple deployments per run (#39853)
Previously, the `deploy-to-firebase.js` script would only perform one deployment operation on each run. This commit adds support for performing multiple deployment operations. NOTE: In a subsequent commit, this will be leveraged fix an issue with `rc.angular.io` redirects in the presence of a ServiceWorker by deploying the same artifacts to multiple Firebase projects/sites. See #39760 for more details. PR Close #39853
This commit is contained in:
parent
6e6eee6d5b
commit
53bd832c77
|
@ -15,7 +15,7 @@ const NG_REMOTE_URL = `https://github.com/${REPO_SLUG}.git`;
|
||||||
|
|
||||||
// Exports
|
// Exports
|
||||||
module.exports = {
|
module.exports = {
|
||||||
computeDeploymentInfo,
|
computeDeploymentsInfo,
|
||||||
computeInputVars,
|
computeInputVars,
|
||||||
getLatestCommit,
|
getLatestCommit,
|
||||||
};
|
};
|
||||||
|
@ -24,7 +24,15 @@ module.exports = {
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
const isDryRun = process.argv[2] === '--dry-run';
|
const isDryRun = process.argv[2] === '--dry-run';
|
||||||
const inputVars = computeInputVars(process.env);
|
const inputVars = computeInputVars(process.env);
|
||||||
const deploymentInfo = computeDeploymentInfo(inputVars);
|
const deploymentsInfo = computeDeploymentsInfo(inputVars);
|
||||||
|
const totalDeployments = deploymentsInfo.length;
|
||||||
|
|
||||||
|
console.log(`Total deployments: ${totalDeployments}`);
|
||||||
|
|
||||||
|
deploymentsInfo.forEach((deploymentInfo, idx) => {
|
||||||
|
console.log(
|
||||||
|
`\n\n\nDeployment ${idx + 1} of ${totalDeployments}\n` +
|
||||||
|
'-----------------');
|
||||||
|
|
||||||
if (deploymentInfo.skipped) {
|
if (deploymentInfo.skipped) {
|
||||||
console.log(deploymentInfo.reason);
|
console.log(deploymentInfo.reason);
|
||||||
|
@ -44,6 +52,8 @@ if (require.main === module) {
|
||||||
deploy({...inputVars, ...deploymentInfo});
|
deploy({...inputVars, ...deploymentInfo});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
|
@ -63,23 +73,25 @@ function checkPayloadSize() {
|
||||||
yarn('payload-size');
|
yarn('payload-size');
|
||||||
}
|
}
|
||||||
|
|
||||||
function computeDeploymentInfo(
|
function computeDeploymentsInfo(
|
||||||
{currentBranch, currentCommit, isPullRequest, repoName, repoOwner, stableBranch}) {
|
{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 (`${repoOwner}/${repoName}` !== REPO_SLUG) {
|
if (`${repoOwner}/${repoName}` !== REPO_SLUG) {
|
||||||
return skipDeployment(`Skipping deploy because this is not ${REPO_SLUG}.`);
|
return [skipDeployment(`Skipping deploy because this is not ${REPO_SLUG}.`)];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 (isPullRequest) {
|
if (isPullRequest) {
|
||||||
return skipDeployment('Skipping deploy because this is a PR build.');
|
return [skipDeployment('Skipping deploy because this is a PR build.')];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 = getLatestCommit(currentBranch);
|
const latestCommit = getLatestCommit(currentBranch);
|
||||||
if (currentCommit !== latestCommit) {
|
if (currentCommit !== latestCommit) {
|
||||||
return skipDeployment(
|
return [
|
||||||
`Skipping deploy because ${currentCommit} is not the latest commit (${latestCommit}).`);
|
skipDeployment(
|
||||||
|
`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.
|
||||||
|
@ -120,9 +132,9 @@ function computeDeploymentInfo(
|
||||||
};
|
};
|
||||||
|
|
||||||
if (currentBranch === 'master') {
|
if (currentBranch === 'master') {
|
||||||
return deploymentInfoPerTarget.next;
|
return [deploymentInfoPerTarget.next];
|
||||||
} else if (currentBranch === stableBranch) {
|
} else if (currentBranch === stableBranch) {
|
||||||
return deploymentInfoPerTarget.stable;
|
return [deploymentInfoPerTarget.stable];
|
||||||
} else {
|
} else {
|
||||||
const stableBranchMajorVersion = computeMajorVersion(stableBranch);
|
const stableBranchMajorVersion = computeMajorVersion(stableBranch);
|
||||||
|
|
||||||
|
@ -140,20 +152,22 @@ function computeDeploymentInfo(
|
||||||
// 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 (currentBranch !== mostRecentMinorVersionBranch) {
|
if (currentBranch !== mostRecentMinorVersionBranch) {
|
||||||
return skipDeployment(
|
return [
|
||||||
|
skipDeployment(
|
||||||
`Skipping deploy of branch "${currentBranch}" 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}"`),
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return (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`.
|
||||||
deploymentInfoPerTarget.archive :
|
[deploymentInfoPerTarget.archive] :
|
||||||
// This is the latest minor version for a major that is equal or greater than the stable
|
// This is the latest minor version for a major that is equal or greater than the stable
|
||||||
// major version, but not the stable version itself:
|
// major version, but not the stable version itself:
|
||||||
// Deploy as `rc`.
|
// Deploy as `rc`.
|
||||||
deploymentInfoPerTarget.rc;
|
[deploymentInfoPerTarget.rc];
|
||||||
}
|
}
|
||||||
|
|
||||||
// We should never get here.
|
// We should never get here.
|
||||||
|
|
|
@ -2,283 +2,317 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const {execSync} = require('child_process');
|
const {execSync} = require('child_process');
|
||||||
const {computeDeploymentInfo, computeInputVars, getLatestCommit} = require('./deploy-to-firebase');
|
const {computeDeploymentsInfo, computeInputVars, getLatestCommit} = require('./deploy-to-firebase');
|
||||||
|
|
||||||
|
|
||||||
describe('deploy-to-firebase:', () => {
|
describe('deploy-to-firebase:', () => {
|
||||||
// Helpers
|
// Helpers
|
||||||
const jsonFunctionReplacer = (_key, val) =>
|
const jsonFunctionReplacer = (_key, val) =>
|
||||||
(typeof val === 'function') ? `function:${val.name}` : val;
|
(typeof val === 'function') ? `function:${val.name}` : val;
|
||||||
const getDeploymentInfoFor = env => {
|
const getDeploymentsInfoFor = env => {
|
||||||
const deploymentInfo = computeDeploymentInfo(computeInputVars(env));
|
const deploymentsInfo = computeDeploymentsInfo(computeInputVars(env));
|
||||||
return JSON.parse(JSON.stringify(deploymentInfo, jsonFunctionReplacer));
|
return JSON.parse(JSON.stringify(deploymentsInfo, jsonFunctionReplacer));
|
||||||
};
|
};
|
||||||
|
|
||||||
it('master - skip deploy - not angular', () => {
|
it('master - skip deploy - not angular', () => {
|
||||||
expect(getDeploymentInfoFor({
|
expect(getDeploymentsInfoFor({
|
||||||
CI_REPO_OWNER: 'angular',
|
CI_REPO_OWNER: 'angular',
|
||||||
CI_REPO_NAME: 'notangular',
|
CI_REPO_NAME: 'notangular',
|
||||||
})).toEqual({
|
})).toEqual([
|
||||||
|
{
|
||||||
skipped: true,
|
skipped: true,
|
||||||
reason: 'Skipping deploy because this is not angular/angular.',
|
reason: 'Skipping deploy because this is not angular/angular.',
|
||||||
});
|
},
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('master - skip deploy - angular fork', () => {
|
it('master - skip deploy - angular fork', () => {
|
||||||
expect(getDeploymentInfoFor({
|
expect(getDeploymentsInfoFor({
|
||||||
CI_REPO_OWNER: 'notangular',
|
CI_REPO_OWNER: 'notangular',
|
||||||
CI_REPO_NAME: 'angular',
|
CI_REPO_NAME: 'angular',
|
||||||
})).toEqual({
|
})).toEqual([
|
||||||
|
{
|
||||||
skipped: true,
|
skipped: true,
|
||||||
reason: 'Skipping deploy because this is not angular/angular.',
|
reason: 'Skipping deploy because this is not angular/angular.',
|
||||||
});
|
},
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('master - skip deploy - pull request', () => {
|
it('master - skip deploy - pull request', () => {
|
||||||
expect(getDeploymentInfoFor({
|
expect(getDeploymentsInfoFor({
|
||||||
CI_REPO_OWNER: 'angular',
|
CI_REPO_OWNER: 'angular',
|
||||||
CI_REPO_NAME: 'angular',
|
CI_REPO_NAME: 'angular',
|
||||||
CI_PULL_REQUEST: 'true',
|
CI_PULL_REQUEST: 'true',
|
||||||
})).toEqual({
|
})).toEqual([
|
||||||
|
{
|
||||||
skipped: true,
|
skipped: true,
|
||||||
reason: 'Skipping deploy because this is a PR build.',
|
reason: 'Skipping deploy because this is a PR build.',
|
||||||
});
|
},
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('master - deploy success', () => {
|
it('master - deploy success', () => {
|
||||||
expect(getDeploymentInfoFor({
|
expect(getDeploymentsInfoFor({
|
||||||
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: getLatestCommit('master'),
|
CI_COMMIT: getLatestCommit('master'),
|
||||||
})).toEqual({
|
})).toEqual([
|
||||||
|
{
|
||||||
deployEnv: 'next',
|
deployEnv: 'next',
|
||||||
projectId: 'angular-io',
|
projectId: 'angular-io',
|
||||||
siteId: 'next-angular-io-site',
|
siteId: 'next-angular-io-site',
|
||||||
deployedUrl: 'https://next.angular.io/',
|
deployedUrl: 'https://next.angular.io/',
|
||||||
preDeployActions: ['function:build', 'function:checkPayloadSize'],
|
preDeployActions: ['function:build', 'function:checkPayloadSize'],
|
||||||
postDeployActions: ['function:testPwaScore'],
|
postDeployActions: ['function:testPwaScore'],
|
||||||
});
|
},
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('master - skip deploy - commit not HEAD', () => {
|
it('master - skip deploy - commit not HEAD', () => {
|
||||||
expect(getDeploymentInfoFor({
|
expect(getDeploymentsInfoFor({
|
||||||
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',
|
||||||
})).toEqual({
|
})).toEqual([
|
||||||
|
{
|
||||||
skipped: true,
|
skipped: true,
|
||||||
reason:
|
reason:
|
||||||
'Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ' +
|
'Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ' +
|
||||||
`(${getLatestCommit('master')}).`,
|
`(${getLatestCommit('master')}).`,
|
||||||
});
|
},
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('stable - deploy success', () => {
|
it('stable - deploy success', () => {
|
||||||
expect(getDeploymentInfoFor({
|
expect(getDeploymentsInfoFor({
|
||||||
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: getLatestCommit('4.3.x'),
|
CI_COMMIT: getLatestCommit('4.3.x'),
|
||||||
})).toEqual({
|
})).toEqual([
|
||||||
|
{
|
||||||
deployEnv: 'stable',
|
deployEnv: 'stable',
|
||||||
projectId: 'angular-io',
|
projectId: 'angular-io',
|
||||||
siteId: 'v4-angular-io-site',
|
siteId: 'v4-angular-io-site',
|
||||||
deployedUrl: 'https://angular.io/',
|
deployedUrl: 'https://angular.io/',
|
||||||
preDeployActions: ['function:build', 'function:checkPayloadSize'],
|
preDeployActions: ['function:build', 'function:checkPayloadSize'],
|
||||||
postDeployActions: ['function:testPwaScore'],
|
postDeployActions: ['function:testPwaScore'],
|
||||||
});
|
},
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('stable - skip deploy - commit not HEAD', () => {
|
it('stable - skip deploy - commit not HEAD', () => {
|
||||||
expect(getDeploymentInfoFor({
|
expect(getDeploymentsInfoFor({
|
||||||
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',
|
||||||
})).toEqual({
|
})).toEqual([
|
||||||
|
{
|
||||||
skipped: true,
|
skipped: true,
|
||||||
reason:
|
reason:
|
||||||
'Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ' +
|
'Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ' +
|
||||||
`(${getLatestCommit('4.3.x')}).`,
|
`(${getLatestCommit('4.3.x')}).`,
|
||||||
});
|
},
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('archive - deploy success', () => {
|
it('archive - deploy success', () => {
|
||||||
expect(getDeploymentInfoFor({
|
expect(getDeploymentsInfoFor({
|
||||||
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: getLatestCommit('2.4.x'),
|
CI_COMMIT: getLatestCommit('2.4.x'),
|
||||||
})).toEqual({
|
})).toEqual([
|
||||||
|
{
|
||||||
deployEnv: 'archive',
|
deployEnv: 'archive',
|
||||||
projectId: 'angular-io',
|
projectId: 'angular-io',
|
||||||
siteId: 'v2-angular-io-site',
|
siteId: 'v2-angular-io-site',
|
||||||
deployedUrl: 'https://v2.angular.io/',
|
deployedUrl: 'https://v2.angular.io/',
|
||||||
preDeployActions: ['function:build', 'function:checkPayloadSize'],
|
preDeployActions: ['function:build', 'function:checkPayloadSize'],
|
||||||
postDeployActions: ['function:testPwaScore'],
|
postDeployActions: ['function:testPwaScore'],
|
||||||
});
|
},
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
// v9 used to be special-cased, because it was piloting the Firebase hosting "multisites" setup.
|
// v9 used to be special-cased, because it was 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.
|
||||||
it('archive - deploy success (no special case for v9)', () => {
|
it('archive - deploy success (no special case for v9)', () => {
|
||||||
expect(getDeploymentInfoFor({
|
expect(getDeploymentsInfoFor({
|
||||||
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: getLatestCommit('9.1.x'),
|
CI_COMMIT: getLatestCommit('9.1.x'),
|
||||||
})).toEqual({
|
})).toEqual([
|
||||||
|
{
|
||||||
deployEnv: 'archive',
|
deployEnv: 'archive',
|
||||||
projectId: 'angular-io',
|
projectId: 'angular-io',
|
||||||
siteId: 'v9-angular-io-site',
|
siteId: 'v9-angular-io-site',
|
||||||
deployedUrl: 'https://v9.angular.io/',
|
deployedUrl: 'https://v9.angular.io/',
|
||||||
preDeployActions: ['function:build', 'function:checkPayloadSize'],
|
preDeployActions: ['function:build', 'function:checkPayloadSize'],
|
||||||
postDeployActions: ['function:testPwaScore'],
|
postDeployActions: ['function:testPwaScore'],
|
||||||
});
|
},
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('archive - skip deploy - commit not HEAD', () => {
|
it('archive - skip deploy - commit not HEAD', () => {
|
||||||
expect(getDeploymentInfoFor({
|
expect(getDeploymentsInfoFor({
|
||||||
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',
|
||||||
})).toEqual({
|
})).toEqual([
|
||||||
|
{
|
||||||
skipped: true,
|
skipped: true,
|
||||||
reason:
|
reason:
|
||||||
'Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ' +
|
'Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ' +
|
||||||
`(${getLatestCommit('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(getDeploymentInfoFor({
|
expect(getDeploymentsInfoFor({
|
||||||
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: getLatestCommit('2.1.x'),
|
CI_COMMIT: getLatestCommit('2.1.x'),
|
||||||
})).toEqual({
|
})).toEqual([
|
||||||
|
{
|
||||||
skipped: true,
|
skipped: true,
|
||||||
reason:
|
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(getDeploymentInfoFor({
|
expect(getDeploymentsInfoFor({
|
||||||
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: getLatestCommit('2.1.x'),
|
CI_COMMIT: getLatestCommit('2.1.x'),
|
||||||
})).toEqual({
|
})).toEqual([
|
||||||
|
{
|
||||||
skipped: true,
|
skipped: true,
|
||||||
reason:
|
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(getDeploymentInfoFor({
|
expect(getDeploymentsInfoFor({
|
||||||
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: getLatestCommit('4.4.x'),
|
CI_COMMIT: getLatestCommit('4.4.x'),
|
||||||
})).toEqual({
|
})).toEqual([
|
||||||
|
{
|
||||||
deployEnv: 'rc',
|
deployEnv: 'rc',
|
||||||
projectId: 'angular-io',
|
projectId: 'angular-io',
|
||||||
siteId: 'rc-angular-io-site',
|
siteId: 'rc-angular-io-site',
|
||||||
deployedUrl: 'https://rc.angular.io/',
|
deployedUrl: 'https://rc.angular.io/',
|
||||||
preDeployActions: ['function:build', 'function:checkPayloadSize'],
|
preDeployActions: ['function:build', 'function:checkPayloadSize'],
|
||||||
postDeployActions: ['function:testPwaScore'],
|
postDeployActions: ['function:testPwaScore'],
|
||||||
});
|
},
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rc - deploy success - major same as stable, minor higher', () => {
|
it('rc - deploy success - major same as stable, minor higher', () => {
|
||||||
expect(getDeploymentInfoFor({
|
expect(getDeploymentsInfoFor({
|
||||||
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: getLatestCommit('2.4.x'),
|
CI_COMMIT: getLatestCommit('2.4.x'),
|
||||||
})).toEqual({
|
})).toEqual([
|
||||||
|
{
|
||||||
deployEnv: 'rc',
|
deployEnv: 'rc',
|
||||||
projectId: 'angular-io',
|
projectId: 'angular-io',
|
||||||
siteId: 'rc-angular-io-site',
|
siteId: 'rc-angular-io-site',
|
||||||
deployedUrl: 'https://rc.angular.io/',
|
deployedUrl: 'https://rc.angular.io/',
|
||||||
preDeployActions: ['function:build', 'function:checkPayloadSize'],
|
preDeployActions: ['function:build', 'function:checkPayloadSize'],
|
||||||
postDeployActions: ['function:testPwaScore'],
|
postDeployActions: ['function:testPwaScore'],
|
||||||
});
|
},
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rc - skip deploy - commit not HEAD', () => {
|
it('rc - skip deploy - commit not HEAD', () => {
|
||||||
expect(getDeploymentInfoFor({
|
expect(getDeploymentsInfoFor({
|
||||||
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',
|
||||||
})).toEqual({
|
})).toEqual([
|
||||||
|
{
|
||||||
skipped: true,
|
skipped: true,
|
||||||
reason:
|
reason:
|
||||||
'Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ' +
|
'Skipping deploy because DUMMY_TEST_COMMIT is not the latest commit ' +
|
||||||
`(${getLatestCommit('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(getDeploymentInfoFor({
|
expect(getDeploymentsInfoFor({
|
||||||
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: getLatestCommit('2.1.x'),
|
CI_COMMIT: getLatestCommit('2.1.x'),
|
||||||
})).toEqual({
|
})).toEqual([
|
||||||
|
{
|
||||||
skipped: true,
|
skipped: true,
|
||||||
reason:
|
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(getDeploymentInfoFor({
|
expect(getDeploymentsInfoFor({
|
||||||
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: getLatestCommit('4.3.x'),
|
CI_COMMIT: getLatestCommit('4.3.x'),
|
||||||
})).toEqual({
|
})).toEqual([
|
||||||
|
{
|
||||||
skipped: true,
|
skipped: true,
|
||||||
reason:
|
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"',
|
||||||
});
|
},
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('integration - should run the main script without error', () => {
|
it('integration - should run the main script without error', () => {
|
||||||
|
@ -293,6 +327,12 @@ describe('deploy-to-firebase:', () => {
|
||||||
};
|
};
|
||||||
const result = execSync(cmd, {encoding: 'utf8', env}).trim();
|
const result = execSync(cmd, {encoding: 'utf8', env}).trim();
|
||||||
expect(result).toBe(
|
expect(result).toBe(
|
||||||
|
'Total deployments: 1\n' +
|
||||||
|
'\n' +
|
||||||
|
'\n' +
|
||||||
|
'\n' +
|
||||||
|
'Deployment 1 of 1\n' +
|
||||||
|
'-----------------\n' +
|
||||||
'Git branch : master\n' +
|
'Git branch : master\n' +
|
||||||
`Git commit : ${commit}\n` +
|
`Git commit : ${commit}\n` +
|
||||||
'Build/deploy mode : next\n' +
|
'Build/deploy mode : next\n' +
|
||||||
|
|
Loading…
Reference in New Issue