build(docs-infra): add support for RC deployments to deployment script (#39470)

This commit updates the angular.io deployment script
(`deploy-to-firebase.js`) to support deploying release-candidate
versions.

This is part of the work needed to prepare angular.io for our
[new versioning/branching process][1] (also tracked in #39366).

[1]: https://docs.google.com/document/d/197kVillDwx-RZtSVOBtPb4BBIAw0E9RT3q3v6DZkykU

PR Close #39470
This commit is contained in:
George Kalpakas 2020-10-28 12:23:57 +02:00 committed by Joey Perrott
parent 51fe0fe622
commit 1aaf556815
2 changed files with 99 additions and 33 deletions

View File

@ -58,6 +58,12 @@ const deployInfoPerTarget = {
siteId: 'aio-staging',
deployedUrl: 'https://next.angular.io/',
},
rc: {
deployEnv: 'rc',
projectId: 'angular-io',
siteId: 'rc-angular-io-site',
deployedUrl: 'https://rc.angular.io/',
},
stable: {
deployEnv: 'stable',
projectId: 'angular-io',
@ -80,17 +86,8 @@ if (CI_BRANCH === 'master') {
} 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 =
const mostRecentMinorVersionBranch =
// List the branches that start with the major version.
exec(`git ls-remote ${NG_REMOTE_URL} refs/heads/${currentBranchMajorVersion}.*.x`).split('\n')
// Extract the version number.
@ -100,15 +97,24 @@ if (CI_BRANCH === 'master') {
// Get the highest version.
.pop();
// Do not deploy as it is not the latest branch for the given major version.
if (CI_BRANCH !== mostRecentMinorVersion) {
// 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.
if (CI_BRANCH !== mostRecentMinorVersionBranch) {
console.log(
`Skipping deploy of branch "${CI_BRANCH}" to Firebase.\n` +
`There is a more recent branch with the same major version: "${mostRecentMinorVersion}"`);
'There is a more recent branch with the same major version: ' +
`"${mostRecentMinorVersionBranch}"`);
process.exit(0);
}
deployInfo = deployInfoPerTarget.archive;
deployInfo = (currentBranchMajorVersion < stableBranchMajorVersion) ?
// This is the latest minor version for a major that is less than the stable major version:
// Deploy as `archive`.
deployInfoPerTarget.archive :
// 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:
// Deploy as `rc`.
deployInfoPerTarget.rc;
}
const {deployEnv, projectId, siteId, deployedUrl} = deployInfo;

View File

@ -142,7 +142,7 @@ describe('deploy-to-firebase:', () => {
`(${getLatestCommitForBranch('2.4.x')}).`);
});
it('archive - skip deploy - major version too high, lower minor', () => {
it('archive - skip deploy - major same as stable, minor less than stable', () => {
expect(deployToFirebaseDryRun({
CI_REPO_OWNER: 'angular',
CI_REPO_NAME: 'angular',
@ -153,26 +153,10 @@ describe('deploy-to-firebase:', () => {
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"');
'There is a more recent branch with the same major version: "2.4.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', () => {
it('archive - skip deploy - major lower than stable, minor not latest', () => {
expect(deployToFirebaseDryRun({
CI_REPO_OWNER: 'angular',
CI_REPO_NAME: 'angular',
@ -185,4 +169,80 @@ describe('deploy-to-firebase:', () => {
'Skipping deploy of branch "2.1.x" to Firebase.\n' +
'There is a more recent branch with the same major version: "2.4.x"');
});
it('rc - deploy success - major higher than stable', () => {
expect(deployToFirebaseDryRun({
CI_REPO_OWNER: 'angular',
CI_REPO_NAME: 'angular',
CI_PULL_REQUEST: 'false',
CI_BRANCH: '4.4.x',
CI_STABLE_BRANCH: '2.2.x',
CI_COMMIT: getLatestCommitForBranch('4.4.x'),
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
})).toBe(
'Git branch : 4.4.x\n' +
'Build/deploy mode : rc\n' +
'Firebase project : angular-io\n' +
'Firebase site : rc-angular-io-site\n' +
'Deployment URL : https://rc.angular.io/');
});
it('rc - deploy success - major same as stable, minor higher', () => {
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(
'Git branch : 2.4.x\n' +
'Build/deploy mode : rc\n' +
'Firebase project : angular-io\n' +
'Firebase site : rc-angular-io-site\n' +
'Deployment URL : https://rc.angular.io/');
});
it('rc - 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: '2.2.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('rc - skip deploy - major same as stable, minor not latest', () => {
expect(deployToFirebaseDryRun({
CI_REPO_OWNER: 'angular',
CI_REPO_NAME: 'angular',
CI_PULL_REQUEST: 'false',
CI_BRANCH: '2.1.x',
CI_STABLE_BRANCH: '2.0.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"');
});
it('rc - skip deploy - major higher than stable, minor not latest', () => {
expect(deployToFirebaseDryRun({
CI_REPO_OWNER: 'angular',
CI_REPO_NAME: 'angular',
CI_PULL_REQUEST: 'false',
CI_BRANCH: '4.3.x',
CI_STABLE_BRANCH: '2.4.x',
CI_COMMIT: getLatestCommitForBranch('4.3.x'),
CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN: 'XXXXX',
})).toBe(
'Skipping deploy of branch "4.3.x" to Firebase.\n' +
'There is a more recent branch with the same major version: "4.4.x"');
});
});