Skip to content

Commit

Permalink
Split out promotion verification steps
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Apr 9, 2020
1 parent 7fcc66a commit 0666c26
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions lib/promote_release.js
Expand Up @@ -25,42 +25,55 @@ class ReleasePromotion {
}

async promote() {
const { version, prid, cli } = this;

// In the promotion stage, we can pull most relevant data
// from the release commit created in the preparation stage.
await this.parseDataFromReleaseCommit();

const { prid, cli, version } = this;

// Verify that PR is ready to promote.
cli.startSpinner('Verifying PR promotion readiness');
const {
jenkinsReady,
githubCIReady,
isApproved
} = await this.verifyPRAttributes();

cli.startSpinner('Verifying Jenkins CI status');
if (!jenkinsReady) {
cli.stopSpinner(`Jenkins CI is failing for #${prid}`);
cli.stopSpinner(
`Jenkins CI is failing for #${prid}`, cli.SPINNER_STATUS.FAILED);
const proceed = await cli.prompt('Do you want to proceed?');
if (!proceed) {
cli.warn(`Aborting release promotion for version ${version}`);
return;
}
} else if (!githubCIReady) {
cli.stopSpinner(`GitHub CI is failing for #${prid}`);
}
cli.stopSpinner('Jenkins CI is passing');

cli.startSpinner('Verifying GitHub CI status');
if (!githubCIReady) {
cli.stopSpinner(
`GitHub CI is failing for #${prid}`, cli.SPINNER_STATUS.FAILED);
const proceed = await cli.prompt('Do you want to proceed?');
if (!proceed) {
cli.warn(`Aborting release promotion for version ${version}`);
return;
}
} else if (!isApproved) {
cli.stopSpinner(`#${prid} does not have sufficient approvals`);
}
cli.stopSpinner('GitHub CI is passing');

cli.startSpinner('Verifying PR approval status');
if (!isApproved) {
cli.stopSpinner(
`#${prid} does not have sufficient approvals`,
cli.SPINNER_STATUS.FAILED);
const proceed = await cli.prompt('Do you want to proceed?');
if (!proceed) {
cli.warn(`Aborting release promotion for version ${version}`);
return;
}
}
cli.stopSpinner(`The release PR for ${version} is ready to promote!`);
cli.stopSpinner(`#${prid} has necessary approvals`);

// Create and sign the release tag.
const shouldTagAndSignRelease = await cli.prompt(
Expand All @@ -74,7 +87,7 @@ class ReleasePromotion {
// Set up for next release.
cli.startSpinner('Setting up for next release');
await this.setupForNextRelease();
cli.startSpinner('Successfully set up for next release');
cli.stopSpinner('Successfully set up for next release');

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

return {
jenkinsReady,
Expand All @@ -160,7 +173,7 @@ class ReleasePromotion {
const components = releaseCommitMessage.split(' ');

// Parse out release date.
if (!/\d{4}-\d{2}-\d{2}/.match(components[0])) {
if (!components[0].match(/\d{4}-\d{2}-\d{2}/)) {
cli.error(`Release commit contains invalid date: ${components[0]}`);
return;
}
Expand Down

0 comments on commit 0666c26

Please sign in to comment.