Skip to content

Commit 8be50c6

Browse files
committed
fix: handle if runId is 0
1 parent eee3fc2 commit 8be50c6

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

.github/scripts/create-e2e-test-report.ts

+19-16
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,26 @@ async function main() {
3838
const jobsCache: { [runId: number]: Job[] } = {};
3939

4040
async function getJobs(runId: number) {
41-
if (jobsCache[runId]) {
42-
return jobsCache[runId];
43-
}
44-
try {
45-
const jobs = await github.paginate(
46-
github.rest.actions.listJobsForWorkflowRun,
47-
{
48-
owner: env.OWNER,
49-
repo: env.REPOSITORY,
50-
run_id: runId,
51-
per_page: 100,
52-
},
53-
);
54-
jobsCache[runId] = jobs;
55-
return jobsCache[runId];
56-
} catch (error) {
41+
if (!runId) {
5742
return [];
43+
} else if (jobsCache[runId]) {
44+
return jobsCache[runId];
45+
} else {
46+
try {
47+
const jobs = await github.paginate(
48+
github.rest.actions.listJobsForWorkflowRun,
49+
{
50+
owner: env.OWNER,
51+
repo: env.REPOSITORY,
52+
run_id: runId,
53+
per_page: 100,
54+
},
55+
);
56+
jobsCache[runId] = jobs;
57+
return jobsCache[runId];
58+
} catch (error) {
59+
return [];
60+
}
5861
}
5962
}
6063

0 commit comments

Comments
 (0)