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

refactor: re-organize PR linter #32969

Merged
merged 18 commits into from
Jan 17, 2025
Merged

refactor: re-organize PR linter #32969

merged 18 commits into from
Jan 17, 2025

Conversation

rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Jan 16, 2025

The PR linter code was a bit of a mess; evaluating rules and mutating the PR was interspersed, generic GitHub code was mixed with CDK-specific code, the linter could be triggered from multiple sources, none of them were documented very well.

Try to rectify all of that in this PR to make it easier to extend the PR linter in the future:

  • Split the linter into clear evaluate/act responsibilities.
  • Split code across more than 1 file.
  • Document how the "PR Linter Trigger" works
  • Streamline how we get a PR number into the linter.
  • Give an example of how to run it locally to test the rule evaluation on real PRs

Not every crazy design decision has been rectified yet, but at least we have a start of something a little more comprehensible. Another change I made: the old PR linter creates a comment + a review with the same content (but not quite). In this PR, make it just do reviews and don't do comments.

This started from a PR that had CodeCov changes added, but I want to do a refactor without feature changes first before adding new code.


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 January 16, 2025 12:00
@github-actions github-actions bot added the p2 label Jan 16, 2025
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jan 16, 2025
Copy link

codecov bot commented Jan 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.48%. Comparing base (74bd8ce) to head (935a77b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #32969   +/-   ##
=======================================
  Coverage   81.48%   81.48%           
=======================================
  Files         226      226           
  Lines       13768    13768           
  Branches     2416     2416           
=======================================
  Hits        11219    11219           
  Misses       2271     2271           
  Partials      278      278           
Flag Coverage Δ
suite.unit 81.48% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
packages/aws-cdk 80.89% <ø> (ø)
packages/aws-cdk-lib/core 82.10% <ø> (ø)

@rix0rrr rix0rrr changed the title chore: refactor PR linter refactor: re-organize PR linter Jan 16, 2025
@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 16, 2025
tools/@aws-cdk/prlint/constants.ts Outdated Show resolved Hide resolved
tools/@aws-cdk/prlint/github.ts Outdated Show resolved Hide resolved
tools/@aws-cdk/prlint/index.ts Outdated Show resolved Hide resolved
* For code that requires an exception
*/
public actionsToException(actions: LinterActions) {
if (actions.requestChanges) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this always the logic? only fail the linter if it requests changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.

@rix0rrr rix0rrr added the pr/do-not-merge This PR should not be merged at this time. label Jan 16, 2025
Copy link
Contributor

@mrgrain mrgrain left a comment

Choose a reason for hiding this comment

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

I trust you to fix problems

@rix0rrr rix0rrr removed the pr/do-not-merge This PR should not be merged at this time. label Jan 17, 2025
@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 17, 2025
Copy link
Contributor

mergify bot commented Jan 17, 2025

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
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

Copy link
Contributor

mergify bot commented Jan 17, 2025

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).

@mergify mergify bot merged commit 680b6ba into main Jan 17, 2025
19 checks passed
@mergify mergify bot deleted the huijbers/refactor-prlinter branch January 17, 2025 10:37
Copy link

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 Jan 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
contribution/core This is a PR that came from AWS. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants