Skip to content

Commit 7adb09b

Browse files
committed
Fix listing jobs
1 parent b6eaea3 commit 7adb09b

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

lib/github-api-client.ts

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,18 +167,32 @@ export class RealGitHubApiClient {
167167
}
168168

169169
async listJobs(runId: number): Promise<WorkflowJob[]> {
170-
const url =
171-
`https://api.github.com/repos/${OWNER}/${REPO}/actions/runs/${runId}/jobs`;
172-
173-
const response = await this.#fileFetcher.get(url, this.#getHeaders());
170+
const allJobs: WorkflowJob[] = [];
171+
const maxPages = 10;
174172

175-
if (!response.ok) {
176-
throw new Error(
177-
`Failed to list jobs: ${response.status} ${response.statusText}`,
173+
for (let page = 1; page <= maxPages; page++) {
174+
const url = new URL(
175+
`https://api.github.com/repos/${OWNER}/${REPO}/actions/runs/${runId}/jobs`,
178176
);
177+
url.searchParams.set("per_page", "100");
178+
url.searchParams.set("page", page.toString());
179+
180+
const response = await this.#fileFetcher.get(url, this.#getHeaders());
181+
182+
if (!response.ok) {
183+
throw new Error(
184+
`Failed to list jobs: ${response.status} ${response.statusText}`,
185+
);
186+
}
187+
188+
const data: JobsListResponse = await response.json();
189+
allJobs.push(...data.jobs);
190+
191+
if (allJobs.length >= data.total_count) {
192+
break;
193+
}
179194
}
180195

181-
const data: JobsListResponse = await response.json();
182-
return data.jobs;
196+
return allJobs;
183197
}
184198
}

routes/results/[runId].tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,17 @@ export default define.page<typeof handler>(function TestResultsPage({ data }) {
168168
return (
169169
<div class="container mx-auto px-4 py-8 max-w-7xl">
170170
<div class="mb-8">
171-
<h1 class="text-3xl font-bold mb-2">Test Results for Run #{runId}</h1>
171+
<h1 class="text-3xl font-bold mb-2">
172+
Test Results for Run{" "}
173+
<a
174+
href={`https://github.com/denoland/deno/actions/runs/${runId}`}
175+
class="text-blue-600 hover:text-blue-800"
176+
target="_blank"
177+
rel="noopener noreferrer"
178+
>
179+
#{runId}
180+
</a>
181+
</h1>
172182
<div class="text-gray-600 mb-2">
173183
Branch: <span class="font-semibold">{run.head_branch}</span>
174184
</div>

0 commit comments

Comments
 (0)