Files
OmniRoute/scripts/merge-queue/github.mjs
diegosouzapw 727cacafd3 fix(ci): omni-queue counts only the candidate's own push runs in its verdict
The candidate SHA is public. Anybody can publish that commit in a fork, or
on a branch of this repository, and open a pull request whose head is the
candidate. The PR's CI then reports check runs on the same SHA, and the
tick read them as the candidate's:

- readChecks kept every run whose check suite had no head_branch (fork
  PRs) or whose head_branch was the candidate ref (a same-repository PR
  from a branch with that name);
- by cancelling or re-pushing, the PR's author could make the candidate
  red or "infra" (retry, then a paused base), and a later run with the
  same name superseded the candidate's own result in checks.latestByName.

The verdict of a candidate ref now counts only the check runs of the check
suites of push-event workflow runs on that ref for that SHA
(GET /actions/runs?branch=<ref>&event=push&head_sha=<sha>, token already
has actions: read). Every listed run is re-checked for event, branch and
SHA. Anything else on the SHA is ignored: the base's own push, the other
ref of an infra retry, pull_request suites, workflow_dispatch runs, and
check runs of other apps (commit statuses are unchanged). Unknown fails
closed: with no ref, or no push run listed yet, no run counts, the verdict
stays pending and the existing no-CI timeout applies.

Why not strict `headBranch === ref`: checked on the release tip of the
real repository, a check suite carries the branch but not the event, so
the suites of a pull_request run and of a push run on the same branch
look alike. Each workflow run has its own check suite, and
workflow_run.check_suite_id equals check_run.check_suite.id.

github.mjs: check runs carry checkSuiteId; workflow runs carry headBranch
and checkSuiteId.

Tests: the new tick, client and end-to-end tests fail on the previous
code. Existing assertions changed, all additive, because the normalized
shapes gained fields: github.test.mjs expects checkSuiteId on
normalizeCheckRun and headBranch/checkSuiteId on listWorkflowRuns. One
tick test that injects raw check runs now attributes them to the push run
of the candidate ref in its setup; its assertions are untouched.
2026-11-14 12:34:17 -03:00

36 KiB