From 89509dffd26b714ecb774ba1a590661edd59a7ad Mon Sep 17 00:00:00 2001 From: Joey Perrott Date: Thu, 15 Jul 2021 16:26:26 -0700 Subject: [PATCH] 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 --- dev-infra/ng-dev.js | 32 +++++++++---------- dev-infra/release/publish/actions.ts | 10 +++--- .../release/publish/actions/cut-lts-patch.ts | 4 +-- .../release/publish/actions/cut-new-patch.ts | 4 +-- .../publish/actions/cut-next-prerelease.ts | 4 +-- .../publish/actions/cut-release-candidate.ts | 4 +-- .../release/publish/actions/cut-stable.ts | 4 +-- .../actions/move-next-into-feature-freeze.ts | 4 +-- 8 files changed, 33 insertions(+), 33 deletions(-) diff --git a/dev-infra/ng-dev.js b/dev-infra/ng-dev.js index d8d9424b38..cbab138243 100755 --- a/dev-infra/ng-dev.js +++ b/dev-infra/ng-dev.js @@ -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); }); diff --git a/dev-infra/release/publish/actions.ts b/dev-infra/release/publish/actions.ts index 2d94339a25..c33f1950a4 100644 --- a/dev-infra/release/publish/actions.ts +++ b/dev-infra/release/publish/actions.ts @@ -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 { + protected async waitForPullRequestToBeMerged( + {id}: PullRequest, interval = waitForPullRequestInterval): Promise { 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; } diff --git a/dev-infra/release/publish/actions/cut-lts-patch.ts b/dev-infra/release/publish/actions/cut-lts-patch.ts index 52f1ae6ba8..7a5a06f0eb 100644 --- a/dev-infra/release/publish/actions/cut-lts-patch.ts +++ b/dev-infra/release/publish/actions/cut-lts-patch.ts @@ -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); } diff --git a/dev-infra/release/publish/actions/cut-new-patch.ts b/dev-infra/release/publish/actions/cut-new-patch.ts index 0e24e7d94a..5d6957aaa0 100644 --- a/dev-infra/release/publish/actions/cut-new-patch.ts +++ b/dev-infra/release/publish/actions/cut-new-patch.ts @@ -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); } diff --git a/dev-infra/release/publish/actions/cut-next-prerelease.ts b/dev-infra/release/publish/actions/cut-next-prerelease.ts index 7d77ae6a6b..3572b88221 100644 --- a/dev-infra/release/publish/actions/cut-next-prerelease.ts +++ b/dev-infra/release/publish/actions/cut-next-prerelease.ts @@ -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 diff --git a/dev-infra/release/publish/actions/cut-release-candidate.ts b/dev-infra/release/publish/actions/cut-release-candidate.ts index d480c9fa19..ff7a901532 100644 --- a/dev-infra/release/publish/actions/cut-release-candidate.ts +++ b/dev-infra/release/publish/actions/cut-release-candidate.ts @@ -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); } diff --git a/dev-infra/release/publish/actions/cut-stable.ts b/dev-infra/release/publish/actions/cut-stable.ts index 5259f41c0e..7c8747a8db 100644 --- a/dev-infra/release/publish/actions/cut-stable.ts +++ b/dev-infra/release/publish/actions/cut-stable.ts @@ -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 diff --git a/dev-infra/release/publish/actions/move-next-into-feature-freeze.ts b/dev-infra/release/publish/actions/move-next-into-feature-freeze.ts index a4c7f9eaf0..2259cced9e 100644 --- a/dev-infra/release/publish/actions/move-next-into-feature-freeze.ts +++ b/dev-infra/release/publish/actions/move-next-into-feature-freeze.ts @@ -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); }