Skip to content

Commit

Permalink
Remove page === 10 and try fetching all pages for Workflow runs
Browse files Browse the repository at this point in the history
  • Loading branch information
yykamei committed Apr 9, 2024
1 parent 35ef43f commit ca5eb03
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29376,7 +29376,7 @@ class GitHubAPIClient {
let page = 1;
let link = "";
let runs = [];
while (page === 1 || (page <= 10 && link.includes(GITHUB_LINK_REL_REXT))) {
while (page === 1 || link.includes(GITHUB_LINK_REL_REXT)) {
(0,core.debug)(`Fetching runs page ${page}`);
const response = await this.client.request("GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs", {
owner,
Expand Down
2 changes: 1 addition & 1 deletion src/GitHubAPIClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class GitHubAPIClient implements APIClient {
let page = 1;
let link = "";
let runs: GitHubWorkflowRun[] = [];
while (page === 1 || (page <= 10 && link.includes(GITHUB_LINK_REL_REXT))) {
while (page === 1 || link.includes(GITHUB_LINK_REL_REXT)) {
debug(`Fetching runs page ${page}`);
const response = await this.client.request(
"GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs",
Expand Down
8 changes: 4 additions & 4 deletions tests/GitHubAPIClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,17 @@ describe("GitHubAPIClient.getWorkflowRuns()", () => {
},
],
},
headers: { link: 'rel="next"' },
headers: { link: id !== 15 ? 'rel="next"' : "" },
url: "https://example.com",
status: 200,
});
}

const runs = await client.getWorkflowRuns("yykamei", "test-repo", 34);
expect(spy).toHaveBeenCalledTimes(10);
expect(runs.length).toEqual(10);
expect(spy).toHaveBeenCalledTimes(12);
expect(runs.length).toEqual(12);
expect(runs.map((r) => r.parameters.id)).toEqual([
4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
]);
});
});
Expand Down

0 comments on commit ca5eb03

Please sign in to comment.