Skip to content

Commit 3446e1f

Browse files
committed
CI: port ABI check improvements from the spec repo
Bring the loader's check-abi.yml in line with the spec repo's loader-integration ABI check, so routine changes stop failing it. - Downgrade Parameter_Changed_Register / Parameter_Changed_Offset to Low. abi-dumper reads the last DWARF location entry, so -Og builds report false register/offset moves. Real breaks still fail via the type, added and removed rules. - Ignore the ZE_API_VERSION_CURRENT bump (scripts/update_ze_api_version.py, copied from the spec repo). - Pin abi-compliance-checker to 2.3 and abi-dumper to 1.4. - Let a reviewer accept a failure with an approval review containing abi-failure-approved. Only approvals from users with write access on the checked head commit count; the review re-runs the check. - Post one PR comment with both results, from a workflow_run companion (check-abi-comment.yml) so it works for fork PRs. - Cache base.dump by base commit, runner image and abi-dumper version. A push to master seeds the cache so new PRs skip the base build. The two jobs are now one matrix job; job names are unchanged. Tested locally with v1.33.1 -> v1.34.0, the case that failed #516: stock 94.9% (2 problems, exit 1); with this change 100% (0 problems, exit 0). Reverse compare (v1.34.0 -> v1.33.1) still fails: 21 problems. Signed-off-by: Russell McGuire <russell.w.mcguire@intel.com>
1 parent 350c7d0 commit 3446e1f

3 files changed

Lines changed: 382 additions & 81 deletions

File tree

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Check ABI Comment
2+
3+
# Posts the result of the "Check ABI" workflow back onto the pull request.
4+
# Because it is triggered by workflow_run it runs in the base repository
5+
# context with a writable token, so it can comment on fork PRs without ever
6+
# checking out or executing untrusted PR code.
7+
#
8+
# One comment per PR is created on the first run and updated in place after.
9+
#
10+
# NOTE: workflow_run only triggers from workflow files on the default branch, so
11+
# this begins working once merged to master.
12+
13+
on:
14+
workflow_run:
15+
workflows: [Check ABI]
16+
types: [completed]
17+
18+
permissions:
19+
actions: read # download the summary artifacts from the triggering run
20+
contents: read
21+
pull-requests: write # comment on the pull request (issues API, PR target)
22+
23+
jobs:
24+
comment:
25+
runs-on: ubuntu-latest
26+
if: >-
27+
github.event.workflow_run.event == 'pull_request' ||
28+
github.event.workflow_run.event == 'pull_request_review'
29+
steps:
30+
- name: Download summaries
31+
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
32+
continue-on-error: true
33+
with:
34+
pattern: abi-summary-*
35+
merge-multiple: true
36+
run-id: ${{ github.event.workflow_run.id }}
37+
github-token: ${{ secrets.GITHUB_TOKEN }}
38+
- name: Post or update PR comment
39+
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
40+
env:
41+
RUN_URL: ${{ github.event.workflow_run.html_url }}
42+
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
43+
with:
44+
script: |
45+
const fs = require('fs');
46+
const marker = '<!-- check-abi-report -->';
47+
const { owner, repo } = context.repo;
48+
49+
if (!fs.existsSync('pr_number.txt')) {
50+
core.info('No summary artifact found; nothing to comment on.');
51+
return;
52+
}
53+
const issue_number = parseInt(fs.readFileSync('pr_number.txt', 'utf8').trim(), 10);
54+
if (!Number.isInteger(issue_number)) {
55+
core.info('Invalid PR number; skipping.');
56+
return;
57+
}
58+
// The artifact comes from PR-controlled code; only trust the number if
59+
// that PR's head is the commit the run checked.
60+
const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number: issue_number });
61+
if (pr.head.sha !== process.env.HEAD_SHA) {
62+
core.info(`PR #${issue_number} head is ${pr.head.sha}, run checked ${process.env.HEAD_SHA}; skipping.`);
63+
return;
64+
}
65+
66+
const sections = ['last-release', 'master']
67+
.filter(base => fs.existsSync(`${base}.md`))
68+
.map(base => fs.readFileSync(`${base}.md`, 'utf8').trim());
69+
70+
const body = [
71+
marker,
72+
'### Level Zero loader ABI check',
73+
'',
74+
...sections.flatMap(s => [s, '']),
75+
`[Workflow run](${process.env.RUN_URL})`,
76+
'',
77+
'If an ABI change is intended, a reviewer with write access can accept it: '
78+
+ 'leave an **approval review** on the PR head commit with the keyword '
79+
+ '`abi-failure-approved` in the review body. That re-runs the check.',
80+
].join('\n');
81+
82+
const comments = await github.paginate(github.rest.issues.listComments, {
83+
owner, repo, issue_number, per_page: 100,
84+
});
85+
const existing = comments.find(c => c.body && c.body.includes(marker));
86+
87+
if (existing) {
88+
await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body });
89+
} else {
90+
await github.rest.issues.createComment({ owner, repo, issue_number, body });
91+
}

0 commit comments

Comments
 (0)