ci: merge once the checks have reported, not before they start #1725

Merged
jaylouisw merged 2 commits from ci/1116-2020 into main 2026-11-16 20:37:20 +00:00
Owner

What was broken

Every merge gate in this repository is an arm, and an arm is not a gate.

pr-rebase.yml and auto-rebase.yml both POST
{"Do":"squash","merge_when_checks_succeed":true} seconds after the force-push that
rebased the branch. Forgejo evaluates that flag against the checks that exist at the
moment of the call — and for a head pushed seconds earlier that set is empty.
"All checks succeeded" over nothing is true, so the pull request merged and CI then
reported on a commit that was already on main.

Baseline (measured, /commits/{sha}/status over the 25 most recently merged PRs, 2026-11-16)

evidence value
PRs merged before any of their 7 checks reported 25 of 25
PRs with no status at all on the head commit at merge time 15 of 25
single clearest case #1719: rebase job run 4092 armed it at 19:59:43 (HTTP 201), merged 19:59:54, its own CI run 4091 finished its last leg 20:00:51 — 58 s after the commit was on main

Test (Node 18/20/22) on run 4091: started 19:59:43-47, all green by 20:00:51 for a
pull request that had already landed at 19:59:54. The matrix was a post-merge
notification.

The change

  • ci.yml: new job Arm auto-merge (needs: [changes, test, smoke, docker],
    if: always() && pull_request && live != 'false'). It reads the head commit's
    statuses and merges only when every reported check is a success and all three
    CI / Test (Node *) legs are in the set. node:20-bookworm start plus the API calls
    — ~10 s of a slot.
  • pr-rebase.yml, auto-rebase.yml: arming is now conditional on the same predicate
    (checks_green), so a head that was just rebased is left to the new job instead of
    being armed while its checks are still empty. Both keep arming a head that is already
    green, so a pull request that lost its arm does not sit mergeable and unarmed.
  • every merge now carries head_commit_id, so a run against a superseded commit cannot
    merge a newer one.

Coverage unchanged

No check is dropped or weakened: the gate now reads the checks instead of arming past
them. Same 3-leg matrix, same static checks, same smoke and Docker jobs. Local run on
this branch: 287 suites, 10227 assertions, check-ci-disk-hygiene, check-node-surface,
check-canonical-urls and check-control-bytes all clean.

After

Run id for this branch is recorded in a comment below once it concludes.

## What was broken Every merge gate in this repository is an *arm*, and an arm is not a gate. `pr-rebase.yml` and `auto-rebase.yml` both POST `{"Do":"squash","merge_when_checks_succeed":true}` seconds after the force-push that rebased the branch. Forgejo evaluates that flag against the checks that exist at the moment of the call — and for a head pushed seconds earlier that set is empty. "All checks succeeded" over nothing is true, so the pull request merged and CI then reported on a commit that was already on `main`. ## Baseline (measured, `/commits/{sha}/status` over the 25 most recently merged PRs, 2026-11-16) | evidence | value | | --- | --- | | PRs merged before any of their 7 checks reported | **25 of 25** | | PRs with *no* status at all on the head commit at merge time | **15 of 25** | | single clearest case | #1719: rebase job **run 4092** armed it at `19:59:43` (HTTP 201), merged `19:59:54`, its own CI **run 4091** finished its last leg `20:00:51` — 58 s after the commit was on main | `Test (Node 18/20/22)` on run 4091: started 19:59:43-47, all green by 20:00:51 for a pull request that had already landed at 19:59:54. The matrix was a post-merge notification. ## The change * `ci.yml`: new job **`Arm auto-merge`** (`needs: [changes, test, smoke, docker]`, `if: always() && pull_request && live != 'false'`). It reads the head commit's statuses and merges only when every reported check is a `success` **and** all three `CI / Test (Node *)` legs are in the set. `node:20-bookworm` start plus the API calls — ~10 s of a slot. * `pr-rebase.yml`, `auto-rebase.yml`: arming is now conditional on the same predicate (`checks_green`), so a head that was just rebased is left to the new job instead of being armed while its checks are still empty. Both keep arming a head that is already green, so a pull request that lost its arm does not sit mergeable and unarmed. * every merge now carries `head_commit_id`, so a run against a superseded commit cannot merge a newer one. ## Coverage unchanged No check is dropped or weakened: the gate now *reads* the checks instead of arming past them. Same 3-leg matrix, same static checks, same smoke and Docker jobs. Local run on this branch: 287 suites, 10227 assertions, `check-ci-disk-hygiene`, `check-node-surface`, `check-canonical-urls` and `check-control-bytes` all clean. ## After Run id for this branch is recorded in a comment below once it concludes.
ci: merge once the checks have reported, not before they start
All checks were successful
CI / Classify the change (pull_request) Successful in 13s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 18s
CI / Server smoke test (pull_request) Successful in 19s
CI / Test (Node 20) (pull_request) Successful in 51s
CI / Docker build (pull_request) Successful in 27s
CI / Test (Node 18) (pull_request) Successful in 56s
CI / Test (Node 22) (pull_request) Successful in 55s
CI / Arm auto-merge (pull_request) Successful in 2s
f04e8e2fdf
All 25 of the most recently merged pull requests (#1723, #1722, #1721, #1719,
#1718, #1717, #1716, #1715, #1713, #1712, #1711, #1710, #1709, #1708, #1707,
#1706, #1705, #1704, #1703, #1702, #1700, #1699, #1698, #1690) were merged
before any of their seven checks reported, and 15 of them had no status at all
on the head commit at the moment of the merge.

The mechanism is an arm, not a gate: pr-rebase.yml and auto-rebase.yml POST
{"Do":"squash","merge_when_checks_succeed":true} seconds after the force-push
that rebased the branch, and Forgejo evaluates that flag against the checks that
exist at that moment. After a force-push that set is empty, and "all checks
succeeded" over nothing is true, so the pull request landed and CI reported on a
commit that was already on main. #1719 is the clearest case: run 4092 armed it at
19:59:43 (HTTP 201), Forgejo merged at 19:59:54, and its own run 4091 did not
finish its first test leg until 20:00:46.

So the merge moves to the one job that runs after the checks it depends on:
`Arm auto-merge` in ci.yml, needs [changes, test, smoke, docker], which reads the
head commit's statuses and merges only when every reported check is a success and
all three CI test legs are among them. Both rebase workflows keep arming as a
fallback but now only for a head that is already green.

The merge carries head_commit_id, so a stale run cannot merge a newer commit, and
every failure path is a warning and an unmerged branch - never a red X on a pull
request that is fine. No check is weakened: the gate now reads the checks instead
of skipping them.
jaylouisw force-pushed ci/1116-2020 from f04e8e2fdf
All checks were successful
CI / Classify the change (pull_request) Successful in 13s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 18s
CI / Server smoke test (pull_request) Successful in 19s
CI / Test (Node 20) (pull_request) Successful in 51s
CI / Docker build (pull_request) Successful in 27s
CI / Test (Node 18) (pull_request) Successful in 56s
CI / Test (Node 22) (pull_request) Successful in 55s
CI / Arm auto-merge (pull_request) Successful in 2s
to 711fe27cbe
All checks were successful
CI / Classify the change (pull_request) Successful in 14s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 17s
CI / Server smoke test (pull_request) Successful in 21s
CI / Test (Node 20) (pull_request) Successful in 52s
CI / Test (Node 18) (pull_request) Successful in 56s
CI / Docker build (pull_request) Successful in 28s
CI / Test (Node 22) (pull_request) Successful in 57s
CI / Arm auto-merge (pull_request) Successful in 3s
2026-11-16 20:32:24 +00:00
Compare
ci: the reader's own pending status is not a check on the change
All checks were successful
CI / Classify the change (pull_request) Successful in 13s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 17s
CI / Server smoke test (pull_request) Successful in 22s
CI / Test (Node 20) (pull_request) Successful in 53s
CI / Test (Node 18) (pull_request) Successful in 56s
CI / Docker build (pull_request) Successful in 28s
CI / Test (Node 22) (pull_request) Successful in 58s
CI / Arm auto-merge (pull_request) Successful in 12s
753bede7bc
Run 4125 task 9254 refused to merge #1725 with

  not successful: CI / Arm auto-merge (pull_request)=pending

which is the job's own status while it runs. All three predicates now exclude the
context of the job that reads them, so 'everything has reported' means everything
except the reader. The comment has no apostrophe for the same reason: the JS lives
inside a single-quoted node -e argument.
Author
Owner

After

Merged at 20:37:20, 14 s after the last real check reported - not 57 s before.

before (#1719) after (#1725)
rebase / arm run 4092, armed 19:59:43 4128 (rebase only: checks were not green)
CI run 4091 4127, tasks 9257-9261, arm task 9262
last real check green 20:00:51 20:37:06 (Test (Node 22), task 9259)
merged 19:59:54 - 57 s early 20:37:20 - 14 s late

arm job log, run 4127 task 9262:

20:37:11  #1725: every check on 753bede7bcf6fc35c1cfe40ae3942b0b01d69cf2 is green - merging
20:37:21  #1725: merged 753bede7bcf6fc35c1cfe40ae3942b0b01d69cf2 as a squash, every check green

The first attempt at this gate (run 4125 task 9254) refused to merge with
not successful: CI / Arm auto-merge (pull_request)=pending - the job's own status while it
runs - so the reader's own context is now excluded from all three predicates.

Run 4127 wall clock: classify 20:36:01 -> arm 20:37:28 = 87 s, against 86 s for run 4091
before the change: the gate costs ~14 s of a slot per pull request.

Still red / known

  • test/board-id-is-a-name.test.js failed once locally at PF_TEST_CONCURRENCY=10 on this
    Windows host (10227 passed / 1 failed) and passes 65/65 standalone; CI at 10-way was
    287 suites / 10292 assertions green (run 4091). A dev-host harness flake, and it lives in
    test/, which this stream does not touch.
  • pr-rebase.yml no longer arms a head it just pushed, so a pull request whose CI run never
    dispatches is merged by hand, exactly as before.
## After Merged at `20:37:20`, **14 s after** the last real check reported - not 57 s before. | | before (#1719) | after (#1725) | | --- | --- | --- | | rebase / arm run | 4092, armed 19:59:43 | 4128 (rebase only: checks were not green) | | CI run | 4091 | **4127**, tasks 9257-9261, arm task **9262** | | last real check green | 20:00:51 | 20:37:06 (`Test (Node 22)`, task 9259) | | merged | 19:59:54 - **57 s early** | 20:37:20 - **14 s late** | arm job log, run 4127 task 9262: ``` 20:37:11 #1725: every check on 753bede7bcf6fc35c1cfe40ae3942b0b01d69cf2 is green - merging 20:37:21 #1725: merged 753bede7bcf6fc35c1cfe40ae3942b0b01d69cf2 as a squash, every check green ``` The first attempt at this gate (run 4125 task 9254) refused to merge with `not successful: CI / Arm auto-merge (pull_request)=pending` - the job's own status while it runs - so the reader's own context is now excluded from all three predicates. Run 4127 wall clock: classify 20:36:01 -> arm 20:37:28 = **87 s**, against 86 s for run 4091 before the change: the gate costs ~14 s of a slot per pull request. ## Still red / known * `test/board-id-is-a-name.test.js` failed once locally at `PF_TEST_CONCURRENCY=10` on this Windows host (10227 passed / 1 failed) and passes 65/65 standalone; CI at 10-way was 287 suites / 10292 assertions green (run 4091). A dev-host harness flake, and it lives in `test/`, which this stream does not touch. * `pr-rebase.yml` no longer arms a head it just pushed, so a pull request whose CI run never dispatches is merged by hand, exactly as before.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jaylouisw/packetforge!1725
No description provided.