Skip to content

Commit be8804b

Browse files
committed
don't fail build when fetching job url fails
1 parent 12c0822 commit be8804b

File tree

2 files changed

+41
-25
lines changed

2 files changed

+41
-25
lines changed

.github/workflows/build-common.yml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -334,22 +334,27 @@ jobs:
334334
with:
335335
result-encoding: string
336336
script: |
337-
const matrix = JSON.parse(process.env.matrix);
338-
const job_name = `common / test${ matrix['test-partition'] } (${ matrix['test-java-version'] }, ${ matrix.vm }, indy ${ matrix['test-indy'] })`;
339-
340-
const workflow_jobs_nested = await github.paginate(
341-
github.rest.actions.listJobsForWorkflowRun,
342-
{
343-
owner: context.repo.owner,
344-
repo: context.repo.repo,
345-
run_id: context.runId,
346-
per_page: 100
347-
},
348-
(response) => {
349-
return response.data;
350-
},
351-
);
352-
return workflow_jobs_nested.flat().find((job) => job.name === job_name).html_url;
337+
try {
338+
const matrix = JSON.parse(process.env.matrix);
339+
const job_name = `common / test${ matrix['test-partition'] } (${ matrix['test-java-version'] }, ${ matrix.vm }, indy ${ matrix['test-indy'] })`;
340+
const workflow_jobs_nested = await github.paginate(
341+
github.rest.actions.listJobsForWorkflowRun,
342+
{
343+
owner: context.repo.owner,
344+
repo: context.repo.repo,
345+
run_id: context.runId,
346+
per_page: 100
347+
},
348+
(response) => {
349+
return response.data;
350+
},
351+
);
352+
const job = workflow_jobs_nested.flat().find((job) => job.name === job_name);
353+
return job ? job.html_url : '';
354+
} catch (e) {
355+
core.warning(`Failed to get current job url: ${e}`);
356+
return '';
357+
}
353358
354359
- name: Flaky test report
355360
if: ${{ !cancelled() }}

.github/workflows/reusable-test-latest-deps.yml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,26 @@ jobs:
9191
with:
9292
result-encoding: string
9393
script: |
94-
const { data: workflow_run } = await github.rest.actions.listJobsForWorkflowRun({
95-
owner: context.repo.owner,
96-
repo: context.repo.repo,
97-
run_id: context.runId,
98-
per_page: 100
99-
});
100-
const matrix = JSON.parse(process.env.matrix);
101-
const job_name = `test-latest-deps / testLatestDeps${ matrix['test-partition'] }`;
102-
return workflow_run.jobs.find((job) => job.name === job_name).html_url;
94+
try {
95+
const job_name = `test-latest-deps / testLatestDeps${ matrix['test-partition'] }`;
96+
const workflow_jobs_nested = await github.paginate(
97+
github.rest.actions.listJobsForWorkflowRun,
98+
{
99+
owner: context.repo.owner,
100+
repo: context.repo.repo,
101+
run_id: context.runId,
102+
per_page: 100
103+
},
104+
(response) => {
105+
return response.data;
106+
},
107+
);
108+
const job = workflow_jobs_nested.flat().find((job) => job.name === job_name);
109+
return job ? job.html_url : '';
110+
} catch (e) {
111+
core.warning(`Failed to get current job url: ${e}`);
112+
return '';
113+
}
103114
104115
- name: Flaky test report
105116
if: ${{ !cancelled() }}

0 commit comments

Comments
 (0)