From be36d1ee2183be008ed15405f4edd5c4917d4547 Mon Sep 17 00:00:00 2001 From: Casey Lee Date: Wed, 19 Oct 2022 06:13:42 -0700 Subject: [PATCH] chore(prlint): add pagination to listFiles in PR (#22555) 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* --- tools/@aws-cdk/prlint/lint.ts | 2 +- tools/@aws-cdk/prlint/test/lint.test.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/@aws-cdk/prlint/lint.ts b/tools/@aws-cdk/prlint/lint.ts index d4c38e04a4b73..9f7904f4c501f 100644 --- a/tools/@aws-cdk/prlint/lint.ts +++ b/tools/@aws-cdk/prlint/lint.ts @@ -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..."); diff --git a/tools/@aws-cdk/prlint/test/lint.test.ts b/tools/@aws-cdk/prlint/test/lint.test.ts index 9a22289c7589d..ca417917af878 100644 --- a/tools/@aws-cdk/prlint/test/lint.test.ts +++ b/tools/@aws-cdk/prlint/test/lint.test.ts @@ -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, }) }