From 7b4de34ffaad13ff5c25cd3fdb50e7fca2867819 Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Tue, 3 Sep 2024 02:41:48 +0900 Subject: [PATCH 1/6] wip --- tools/@aws-cdk/prlint/lint.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tools/@aws-cdk/prlint/lint.ts b/tools/@aws-cdk/prlint/lint.ts index 9097dd5516a4c..553fb5a4137b5 100644 --- a/tools/@aws-cdk/prlint/lint.ts +++ b/tools/@aws-cdk/prlint/lint.ts @@ -373,17 +373,23 @@ export class PullRequestLinter { private async assessNeedsReview( pr: Pick, ): Promise { - const reviews = await this.client.pulls.listReviews(this.prParams); - console.log(JSON.stringify(reviews.data)); + // TODO: remove the following comment outs + // const iterator = this.client.paginate.iterator(this.client.pulls.listReviews, this.prParams); + // for await (const { data: reviews } of iterator) { + // console.log('reviews: ', JSON.stringify(reviews)); + // } + // TODO: tests + const reviewsData = await this.client.paginate(this.client.pulls.listReviews, this.prParams); + console.log(JSON.stringify(reviewsData)); // NOTE: MEMBER = a member of the organization that owns the repository // COLLABORATOR = has been invited to collaborate on the repository - const maintainerRequestedChanges = reviews.data.some( + const maintainerRequestedChanges = reviewsData.some( review => review.author_association === 'MEMBER' && review.user?.login !== 'aws-cdk-automation' && review.state === 'CHANGES_REQUESTED', ); - const maintainerApproved = reviews.data.some( + const maintainerApproved = reviewsData.some( review => review.author_association === 'MEMBER' && review.state === 'APPROVED', ); @@ -403,7 +409,7 @@ export class PullRequestLinter { // be dismissed by a maintainer to respect another reviewer's requested changes. // 5. Checking if any reviewers' most recent review requested changes // -> If so, the PR is considered to still need changes to meet community review. - const reviewsByTrustedCommunityMembers = reviews.data + const reviewsByTrustedCommunityMembers = reviewsData .filter(review => this.getTrustedCommunityMembers().includes(review.user?.login ?? '')) .filter(review => review.state !== 'PENDING' && review.state !== 'COMMENTED') .reduce((grouping, review) => { @@ -420,12 +426,12 @@ export class PullRequestLinter { ...grouping, [review.user!.login]: newest, }; - }, {} as Record); + }, {} as Record); console.log('raw data: ', JSON.stringify(reviewsByTrustedCommunityMembers)); const communityApproved = Object.values(reviewsByTrustedCommunityMembers).some(({state}) => state === 'APPROVED'); const communityRequestedChanges = !communityApproved && Object.values(reviewsByTrustedCommunityMembers).some(({state}) => state === 'CHANGES_REQUESTED') - const prLinterFailed = reviews.data.find((review) => review.user?.login === 'aws-cdk-automation' && review.state !== 'DISMISSED') as Review; + const prLinterFailed = reviewsData.find((review) => review.user?.login === 'aws-cdk-automation' && review.state !== 'DISMISSED') as Review; const userRequestsExemption = pr.labels.some(label => (label.name === Exemption.REQUEST_EXEMPTION || label.name === Exemption.REQUEST_CLARIFICATION)); console.log('evaluation: ', JSON.stringify({ draft: pr.draft, From 1f2a37be8169fd1d2e1dd2ba4e48338801fc09be Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Tue, 3 Sep 2024 12:56:52 +0900 Subject: [PATCH 2/6] rm comments --- tools/@aws-cdk/prlint/lint.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tools/@aws-cdk/prlint/lint.ts b/tools/@aws-cdk/prlint/lint.ts index 553fb5a4137b5..0cb1b89621a24 100644 --- a/tools/@aws-cdk/prlint/lint.ts +++ b/tools/@aws-cdk/prlint/lint.ts @@ -373,12 +373,6 @@ export class PullRequestLinter { private async assessNeedsReview( pr: Pick, ): Promise { - // TODO: remove the following comment outs - // const iterator = this.client.paginate.iterator(this.client.pulls.listReviews, this.prParams); - // for await (const { data: reviews } of iterator) { - // console.log('reviews: ', JSON.stringify(reviews)); - // } - // TODO: tests const reviewsData = await this.client.paginate(this.client.pulls.listReviews, this.prParams); console.log(JSON.stringify(reviewsData)); From cd094530054faced9c61796602614842126d9c74 Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Tue, 3 Sep 2024 15:32:28 +0900 Subject: [PATCH 3/6] test debug --- tools/@aws-cdk/prlint/lint.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/@aws-cdk/prlint/lint.ts b/tools/@aws-cdk/prlint/lint.ts index 0cb1b89621a24..3c45d8b30dd8d 100644 --- a/tools/@aws-cdk/prlint/lint.ts +++ b/tools/@aws-cdk/prlint/lint.ts @@ -373,6 +373,7 @@ export class PullRequestLinter { private async assessNeedsReview( pr: Pick, ): Promise { + console.log('==== test debug ===='); const reviewsData = await this.client.paginate(this.client.pulls.listReviews, this.prParams); console.log(JSON.stringify(reviewsData)); From 6c295af85e80f237ea92365c1029051febe35ff3 Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Tue, 3 Sep 2024 15:32:42 +0900 Subject: [PATCH 4/6] Revert "test debug" This reverts commit cd094530054faced9c61796602614842126d9c74. --- tools/@aws-cdk/prlint/lint.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/@aws-cdk/prlint/lint.ts b/tools/@aws-cdk/prlint/lint.ts index 3c45d8b30dd8d..0cb1b89621a24 100644 --- a/tools/@aws-cdk/prlint/lint.ts +++ b/tools/@aws-cdk/prlint/lint.ts @@ -373,7 +373,6 @@ export class PullRequestLinter { private async assessNeedsReview( pr: Pick, ): Promise { - console.log('==== test debug ===='); const reviewsData = await this.client.paginate(this.client.pulls.listReviews, this.prParams); console.log(JSON.stringify(reviewsData)); From 0c5f016772d9f82766338928cb07dec34478cba2 Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Tue, 3 Sep 2024 15:36:32 +0900 Subject: [PATCH 5/6] debug 2 --- tools/@aws-cdk/prlint/lint.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/@aws-cdk/prlint/lint.ts b/tools/@aws-cdk/prlint/lint.ts index 0cb1b89621a24..787ee6ca0ddce 100644 --- a/tools/@aws-cdk/prlint/lint.ts +++ b/tools/@aws-cdk/prlint/lint.ts @@ -584,6 +584,10 @@ export class PullRequestLinter { // also assess whether the PR needs review or not try { const state = await this.codeBuildJobSucceeded(sha); + console.log('=== test debug ==='); + console.log('=== test debug ==='); + console.log('=== test debug ==='); + console.log('=== test debug ==='); console.log(`PR code build job ${state ? "SUCCESSFUL" : "not yet successful"}`); if (state) { console.log('Assessing if the PR needs a review now'); From 6aa7b605fdc139a62f1e2e3ec2ceb9b070e3fadd Mon Sep 17 00:00:00 2001 From: go-to-k <24818752+go-to-k@users.noreply.github.com> Date: Tue, 3 Sep 2024 15:36:41 +0900 Subject: [PATCH 6/6] Revert "debug 2" This reverts commit 0c5f016772d9f82766338928cb07dec34478cba2. --- tools/@aws-cdk/prlint/lint.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tools/@aws-cdk/prlint/lint.ts b/tools/@aws-cdk/prlint/lint.ts index 787ee6ca0ddce..0cb1b89621a24 100644 --- a/tools/@aws-cdk/prlint/lint.ts +++ b/tools/@aws-cdk/prlint/lint.ts @@ -584,10 +584,6 @@ export class PullRequestLinter { // also assess whether the PR needs review or not try { const state = await this.codeBuildJobSucceeded(sha); - console.log('=== test debug ==='); - console.log('=== test debug ==='); - console.log('=== test debug ==='); - console.log('=== test debug ==='); console.log(`PR code build job ${state ? "SUCCESSFUL" : "not yet successful"}`); if (state) { console.log('Assessing if the PR needs a review now');