Skip to content

CI Self CPU Report #1693

CI Self CPU Report

CI Self CPU Report #1693

name: CI Self CPU Report
# Posts the /run-cpu lane result back on the PR that triggered it. The button
# workflow (ci-self-cpu-button.yml) sets its run-name to "/run-cpu PR <n>",
# which this watcher parses to find the PR. Runs on the cpu runner so it is
# not subject to GitHub-hosted congestion (the lane's reason to exist).
on:
workflow_run:
workflows: ["CI Self CPU Button"]
types: [completed]
permissions:
contents: read
pull-requests: write
jobs:
report:
runs-on: [self-hosted, cpu]
steps:
- name: Comment lane result on PR
uses: actions/github-script@v7
with:
script: |
const run = context.payload.workflow_run;
if (run.event !== 'issue_comment' || run.conclusion === 'skipped') {
core.info(`nothing to report: event=${run.event} conclusion=${run.conclusion}`);
return;
}
const m = (run.display_title || '').match(/PR (\d+)/);
if (!m) {
core.info(`no PR number in display_title: ${run.display_title}`);
return;
}
const prNumber = Number(m[1]);
const jobs = await github.paginate(github.rest.actions.listJobsForWorkflowRun, {
...context.repo,
run_id: run.id,
filter: 'latest',
per_page: 100,
});
const laneJobs = jobs.filter((j) => j.name.startsWith('lane /'));
if (!laneJobs.length) {
core.info('no lane jobs (gate denied); nothing to report');
return;
}
const lines = laneJobs.map((j) => {
const icon = j.conclusion === 'success' ? '✅'
: j.conclusion === 'failure' ? '❌' : '⏭️';
return `- ${icon} ${j.name.replace('lane / ', '')}`;
});
const head = run.conclusion === 'success'
? `✅ **/run-cpu lane passed** — ${run.html_url}`
: `❌ **/run-cpu lane finished with ${run.conclusion}** — ${run.html_url}`;
await github.rest.issues.createComment({
...context.repo,
issue_number: prNumber,
body: `${head}\n\n${lines.join('\n')}`,
});