Skip to content

Commit e9057c3

Browse files
committed
Create check run on workflow run to better display result.
In order to make the behavior of the libc++ restarter more visible to users, this change creates a check run on the considered workflow to let users know what action, if any, was taken
1 parent 86bb5c8 commit e9057c3

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

.github/workflows/restart-preempted-libcxx-jobs.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,27 @@ jobs:
3838
const wf_run = context.payload.workflow_run
3939
core.notice(`Running on "${wf_run.display_title}" by @${wf_run.actor.login} (event: ${wf_run.event})\nWorkflow run URL: ${wf_run.html_url}`)
4040
41+
42+
async function create_check_run(conclusion, message) {
43+
// Create a check run on the given workflow run to indicate if
44+
// we are restarting the workflow or not.
45+
if (conclusion != 'success' && conclusion != 'skipped' && conclusion != 'neutral') {
46+
core.setFailed('Invalid conclusion: ' + conclusion)
47+
}
48+
await github.rest.checks.create({
49+
owner: context.repo.owner,
50+
repo: context.repo.repo,
51+
name: 'Restart Preempted Job',
52+
head_sha: wf_run.head_sha,
53+
status: 'completed',
54+
conclusion: conclusion,
55+
output: {
56+
title: 'Restarted Preempted Job',
57+
summary: message
58+
}
59+
})
60+
}
61+
4162
console.log('Listing check runs for suite')
4263
const check_suites = await github.rest.checks.listForSuite({
4364
owner: context.repo.owner,
@@ -88,13 +109,16 @@ jobs:
88109
// We don't want to restart the workflow if there were other failures.
89110
core.notice('Choosing not to rerun workflow because we found a non-preemption failure' +
90111
'Failure message: "' + annotation.message + '"');
112+
await create_check_run('skipped', 'Choosing not to rerun workflow because we found a non-preemption failure\n'
113+
+ 'Failure message: ' + annotation.message)
91114
return;
92115
}
93116
}
94117
}
95118
96119
if (!has_preempted_job) {
97120
core.notice('No preempted jobs found. Not restarting workflow.');
121+
await create_check_run('neutral', 'No preempted jobs found. Not restarting workflow.')
98122
return;
99123
}
100124
@@ -104,5 +128,6 @@ jobs:
104128
repo: context.repo.repo,
105129
run_id: context.payload.workflow_run.id
106130
})
131+
await create_check_run('success', 'Restarted workflow run due to preempted job')
107132
108133

0 commit comments

Comments
 (0)