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
This commit is contained in:
Pete Bacon Darwin 2020-11-02 17:54:24 +00:00 committed by Joey Perrott
parent ad62edac9c
commit 5f1e9758f5
2 changed files with 21 additions and 1 deletions

View File

@ -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` +

View File

@ -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/');
});
});