Skip to content

Commit 0666c26

Browse files
committed
Split out promotion verification steps
1 parent 7fcc66a commit 0666c26

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

lib/promote_release.js

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,42 +25,55 @@ class ReleasePromotion {
2525
}
2626

2727
async promote() {
28-
const { version, prid, cli } = this;
29-
3028
// In the promotion stage, we can pull most relevant data
3129
// from the release commit created in the preparation stage.
3230
await this.parseDataFromReleaseCommit();
3331

32+
const { prid, cli, version } = this;
33+
3434
// Verify that PR is ready to promote.
35-
cli.startSpinner('Verifying PR promotion readiness');
3635
const {
3736
jenkinsReady,
3837
githubCIReady,
3938
isApproved
4039
} = await this.verifyPRAttributes();
40+
41+
cli.startSpinner('Verifying Jenkins CI status');
4142
if (!jenkinsReady) {
42-
cli.stopSpinner(`Jenkins CI is failing for #${prid}`);
43+
cli.stopSpinner(
44+
`Jenkins CI is failing for #${prid}`, cli.SPINNER_STATUS.FAILED);
4345
const proceed = await cli.prompt('Do you want to proceed?');
4446
if (!proceed) {
4547
cli.warn(`Aborting release promotion for version ${version}`);
4648
return;
4749
}
48-
} else if (!githubCIReady) {
49-
cli.stopSpinner(`GitHub CI is failing for #${prid}`);
50+
}
51+
cli.stopSpinner('Jenkins CI is passing');
52+
53+
cli.startSpinner('Verifying GitHub CI status');
54+
if (!githubCIReady) {
55+
cli.stopSpinner(
56+
`GitHub CI is failing for #${prid}`, cli.SPINNER_STATUS.FAILED);
5057
const proceed = await cli.prompt('Do you want to proceed?');
5158
if (!proceed) {
5259
cli.warn(`Aborting release promotion for version ${version}`);
5360
return;
5461
}
55-
} else if (!isApproved) {
56-
cli.stopSpinner(`#${prid} does not have sufficient approvals`);
62+
}
63+
cli.stopSpinner('GitHub CI is passing');
64+
65+
cli.startSpinner('Verifying PR approval status');
66+
if (!isApproved) {
67+
cli.stopSpinner(
68+
`#${prid} does not have sufficient approvals`,
69+
cli.SPINNER_STATUS.FAILED);
5770
const proceed = await cli.prompt('Do you want to proceed?');
5871
if (!proceed) {
5972
cli.warn(`Aborting release promotion for version ${version}`);
6073
return;
6174
}
6275
}
63-
cli.stopSpinner(`The release PR for ${version} is ready to promote!`);
76+
cli.stopSpinner(`#${prid} has necessary approvals`);
6477

6578
// Create and sign the release tag.
6679
const shouldTagAndSignRelease = await cli.prompt(
@@ -74,7 +87,7 @@ class ReleasePromotion {
7487
// Set up for next release.
7588
cli.startSpinner('Setting up for next release');
7689
await this.setupForNextRelease();
77-
cli.startSpinner('Successfully set up for next release');
90+
cli.stopSpinner('Successfully set up for next release');
7891

7992
const shouldMergeProposalBranch = await cli.prompt(
8093
'Merge proposal branch into staging branch?');
@@ -142,7 +155,7 @@ class ReleasePromotion {
142155
const checker = new PRChecker(cli, data, { prid, owner, repo });
143156
const jenkinsReady = checker.checkJenkinsCI();
144157
const githubCIReady = checker.checkGitHubCI();
145-
const isApproved = checker.checkReviewsAndWait(false /* checkComments */);
158+
const isApproved = checker.checkReviewsAndWait(new Date(), false);
146159

147160
return {
148161
jenkinsReady,
@@ -160,7 +173,7 @@ class ReleasePromotion {
160173
const components = releaseCommitMessage.split(' ');
161174

162175
// Parse out release date.
163-
if (!/\d{4}-\d{2}-\d{2}/.match(components[0])) {
176+
if (!components[0].match(/\d{4}-\d{2}-\d{2}/)) {
164177
cli.error(`Release commit contains invalid date: ${components[0]}`);
165178
return;
166179
}

0 commit comments

Comments
 (0)