Skip to content
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

fix(prlint): a review label doesn't appear when a PR is approved if there are too many comments #31290

Merged
merged 7 commits into from
Sep 3, 2024

Conversation

go-to-k
Copy link
Contributor

@go-to-k go-to-k commented Sep 2, 2024

Issue # (if applicable)

Closes #31294 .

Reason for this change

I've reviewed and approved this PR as a Trusted Community Reviewer.

But it doesn't get the pr/needs-maintainer-review label. It seems to be in CHANGES_REQUESTED state and communityApproved is also false in the job PR Linter / validate-pr. (Please see this comment in the PR.)

I checked the prlint's log in the GitHub Actions output, and it appears that there is too much history (such as comments) to get all the latest data.

List reviews for a pull request in GitHub API can get 30 items per page, however, prlint is not implemented to handle pagination.

  private async assessNeedsReview(
    pr: Pick<GitHubPr, 'mergeable_state' | 'draft' | 'labels' | 'number'>,
  ): Promise<void> {
    const reviews = await this.client.pulls.listReviews(this.prParams);

Therefore, when there are more than 30 comments or change requests, the review label is no longer displayed.

Description of changes

Use pagination for listReviews in the octokit library.

https://github.com/octokit/octokit.js?tab=readme-ov-file#pagination

before

await this.client.pulls.listReviews(this.prParams);

after

await this.client.paginate(this.client.pulls.listReviews, this.prParams);

Description of how you validated changes

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation aws-cdk-automation requested a review from a team September 2, 2024 17:45
@github-actions github-actions bot added distinguished-contributor [Pilot] contributed 50+ PRs to the CDK p2 labels Sep 2, 2024
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@go-to-k go-to-k changed the title fix(prlint): review labels don't appear when a PR is approved if there are too many comments fix(prlint): a review label doesn't appear when a PR is approved if there are too many comments Sep 3, 2024
@github-actions github-actions bot added the bug This issue is a bug. label Sep 3, 2024
@go-to-k
Copy link
Contributor Author

go-to-k commented Sep 3, 2024

Exemption Request:

This PR only changes the call handling regarding the external API (GitHub API via octokit), and the handling is mocked in unit tests. So I can't test in the unit tests. The no regression is confirmed by the fact that existing tests pass.

https://github.com/aws/aws-cdk/blob/v2.155.0/tools/%40aws-cdk/prlint/test/lint.test.ts#L7-L9

https://github.com/aws/aws-cdk/blob/v2.155.0/tools/%40aws-cdk/prlint/test/lint.test.ts#L1207

It also appears that a PR that have introduced pagination in prlint in the past have not added testing in the same way.

@aws-cdk-automation aws-cdk-automation added the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label Sep 3, 2024
@go-to-k go-to-k marked this pull request as ready for review September 3, 2024 06:52
@@ -373,17 +373,17 @@ export class PullRequestLinter {
private async assessNeedsReview(
pr: Pick<GitHubPr, 'mergeable_state' | 'draft' | 'labels' | 'number'>,
): Promise<void> {
const reviews = await this.client.pulls.listReviews(this.prParams);
console.log(JSON.stringify(reviews.data));
const reviewsData = await this.client.paginate(this.client.pulls.listReviews, this.prParams);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Sep 3, 2024
@kaizencc kaizencc added pr-linter/exempt-test The PR linter will not require test changes pr-linter/exempt-integ-test The PR linter will not require integ test changes and removed pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. labels Sep 3, 2024
@aws-cdk-automation aws-cdk-automation dismissed their stale review September 3, 2024 18:21

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

Copy link
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @go-to-k!

Copy link
Contributor

mergify bot commented Sep 3, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Sep 3, 2024
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 5d99b88
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 1c63070 into aws:main Sep 3, 2024
12 checks passed
Copy link
Contributor

mergify bot commented Sep 3, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

Copy link

github-actions bot commented Sep 3, 2024

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 3, 2024
@go-to-k go-to-k deleted the prlint-pagination branch September 4, 2024 02:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. distinguished-contributor [Pilot] contributed 50+ PRs to the CDK p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exempt-test The PR linter will not require test changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

prlint: a review label doesn't appear when a PR is approved if there are too many comments
3 participants