fix(ci): run merge-queue Docker builds on standard runners and skip wait on AWS master (#23043)

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The merge-queue Docker workflow
(`.github/workflows/docker-merge-group.yml`) pre-builds the production
image on `merge_group` so `docker.yml` can promote it on `master`
> - #22993 routed `amd64` merge-queue builds to `cloud-release-32`,
which does not admit `docker-merge-group.yml`, leaving every merge-queue
build queued forever
> - While those builds sat queued, `docker.yml` waited 3 minutes in
`Find the merge-queue build of this commit` before falling back to its
fast AWS release runner
> - This pull request moves `docker-merge-group.yml` back to standard
GitHub-hosted `matrix.runner` runners and sets
`MERGE_GROUP_FIND_WAIT_MS=0` when `CORE_RELEASE_AWS_ENABLED=true`
> - The benefit is that merge-queue builds actually execute and promote
when ready, while fast AWS `master` builds never lose 3 minutes waiting
behind slower GitHub-hosted merge-queue legs

## Linked Issues or Issue Description

Refs #22993, Refs #23000

**Describe the bug**
Every `docker-merge-group.yml` run stayed queued forever on `build
(linux/amd64)` because the `cloud-release-32` runner group does not
admit that workflow. In addition, `docker.yml` waited 3 minutes polling
unfinished merge-queue runs even when running on the faster AWS release
fleet (`CORE_RELEASE_AWS_ENABLED=true`).

**Steps to reproduce**
1. Merge a PR through the GitHub Merge Queue on `master`.
2. Inspect the triggered `Docker merge-queue build` run and see `build
(linux/amd64)` queued indefinitely.
3. Inspect the subsequent `Docker` run on `master` and see `Find the
merge-queue build of this commit` spend 3 minutes waiting before falling
back to a source build.

**Expected behavior**
`docker-merge-group.yml` starts on standard GitHub-hosted runners
(`ubuntu-latest` / `ubuntu-24.04-arm`), and `docker.yml` promotes an
already-completed merge-queue build immediately without stalling 3
minutes when running on the AWS release fleet.

## What Changed

- `.github/workflows/docker-merge-group.yml`: restore `runs-on: ${{
matrix.runner }}` for `build` so `amd64` runs on `ubuntu-latest` instead
of queueing on `cloud-release-32`.
- `.github/workflows/docker.yml`: pass `MERGE_GROUP_FIND_WAIT_MS: ${{
vars.CORE_RELEASE_AWS_ENABLED == 'true' && '0' || '180000' }}` to `Find
the merge-queue build of this commit`.
- `scripts/merge-group-image.mjs`: add `resolveFindWaitMs(env)` (clamped
to `[0, 180000]`, defaulting to `180000`) and use it in `find`.
- `server/src/__tests__/docker-runner-workflows.test.ts` &
`scripts/merge-group-image.test.mjs`: add guard tests for standard
runner placement and `resolveFindWaitMs` / `MERGE_GROUP_FIND_WAIT_MS`.

## Verification

- `vitest run server/src/__tests__/docker-runner-workflows.test.ts`:
15/15 passed.
- `node --test scripts/merge-group-image.test.mjs`: 10/10 passed.

## Risks

- Low risk. Restores standard runner placement (matching #23000) and
keeps the exact promotion verification contract unchanged; fail-open
fallback to source build is preserved.

## Model Used

- Google Antigravity agent (Gemini / Antigravity coding harness with
shell execution and tool use).

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
This commit is contained in:
Dotta authored and GitHub committed 2026-11-26 07:18:53 -06:00
1 parent 8f542b3c9b
commit 8f6d94169a
5 files changed
+36 -9

No files matched your search

+3 -5
View File
@@ -120,11 +120,9 @@ jobs:
- platform: linux/arm64
runner: ubuntu-24.04-arm
arch: arm64
# GitHub-hosted runners: the protected release fleets admit only
# docker.yml on master. amd64 merge-queue builds for canonical master use
# the larger GitHub-hosted runner (cloud-release-32) so pre-merge builds
# finish quickly while commits wait in the queue.
runs-on: ${{ matrix.arch == 'amd64' && (vars.CORE_PUBLICATION_RUNNER || 'cloud-release-32') || matrix.runner }}
# GitHub-hosted runners: the protected release fleets and larger release
# runner groups admit only docker.yml on master.
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
permissions:
contents: read
+4
View File
@@ -371,6 +371,10 @@ jobs:
GITHUB_TOKEN: ${{ github.token }}
BEFORE: ${{ github.event.before }}
ARCH: ${{ matrix.arch }}
# When master runs on the fast AWS release fleet, promote an already-
# completed merge-queue build immediately instead of stalling 3 minutes
# behind a slower GitHub-hosted merge-queue runner.
MERGE_GROUP_FIND_WAIT_MS: ${{ vars.CORE_RELEASE_AWS_ENABLED == 'true' && '0' || '180000' }}
# Master's copy from before this push selects the run; see the promote
# step below.
run: |
+14 -3
View File
@@ -22,10 +22,20 @@ const architectures = ["amd64", "arm64"];
const indexTypes = ["application/vnd.oci.image.index.v1+json", "application/vnd.docker.distribution.manifest.list.v2+json"];
const manifestTypes = ["application/vnd.oci.image.manifest.v1+json", "application/vnd.docker.distribution.manifest.v2+json"];
// How long a master push waits for a merge-queue build that is still running.
// Capped at 3 minutes so a master push on a fast AWS runner falls back to
// building from source instead of stalling behind a slower merge-group leg.
// Capped at 3 minutes so a master push falls back to building from source
// instead of stalling behind a slower merge-group leg; callers on fast AWS
// release runners pass MERGE_GROUP_FIND_WAIT_MS=0 to promote completed builds
// immediately with zero wait penalty.
const findWaitMs = 3 * 60_000;
const findPollMs = 15_000;
export function resolveFindWaitMs(env = process.env) {
const raw = env?.MERGE_GROUP_FIND_WAIT_MS;
if (raw === undefined || raw === "") return findWaitMs;
const parsed = Number(raw);
if (!Number.isInteger(parsed) || parsed < 0) return findWaitMs;
return Math.min(parsed, findWaitMs);
}
const fullSha = /^[a-f0-9]{40}$/;
const hex64 = /^[a-f0-9]{64}$/;
const digestPattern = /^sha256:[a-f0-9]{64}$/;
@@ -215,7 +225,8 @@ async function main(command) {
// Publication waits for the exact-source gate in any case, so waiting here
// briefly for an almost-finished build costs nothing; past the deadline the
// push builds from source.
const deadline = Date.now() + findWaitMs;
const waitMs = resolveFindWaitMs(process.env);
const deadline = Date.now() + waitMs;
let run;
for (;;) {
const { workflow_runs: runs } = await api(`/actions/workflows/docker-merge-group.yml/runs?event=merge_group&head_sha=${sha}&per_page=20`);
+9 -1
View File
@@ -7,7 +7,7 @@ import path from "node:path";
import test from "node:test";
import { fileURLToPath } from "node:url";
import {
archiveImageDigest, assertPipelineUnchanged, changedSince, createRecord, repositoryId, selectArtifact, selectVerifiedRun, verifyRecord, workflowPath,
archiveImageDigest, assertPipelineUnchanged, changedSince, createRecord, repositoryId, resolveFindWaitMs, selectArtifact, selectVerifiedRun, verifyRecord, workflowPath,
} from "./merge-group-image.mjs";
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
@@ -208,6 +208,14 @@ test("master promotes only after proof and otherwise builds exactly as before",
const order = name => steps.indexOf(step(name));
assert.match(step("Find the merge-queue build of this commit"),
/if: github.repository == 'paperclipai\/paperclip' && github.repository_id == '1170821064' && github.event_name == 'push' && github.ref == 'refs\/heads\/master'/);
assert.match(step("Find the merge-queue build of this commit"),
/MERGE_GROUP_FIND_WAIT_MS: \$\{\{ vars\.CORE_RELEASE_AWS_ENABLED == 'true' && '0' \|\| '180000' \}\}/);
assert.equal(resolveFindWaitMs({}), 180_000);
assert.equal(resolveFindWaitMs({ MERGE_GROUP_FIND_WAIT_MS: "0" }), 0);
assert.equal(resolveFindWaitMs({ MERGE_GROUP_FIND_WAIT_MS: "45000" }), 45_000);
assert.equal(resolveFindWaitMs({ MERGE_GROUP_FIND_WAIT_MS: "999999" }), 180_000);
assert.equal(resolveFindWaitMs({ MERGE_GROUP_FIND_WAIT_MS: "-1" }), 180_000);
assert.equal(resolveFindWaitMs({ MERGE_GROUP_FIND_WAIT_MS: "invalid" }), 180_000);
for (const name of ["Find the merge-queue build of this commit", "Download the merge-queue image", "Promote the merge-queue image"]) {
assert.match(step(name), /continue-on-error: true/, `${name} must fall back to the build`);
}
@@ -303,6 +303,12 @@ describe("the merge-queue build's Runner image in docker-merge-group.yml", () =>
expect(record).toContain("RUNNER_INPUTS_DIGEST: ${{ needs.runner_image.outputs.inputs_digest }}");
expect(record).toContain('--runner-inputs-digest "$RUNNER_INPUTS_DIGEST"');
});
it("keeps merge-queue build jobs on standard GitHub-hosted matrix runners", () => {
const runsOn = /\n {4}runs-on: (.+)\n/.exec(buildJob)?.[1];
expect(runsOn).toBe("${{ matrix.runner }}");
expect(buildJob).not.toMatch(/cloud-release-32|CORE_PUBLICATION_RUNNER|runs-on\/fleet=/);
});
});
describe("the pull-request check of the application image's Runner path", () => {