-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: re-organize PR linter (#32969)
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*
- Loading branch information
Showing
9 changed files
with
823 additions
and
582 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
.github/workflows/pr-linter-trigger.yml → ...ub/workflows/pr-linter-review-trigger.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
export const DEFEAULT_LINTER_LOGIN = 'aws-cdk-automation'; | ||
|
||
export const CODE_BUILD_CONTEXT = 'AWS CodeBuild us-east-1 (AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv)'; | ||
|
||
/** | ||
* Types of exemption labels in aws-cdk project. | ||
*/ | ||
export enum Exemption { | ||
README = 'pr-linter/exempt-readme', | ||
TEST = 'pr-linter/exempt-test', | ||
INTEG_TEST = 'pr-linter/exempt-integ-test', | ||
BREAKING_CHANGE = 'pr-linter/exempt-breaking-change', | ||
CLI_INTEG_TESTED = 'pr-linter/cli-integ-tested', | ||
REQUEST_CLARIFICATION = 'pr/reviewer-clarification-requested', | ||
REQUEST_EXEMPTION = 'pr-linter/exemption-requested', | ||
CODECOV = "pr-linter/exempt-codecov", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Endpoints } from '@octokit/types'; | ||
import { StatusEvent } from '@octokit/webhooks-definitions/schema'; | ||
|
||
export type GitHubPr = | ||
Endpoints['GET /repos/{owner}/{repo}/pulls/{pull_number}']['response']['data']; | ||
|
||
|
||
export interface GitHubComment { | ||
id: number; | ||
} | ||
|
||
export interface Review { | ||
id: number; | ||
user: { | ||
login: string; | ||
} | null; | ||
body: string; | ||
state: string; | ||
} | ||
|
||
export interface GithubStatusEvent { | ||
readonly sha: string; | ||
readonly state?: StatusEvent['state']; | ||
readonly context?: string; | ||
} | ||
|
||
export interface GitHubLabel { | ||
readonly name: string; | ||
} | ||
|
||
export interface GitHubFile { | ||
readonly filename: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.