build: print url to commits if staging script fails due to failing status (#14509)

* Based on a recent chat with Miles, it would be good if we default the `Is pre-release?` question to `false` and also print an URL if the status checks for a given branch fail (this should be just more convenient to see what failed)
This commit is contained in:
Paul Gschwendtner
2018-12-14 01:53:46 +01:00
committed by vivian-hu
parent c460728225
commit f59c1ee9bc
3 changed files with 12 additions and 2 deletions
+4
View File
@@ -0,0 +1,4 @@
/** Gets a Github URL that refers to a lists of recent commits within a specified branch. */
export function getGithubBranchCommitsUrl(owner: string, repository: string, branchName: string) {
return `https://github.com/${owner}/${repository}/commits/${branchName}`;
}
@@ -50,6 +50,7 @@ export async function promptForNewVersion(currentVersion: Version): Promise<Vers
message: 'Should this be a pre-release?',
// Prompt whether this should a pre-release if the current release is not a pre-release
when: !currentVersion.prereleaseLabel,
default: false,
}, {
type: 'list',
name: 'prereleaseLabel',
+7 -2
View File
@@ -5,6 +5,7 @@ import {prompt} from 'inquirer';
import {join} from 'path';
import {promptAndGenerateChangelog} from './changelog';
import {GitClient} from './git/git-client';
import {getGithubBranchCommitsUrl} from './git/github-urls';
import {promptForNewVersion} from './prompt/new-version-prompt';
import {parseVersionName, Version} from './version-name/parse-version';
import {getExpectedPublishBranch} from './version-name/publish-branch';
@@ -93,7 +94,7 @@ class StageReleaseTask {
this.switchToPublishBranch(expectedPublishBranch);
this.verifyLocalCommitsMatchUpstream(expectedPublishBranch);
await this.verifyPassingGithubStatus();
await this.verifyPassingGithubStatus(expectedPublishBranch);
const newVersionName = newVersion.format();
const stagingBranch = `release-stage/${newVersionName}`;
@@ -195,8 +196,10 @@ class StageReleaseTask {
}
/** Verifies that the latest commit of the current branch is passing all Github statuses. */
private async verifyPassingGithubStatus() {
private async verifyPassingGithubStatus(expectedPublishBranch: string) {
const commitRef = this.git.getLocalCommitSha('HEAD');
const githubCommitsUrl = getGithubBranchCommitsUrl(this.repositoryOwner, this.repositoryName,
expectedPublishBranch);
const {state} = (await this.githubApi.repos.getCombinedStatusForRef({
owner: this.repositoryOwner,
repo: this.repositoryName,
@@ -206,10 +209,12 @@ class StageReleaseTask {
if (state === 'failure') {
console.error(red(` ✘ Cannot stage release. Commit "${commitRef}" does not pass all ` +
`github status checks. Please make sure this commit passes all checks before re-running.`));
console.error(red(` Please have a look at: ${githubCommitsUrl}`));
process.exit(1);
} else if (state === 'pending') {
console.error(red(` ✘ Cannot stage release yet. Commit "${commitRef}" still has ` +
`pending github statuses that need to succeed before staging a release.`));
console.error(red(` Please have a look at: ${githubCommitsUrl}`));
process.exit(0);
}