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

chore(pr-lint): provide output to user in comments #22029

Merged
merged 25 commits into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
24cb7e7
chore(pr-linter): provide output to user in comments
TheRealAmazonKendra Sep 14, 2022
f7961f8
update to node16
TheRealAmazonKendra Sep 14, 2022
321334f
probably still fails
TheRealAmazonKendra Sep 14, 2022
bba1bbe
env in maybe in right place now
TheRealAmazonKendra Sep 14, 2022
d086fcf
yolo
TheRealAmazonKendra Sep 14, 2022
d8d13d8
maybe this time?
TheRealAmazonKendra Sep 14, 2022
3ffec41
update dependencies for github actions
TheRealAmazonKendra Sep 14, 2022
1fa454b
Revert "update dependencies for github actions"
TheRealAmazonKendra Sep 14, 2022
eb04078
Merge branch 'main' into TheRealAmazonKendra/pr-linter
mergify[bot] Sep 14, 2022
dddddda
update github dependencies
TheRealAmazonKendra Sep 14, 2022
a47f0ce
only environment variable needed
TheRealAmazonKendra Sep 15, 2022
001584b
update documentation
TheRealAmazonKendra Sep 15, 2022
04b987f
list all failures
TheRealAmazonKendra Sep 17, 2022
960b19e
output test
TheRealAmazonKendra Sep 17, 2022
99da1c8
another output test
TheRealAmazonKendra Sep 17, 2022
90c9b8a
switch token
TheRealAmazonKendra Sep 17, 2022
4f0be4e
please dismiss old reviews?
TheRealAmazonKendra Sep 17, 2022
7bb4a07
clean up after yourself
TheRealAmazonKendra Sep 17, 2022
5be6acd
nope, that was bad
TheRealAmazonKendra Sep 17, 2022
e322728
remove commented out lines
TheRealAmazonKendra Sep 17, 2022
b82dcaa
updates from feedback and refactoring
TheRealAmazonKendra Sep 19, 2022
a8ab4af
Merge branch 'main' into TheRealAmazonKendra/pr-linter
Naumel Sep 20, 2022
784fee5
Merge branch 'main' into TheRealAmazonKendra/pr-linter
mergify[bot] Sep 20, 2022
9d984ae
Fixing the merge conflict commit.
Naumel Sep 20, 2022
d30f514
Merge branch 'main' into TheRealAmazonKendra/pr-linter
mergify[bot] Sep 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pr-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
validate-pr:
permissions:
contents: read
pull-requests: read
pull-requests: write
runs-on: ubuntu-latest
steps:

Expand All @@ -29,5 +29,5 @@ jobs:
- name: Validate
uses: ./tools/@aws-cdk/prlint
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.PROJEN_GITHUB_TOKEN }}
REPO_ROOT: ${{ github.workspace }}
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@ Integration tests perform a few functions in the CDK code base -

The following list contains common scenarios where we _know_ that integration tests are required.
This is not an exhaustive list and we will, by default, require integration tests for all
new features unless there is a good reason why one is not needed.
new features and all fixes unless there is a good reason why one is not needed.

1. Adding a new feature that is using previously unused CloudFormation resource types
2. Adding a new feature that is using previously unused (or untested) CloudFormation properties
1. Adding a new feature
2. Adding a fix to an existing feature
3. Involves configuring resource types across services (i.e. integrations)
4. Adding a new supported version (e.g. a new [AuroraMysqlEngineVersion](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_rds.AuroraMysqlEngineVersion.html))
5. Adding any functionality via a [Custom Resource](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.custom_resources-readme.html)
Expand Down
23 changes: 2 additions & 21 deletions tools/@aws-cdk/prlint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ A Github action that checks pull requests around PR titles, description and othe
This check validates that the modified files in the PR follow these rules:

1. `feat` requires a change to a `README.md`.
2. `feat` requires a change to a test file.
3. `fix` requires a change to a test file.
2. `feat` requires a change to a unit test file and integration test files.
3. `fix` requires a change to a unit test file and integration test files.
4. `BREAKING CHANGE` section is formatted correctly, per the [conventional commits] spec.
5. No breaking changes announced for stable modules.

Expand Down Expand Up @@ -42,22 +42,3 @@ steps:
env:
REPO_ROOT: ${{ github.workspace }}
```

# Testing locally

To test the linter against an actual PR locally, run

```console
env REPO_ROOT=/path/to/cdk/repo node lint.js validatePr 5857

Creating un-authenticated GitHub Client
⌛ Fetching PR number 5857
⌛ Fetching files for PR number 5857
⌛ Validating...
Error: Features must contain a change to a README file
at featureContainsReadme (/Users/epolon/dev/src/github.com/aws/aws-cdk/tools/prlint/index.js:43:15)
at Object.mandatoryChanges (/Users/epolon/dev/src/github.com/aws/aws-cdk/tools/prlint/index.js:74:5)
at process._tickCallback (internal/process/next_tick.js:68:7)
```

Note that an **un-authenticated** GitHub client is created, unless you set the `GITHUB_TOKEN` env variable.
4 changes: 2 additions & 2 deletions tools/@aws-cdk/prlint/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Pull Request Linter
description: Execute validation rules on GitHub Pull Requests
runs:
using: node12
main: index.js
using: node16
main: index.js
2 changes: 0 additions & 2 deletions tools/@aws-cdk/prlint/decs.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
declare module 'github-api';

declare module 'conventional-commits-parser' {
function sync(commitMsg: string): Parsed;

Expand Down
22 changes: 13 additions & 9 deletions tools/@aws-cdk/prlint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@ import * as github from '@actions/github';
import * as linter from './lint';

async function run() {
const number = github.context.issue.number;
const token: string = process.env.GITHUB_TOKEN!;
const client = github.getOctokit(token).rest.pulls;

try {

await linter.validatePr(number);

} catch (error) {

core.setFailed(error.message);
}
const prLinter = new linter.PullRequestLinter({
client,
owner: github.context.repo.owner,
repo: github.context.repo.repo,
number: github.context.issue.number,
});

try {
await prLinter.validate()
} catch (error) {
core.setFailed(error.message);
}
}

run()
Loading