Skip to content

Commit ae574c1

Browse files
committed
ci: add on-demand /verify command handler (Tier 0 verification comment)
Relayed from TechAPI via repository_dispatch (techapi-verify). Checks out the PR head, runs TechAPI app.verify, and posts the band report as TechEngineBot.
1 parent 431d1a9 commit ae574c1

1 file changed

Lines changed: 102 additions & 0 deletions

File tree

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: techapi-verify-comment
2+
3+
# On-demand Tier 0 data verification for a TechAPI PR. Triggered by an English
4+
# command comment (`/verify`) on the PR, relayed here as a repository_dispatch by
5+
# TechAPI's verify-command.yml. Checks out the PR head, runs TechAPI's app.verify,
6+
# and posts the green/yellow/red band report back on the PR as TechEngineBot.
7+
on:
8+
repository_dispatch:
9+
types: [techapi-verify]
10+
workflow_dispatch:
11+
inputs:
12+
pr_number:
13+
description: "TechAPI PR number to verify + comment on"
14+
required: true
15+
head_sha:
16+
description: "TechAPI commit SHA to verify"
17+
required: true
18+
19+
permissions:
20+
contents: read
21+
22+
concurrency:
23+
group: techapi-verify-${{ github.event.client_payload.pr_number || inputs.pr_number }}
24+
cancel-in-progress: true
25+
26+
jobs:
27+
verify:
28+
runs-on: ubuntu-latest
29+
env:
30+
PYTHONIOENCODING: utf-8
31+
TECHAPI_COMMENT_TOKEN: ${{ secrets.TECHENGINEBOT_TOKEN || secrets.TECHAPI_TOKEN }}
32+
TECHAPI_PR_NUMBER: ${{ github.event.client_payload.pr_number || inputs.pr_number }}
33+
TECHAPI_HEAD_SHA: ${{ github.event.client_payload.head_sha || inputs.head_sha }}
34+
REQUESTED_BY: ${{ github.event.client_payload.requested_by || github.actor }}
35+
steps:
36+
- name: Checkout TechAPI PR head
37+
uses: actions/checkout@v4
38+
with:
39+
repository: GetTechAPI/TechAPI
40+
ref: ${{ env.TECHAPI_HEAD_SHA }}
41+
path: TechAPI
42+
fetch-depth: 0
43+
44+
- uses: actions/setup-python@v5
45+
with:
46+
python-version: "3.12"
47+
48+
# app.verify is a stdlib-only TechAPI module; run it from the checkout.
49+
- name: Run Tier 0 verification
50+
id: verify
51+
run: |
52+
cd TechAPI
53+
git fetch origin main --depth=1 || true
54+
{
55+
echo 'report<<VERIFY_EOF'
56+
echo "### Changed records in this PR"
57+
python -m app.verify score --changed --no-cache || echo "(app.verify unavailable on this ref)"
58+
echo ""
59+
echo "### Full-dataset baseline"
60+
python -m app.verify score --no-cache || true
61+
echo VERIFY_EOF
62+
} >> "$GITHUB_OUTPUT"
63+
64+
- name: Post verification comment (TechEngineBot)
65+
if: env.TECHAPI_COMMENT_TOKEN != ''
66+
uses: actions/github-script@v7
67+
env:
68+
REPORT: ${{ steps.verify.outputs.report }}
69+
PR_NUMBER: ${{ env.TECHAPI_PR_NUMBER }}
70+
REQUESTED_BY: ${{ env.REQUESTED_BY }}
71+
with:
72+
github-token: ${{ secrets.TECHENGINEBOT_TOKEN || secrets.TECHAPI_TOKEN }}
73+
script: |
74+
const marker = '<!-- techengine-verify-command -->';
75+
const report = (process.env.REPORT || '').trim() || '(no output)';
76+
const by = process.env.REQUESTED_BY || 'someone';
77+
const body = [
78+
marker,
79+
'## 🔎 Data verification — Tier 0 (on demand)',
80+
'',
81+
`Requested by @${by} via \`/verify\` · scored by \`app.verify\`, posted by **TechEngineBot**. Informational only — the structural gate (\`app.validate\`) is separate.`,
82+
'',
83+
'```text',
84+
report,
85+
'```',
86+
].join('\n');
87+
const owner = 'GetTechAPI';
88+
const repo = 'TechAPI';
89+
const issue_number = Number(process.env.PR_NUMBER);
90+
const comments = await github.paginate(github.rest.issues.listComments, {
91+
owner, repo, issue_number, per_page: 100,
92+
});
93+
const existing = comments.find((c) => c.body && c.body.includes(marker));
94+
if (existing) {
95+
await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body });
96+
} else {
97+
await github.rest.issues.createComment({ owner, repo, issue_number, body });
98+
}
99+
100+
- name: Dormant when no bot token
101+
if: env.TECHAPI_COMMENT_TOKEN == ''
102+
run: echo "::warning::No TECHENGINEBOT_TOKEN/TECHAPI_TOKEN; verification ran but no comment was posted."

0 commit comments

Comments
 (0)