From 5f1e9758f57ce38f96dc5287c86e3ca1ce416176 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Mon, 2 Nov 2020 17:54:24 +0000 Subject: [PATCH] build(docs-infra): ensure that deployment works on CI (#39535) The actual "main" part of the script that is executed was using an uninitialized variable. This is fixed and a test is added to check. PR Close #39535 --- aio/scripts/deploy-to-firebase.js | 2 +- aio/scripts/deploy-to-firebase.spec.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/aio/scripts/deploy-to-firebase.js b/aio/scripts/deploy-to-firebase.js index 1f700dda00..a381a7a592 100644 --- a/aio/scripts/deploy-to-firebase.js +++ b/aio/scripts/deploy-to-firebase.js @@ -30,7 +30,7 @@ if (require.main === module) { console.log(deploymentInfo.reason); } else { console.log( - `Git branch : ${currentBranch}\n` + + `Git branch : ${inputVars.currentBranch}\n` + `Build/deploy mode : ${deploymentInfo.deployEnv}\n` + `Firebase project : ${deploymentInfo.projectId}\n` + `Firebase site : ${deploymentInfo.siteId}\n` + diff --git a/aio/scripts/deploy-to-firebase.spec.js b/aio/scripts/deploy-to-firebase.spec.js index 1633b983d2..02a09a3aed 100644 --- a/aio/scripts/deploy-to-firebase.spec.js +++ b/aio/scripts/deploy-to-firebase.spec.js @@ -1,6 +1,7 @@ #!/usr/bin/env node 'use strict'; +const {execSync} = require('child_process'); const {computeDeploymentInfo, computeInputVars, getLatestCommit} = require('./deploy-to-firebase'); @@ -259,4 +260,23 @@ describe('deploy-to-firebase:', () => { 'There is a more recent branch with the same major version: "4.4.x"', }); }); + + it('integration - should run the main script without error', () => { + const cmd = `"${process.execPath}" "${__dirname}/deploy-to-firebase" --dry-run`; + const env = { + CI_REPO_OWNER: 'angular', + CI_REPO_NAME: 'angular', + CI_PULL_REQUEST: 'false', + CI_BRANCH: 'master', + CI_COMMIT: getLatestCommit('master') + }; + const result = execSync(cmd, {encoding: 'utf8', env}).trim(); + expect(result).toBe( + 'Git branch : master\n' + + 'Build/deploy mode : next\n' + + 'Firebase project : angular-io\n' + + 'Firebase site : next-angular-io-site\n' + + 'Deployment URLs : https://next.angular.io/\n' + + ' https://next-angular-io-site.web.app/'); + }); });