refactor(dev-infra): provide entire pull request object to waitForPullRequestToBeMerged (#42871)

`waitForPullRequestToBeMerged` should get the entire `PullRequest` object rather than
just the id to allow it to have more information/context for logging and messaging.

PR Close #42871
This commit is contained in:
Joey Perrott 2021-07-15 16:26:26 -07:00 committed by Alex Rickabaugh
parent 53279262be
commit 89509dffd2
8 changed files with 33 additions and 33 deletions

View File

@ -6615,7 +6615,7 @@ class ReleaseAction {
* API is 10 seconds (to not exceed any rate limits). If the pull request is closed without
* merge, the script will abort gracefully (considering a manual user abort).
*/
waitForPullRequestToBeMerged(id, interval = waitForPullRequestInterval) {
waitForPullRequestToBeMerged({ id }, interval = waitForPullRequestInterval) {
return tslib.__awaiter(this, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
debug(`Waiting for pull request #${id} to be merged.`);
@ -6714,13 +6714,13 @@ class ReleaseAction {
yield this.createCommit(commitMessage, [changelogPath]);
info(green(` ✓ Created changelog cherry-pick commit for: "${releaseNotes.version}".`));
// Create a cherry-pick pull request that should be merged by the caretaker.
const { url, id } = yield this.pushChangesToForkAndCreatePullRequest(nextBranch, `changelog-cherry-pick-${releaseNotes.version}`, commitMessage, `Cherry-picks the changelog from the "${stagingBranch}" branch to the next ` +
const pullRequest = yield this.pushChangesToForkAndCreatePullRequest(nextBranch, `changelog-cherry-pick-${releaseNotes.version}`, commitMessage, `Cherry-picks the changelog from the "${stagingBranch}" branch to the next ` +
`branch (${nextBranch}).`);
info(green(` ✓ Pull request for cherry-picking the changelog into "${nextBranch}" ` +
'has been created.'));
info(yellow(` Please ask team members to review: ${url}.`));
info(yellow(` Please ask team members to review: ${pullRequest.url}.`));
// Wait for the Pull Request to be merged.
yield this.waitForPullRequestToBeMerged(id);
yield this.waitForPullRequestToBeMerged(pullRequest);
return true;
});
}
@ -6841,8 +6841,8 @@ class CutLongTermSupportPatchAction extends ReleaseAction {
return tslib.__awaiter(this, void 0, void 0, function* () {
const ltsBranch = yield this._promptForTargetLtsBranch();
const newVersion = semverInc(ltsBranch.version, 'patch');
const { pullRequest: { id }, releaseNotes } = yield this.checkoutBranchAndStageVersion(newVersion, ltsBranch.name);
yield this.waitForPullRequestToBeMerged(id);
const { pullRequest, releaseNotes } = yield this.checkoutBranchAndStageVersion(newVersion, ltsBranch.name);
yield this.waitForPullRequestToBeMerged(pullRequest);
yield this.buildAndPublish(releaseNotes, ltsBranch.name, ltsBranch.npmDistTag);
yield this.cherryPickChangelogIntoNextBranch(releaseNotes, ltsBranch.name);
});
@ -6918,8 +6918,8 @@ class CutNewPatchAction extends ReleaseAction {
return tslib.__awaiter(this, void 0, void 0, function* () {
const { branchName } = this.active.latest;
const newVersion = this._newVersion;
const { pullRequest: { id }, releaseNotes } = yield this.checkoutBranchAndStageVersion(newVersion, branchName);
yield this.waitForPullRequestToBeMerged(id);
const { pullRequest, releaseNotes } = yield this.checkoutBranchAndStageVersion(newVersion, branchName);
yield this.waitForPullRequestToBeMerged(pullRequest);
yield this.buildAndPublish(releaseNotes, branchName, 'latest');
yield this.cherryPickChangelogIntoNextBranch(releaseNotes, branchName);
});
@ -6988,8 +6988,8 @@ class CutNextPrereleaseAction extends ReleaseAction {
const releaseTrain = this._getActivePrereleaseTrain();
const { branchName } = releaseTrain;
const newVersion = yield this._newVersion;
const { pullRequest: { id }, releaseNotes } = yield this.checkoutBranchAndStageVersion(newVersion, branchName);
yield this.waitForPullRequestToBeMerged(id);
const { pullRequest, releaseNotes } = yield this.checkoutBranchAndStageVersion(newVersion, branchName);
yield this.waitForPullRequestToBeMerged(pullRequest);
yield this.buildAndPublish(releaseNotes, branchName, 'next');
// If the pre-release has been cut from a branch that is not corresponding
// to the next release-train, cherry-pick the changelog into the primary
@ -7055,8 +7055,8 @@ class CutReleaseCandidateAction extends ReleaseAction {
return tslib.__awaiter(this, void 0, void 0, function* () {
const { branchName } = this.active.releaseCandidate;
const newVersion = this._newVersion;
const { pullRequest: { id }, releaseNotes } = yield this.checkoutBranchAndStageVersion(newVersion, branchName);
yield this.waitForPullRequestToBeMerged(id);
const { pullRequest, releaseNotes } = yield this.checkoutBranchAndStageVersion(newVersion, branchName);
yield this.waitForPullRequestToBeMerged(pullRequest);
yield this.buildAndPublish(releaseNotes, branchName, 'next');
yield this.cherryPickChangelogIntoNextBranch(releaseNotes, branchName);
});
@ -7099,8 +7099,8 @@ class CutStableAction extends ReleaseAction {
const { branchName } = this.active.releaseCandidate;
const newVersion = this._newVersion;
const isNewMajor = (_a = this.active.releaseCandidate) === null || _a === void 0 ? void 0 : _a.isMajor;
const { pullRequest: { id }, releaseNotes } = yield this.checkoutBranchAndStageVersion(newVersion, branchName);
yield this.waitForPullRequestToBeMerged(id);
const { pullRequest, releaseNotes } = yield this.checkoutBranchAndStageVersion(newVersion, branchName);
yield this.waitForPullRequestToBeMerged(pullRequest);
// If a new major version is published, we publish to the `next` NPM dist tag temporarily.
// We do this because for major versions, we want all main Angular projects to have their
// new major become available at the same time. Publishing immediately to the `latest` NPM
@ -7179,11 +7179,11 @@ class MoveNextIntoFeatureFreezeAction extends ReleaseAction {
// Stage the new version for the newly created branch, and push changes to a
// fork in order to create a staging pull request. Note that we re-use the newly
// created branch instead of re-fetching from the upstream.
const { pullRequest: { id }, releaseNotes } = yield this.stageVersionForBranchAndCreatePullRequest(newVersion, newBranch);
const { pullRequest, releaseNotes } = yield this.stageVersionForBranchAndCreatePullRequest(newVersion, newBranch);
// Wait for the staging PR to be merged. Then build and publish the feature-freeze next
// pre-release. Finally, cherry-pick the release notes into the next branch in combination
// with bumping the version to the next minor too.
yield this.waitForPullRequestToBeMerged(id);
yield this.waitForPullRequestToBeMerged(pullRequest);
yield this.buildAndPublish(releaseNotes, newBranch, 'next');
yield this._createNextBranchUpdatePullRequest(releaseNotes, newVersion);
});

View File

@ -291,8 +291,8 @@ export abstract class ReleaseAction {
* API is 10 seconds (to not exceed any rate limits). If the pull request is closed without
* merge, the script will abort gracefully (considering a manual user abort).
*/
protected async waitForPullRequestToBeMerged(id: number, interval = waitForPullRequestInterval):
Promise<void> {
protected async waitForPullRequestToBeMerged(
{id}: PullRequest, interval = waitForPullRequestInterval): Promise<void> {
return new Promise((resolve, reject) => {
debug(`Waiting for pull request #${id} to be merged.`);
@ -399,7 +399,7 @@ export abstract class ReleaseAction {
info(green(` ✓ Created changelog cherry-pick commit for: "${releaseNotes.version}".`));
// Create a cherry-pick pull request that should be merged by the caretaker.
const {url, id} = await this.pushChangesToForkAndCreatePullRequest(
const pullRequest = await this.pushChangesToForkAndCreatePullRequest(
nextBranch, `changelog-cherry-pick-${releaseNotes.version}`, commitMessage,
`Cherry-picks the changelog from the "${stagingBranch}" branch to the next ` +
`branch (${nextBranch}).`);
@ -407,10 +407,10 @@ export abstract class ReleaseAction {
info(green(
` ✓ Pull request for cherry-picking the changelog into "${nextBranch}" ` +
'has been created.'));
info(yellow(` Please ask team members to review: ${url}.`));
info(yellow(` Please ask team members to review: ${pullRequest.url}.`));
// Wait for the Pull Request to be merged.
await this.waitForPullRequestToBeMerged(id);
await this.waitForPullRequestToBeMerged(pullRequest);
return true;
}

View File

@ -30,10 +30,10 @@ export class CutLongTermSupportPatchAction extends ReleaseAction {
override async perform() {
const ltsBranch = await this._promptForTargetLtsBranch();
const newVersion = semverInc(ltsBranch.version, 'patch');
const {pullRequest: {id}, releaseNotes} =
const {pullRequest, releaseNotes} =
await this.checkoutBranchAndStageVersion(newVersion, ltsBranch.name);
await this.waitForPullRequestToBeMerged(id);
await this.waitForPullRequestToBeMerged(pullRequest);
await this.buildAndPublish(releaseNotes, ltsBranch.name, ltsBranch.npmDistTag);
await this.cherryPickChangelogIntoNextBranch(releaseNotes, ltsBranch.name);
}

View File

@ -28,10 +28,10 @@ export class CutNewPatchAction extends ReleaseAction {
const {branchName} = this.active.latest;
const newVersion = this._newVersion;
const {pullRequest: {id}, releaseNotes} =
const {pullRequest, releaseNotes} =
await this.checkoutBranchAndStageVersion(newVersion, branchName);
await this.waitForPullRequestToBeMerged(id);
await this.waitForPullRequestToBeMerged(pullRequest);
await this.buildAndPublish(releaseNotes, branchName, 'latest');
await this.cherryPickChangelogIntoNextBranch(releaseNotes, branchName);
}

View File

@ -32,10 +32,10 @@ export class CutNextPrereleaseAction extends ReleaseAction {
const {branchName} = releaseTrain;
const newVersion = await this._newVersion;
const {pullRequest: {id}, releaseNotes} =
const {pullRequest, releaseNotes} =
await this.checkoutBranchAndStageVersion(newVersion, branchName);
await this.waitForPullRequestToBeMerged(id);
await this.waitForPullRequestToBeMerged(pullRequest);
await this.buildAndPublish(releaseNotes, branchName, 'next');
// If the pre-release has been cut from a branch that is not corresponding

View File

@ -26,10 +26,10 @@ export class CutReleaseCandidateAction extends ReleaseAction {
const {branchName} = this.active.releaseCandidate!;
const newVersion = this._newVersion;
const {pullRequest: {id}, releaseNotes} =
const {pullRequest, releaseNotes} =
await this.checkoutBranchAndStageVersion(newVersion, branchName);
await this.waitForPullRequestToBeMerged(id);
await this.waitForPullRequestToBeMerged(pullRequest);
await this.buildAndPublish(releaseNotes, branchName, 'next');
await this.cherryPickChangelogIntoNextBranch(releaseNotes, branchName);
}

View File

@ -30,10 +30,10 @@ export class CutStableAction extends ReleaseAction {
const newVersion = this._newVersion;
const isNewMajor = this.active.releaseCandidate?.isMajor;
const {pullRequest: {id}, releaseNotes} =
const {pullRequest, releaseNotes} =
await this.checkoutBranchAndStageVersion(newVersion, branchName);
await this.waitForPullRequestToBeMerged(id);
await this.waitForPullRequestToBeMerged(pullRequest);
// If a new major version is published, we publish to the `next` NPM dist tag temporarily.
// We do this because for major versions, we want all main Angular projects to have their

View File

@ -40,13 +40,13 @@ export class MoveNextIntoFeatureFreezeAction extends ReleaseAction {
// Stage the new version for the newly created branch, and push changes to a
// fork in order to create a staging pull request. Note that we re-use the newly
// created branch instead of re-fetching from the upstream.
const {pullRequest: {id}, releaseNotes} =
const {pullRequest, releaseNotes} =
await this.stageVersionForBranchAndCreatePullRequest(newVersion, newBranch);
// Wait for the staging PR to be merged. Then build and publish the feature-freeze next
// pre-release. Finally, cherry-pick the release notes into the next branch in combination
// with bumping the version to the next minor too.
await this.waitForPullRequestToBeMerged(id);
await this.waitForPullRequestToBeMerged(pullRequest);
await this.buildAndPublish(releaseNotes, newBranch, 'next');
await this._createNextBranchUpdatePullRequest(releaseNotes, newVersion);
}