diff --git a/aio/scripts/deploy-to-firebase.js b/aio/scripts/deploy-to-firebase.js index e756462d5e..4e26bad9dd 100644 --- a/aio/scripts/deploy-to-firebase.js +++ b/aio/scripts/deploy-to-firebase.js @@ -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; diff --git a/aio/scripts/deploy-to-firebase.spec.js b/aio/scripts/deploy-to-firebase.spec.js index 6f32bd2ba8..e4022e29a6 100644 --- a/aio/scripts/deploy-to-firebase.spec.js +++ b/aio/scripts/deploy-to-firebase.spec.js @@ -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"'); + }); });