Repository navigation
ci: give risk-gate a pull_request trigger that writes the risk:T* label - #3404
Conversation
Pure labelPlan(tier, labels) plus a CLI that converges instead of stacking: labels of another tier are removed, the target is added, and a run that already finds the target sends no write. It posts no comment; the tier and its reasons stay in the run summary from risk-gate.mjs. Without --apply it writes nothing. Related #3393.
The workflow is the only producer of the label. It checks out the base commit, so the script and the rules table that judge a pull request are the ones already on main and never the pull request's own copies. Minimal permissions (contents: read, pull-requests: write); a failure says in the run summary that no label was applied, and the gates in tests.yml are not affected. Related #3393.
Four cases on the pure write rule and three on the command: --apply sends exactly the two writes, a re-run sends none, a dry run sends none, no comment is ever posted, and a 403 fails loudly instead of claiming success. The API is a stub in the test process, so nothing leaves the machine and no token is needed. Related #3393.
|
Related/Refs: present, |
|
Related/Refs: Local green (run at this head in a clean worktree, not in CI):
CI green: not claimed. I have no reading for this head: the connector's check-runs and pull-request endpoints both answer The "Risk tier label" run on this PR itself is expected to be red, and I say so before it happens rather than after. The workflow checks out Two consequences stated in the workflow itself and worth repeating here: a pull request from a fork gets a read-only Risk: Still open after this PR, not asked for here: Release — no defect found in this slice. |
Related #3393.
Slice
Give the risk tier a producer. Until now
risk:T*was a label a human typed, so done-when item 4 ("the label is written by a script") had no machine behind it. This adds the workflow that writes it, the script it calls, and the offline tests for that script. One slice, three new files, nothing else touched (tests.ymlis untouched).How the label is decided and written
pull_requestonopened,synchronize,reopened, one concurrency group per PR withcancel-in-progress, 5 minute timeout.ref: pull_request.base.sha. The script and the rules table that judge a PR are the ones onmain; a PR cannot ship a rules table that grades its own diff.risk-gate-label.mjscomputes the tier with the existingrisk-gate.mjsengine and then converges the label set: every otherrisk:T*is deleted, the target is added, and a run that already finds the target sends no write at all. So a re-run, a cancelled run and a re-push all end at exactly onerisk:T*label. It posts no comment - the tier and its reasons stay in the run summary - so there is no second copy to keep in sync.--applyit prints the change and writes nothing, so only the workflow can change a PR.permissions: contents: read+pull-requests: write, nothing else.Two things a reader should know
maindoes not containrisk-gate-label.mjsyet, so the step fails with a missing module. The failure step says so and names the two causes it cannot fix itself. The first PR that gets its label from the script is the one opened after this merges.risk:T0torisk:T3all already exist in this repository, so the workflow has something to attach.Not doing
labeledtrigger) is a separate slice.risk:T2@<sha>) touches the regex, gate 4 and this script together; separate slice.tests.ymldoes not yet run.github/scripts/*.test.mjs; one separate line, separate PR.Evidence (head 4b92184)
b107e677equals the tree of the reviewed local commit22b928e7; the three blobs arebafdee9f(script),55551b07(tests),32f17ca2(workflow).node --test .github/scripts/*.test.mjs-> tests 39 / pass 39 / fail 0 (24 risk-gate + 8 merge-gate + 7 new).node .github/scripts/merge-gate.mjs --self-test->self-test: 5/5 cases as expected, includingrisk:T3 is advisory, not a blocker.Risk tier label, which is neitherFlyBot required checksnor containstests-ok/enqueue-guard.Review
A review comment bound to this head follows separately; a new commit invalidates it.