Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tools/release/git/github-urls.ts
Original file line number Diff line number Diff line change
@@ -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}`;
}
1 change: 1 addition & 0 deletions tools/release/prompt/new-version-prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
9 changes: 7 additions & 2 deletions tools/release/stage-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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}`;
Expand Down Expand Up @@ -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,
Expand All @@ -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);
}

Expand Down