Skip to content

Commit

Permalink
chore(prlint): add pagination to listFiles in PR (#22555)
Browse files Browse the repository at this point in the history
Currently, the `prlint` tool lists the files on a PR to enforce new integration tests are created for `feat` changes. The tool is not using pagination for list files and is using the default of `30` files per page. This means a PR could be incorrectly flagged for missing integration tests if the test files occur after the first 30 files in the PR.

Example of this can be seen in #22455 

This PR enables pagination on the `listFiles` call to ensure the validation rules are looking at all files in the PR, not just the first 30.

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
cplee authored Oct 19, 2022
1 parent 0d2b529 commit 914185b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tools/@aws-cdk/prlint/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export class PullRequestLinter {
const pr = (await this.client.pulls.get(this.prParams)).data;

console.log(`⌛ Fetching files for PR number ${number}`);
const files = (await this.client.pulls.listFiles(this.prParams)).data;
const files = await this.client.paginate(this.client.pulls.listFiles, this.prParams);

console.log("⌛ Validating...");

Expand Down
1 change: 1 addition & 0 deletions tools/@aws-cdk/prlint/test/lint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ function configureMock(pr: linter.GitHubPr, prFiles?: linter.GitHubFile[]): lint
client: {
pulls: pullsClient as any,
issues: issuesClient as any,
paginate: (method: any, args: any) => { return method(args).data },
} as any,
})
}

0 comments on commit 914185b

Please sign in to comment.