Public: anyone can read this; the crew can change it.
Main's full check is never cancelled by a landing, so main gets a verdict #16993
Check · Review · Land · Live done — Landed and live in production.
torque/forge:torque/16966-main-s-full-check-is-never-cancelled-by → main 0 commits fork
3 files
changed +69
−2
src/release/main_check_idle.ts +7 −2
| @@ -9,17 +9,22 @@ | ||
| 9 | 9 | |
| 10 | 10 | import type { Database } from "bun:sqlite"; |
| 11 | 11 | import { during } from "../perf/jobs.ts"; |
| 12 | import { BISECT_ENV, VERIFY_ENV } from "../checks/verify.ts"; | |
| 12 | 13 | |
| 13 | 14 | export const MAIN_CHECK_WAIT_MS = 2 * 60 * 60_000; |
| 14 | 15 | const POLL_MS = 15_000; |
| 15 | 16 | |
| 16 | /** Whether the default branch's full check (never a pull's fast tier) is running now. */ | |
| 17 | /** | |
| 18 | * Whether the default branch's check is running now: the landing's own (env = the branch) and | |
| 19 | * the full check, the verification lane (`verify`, and a bisection step after a red one), which | |
| 20 | * is the hour-long run a swap used to cut off (#16966). Never a pull's fast tier. | |
| 21 | */ | |
| 17 | 22 | export function mainCheckRunning(db: Database, repoId: string, branch: string): boolean { |
| 18 | 23 | return ( |
| 19 | 24 | db |
| 20 | 25 | .query( |
| 21 | 26 | `SELECT 1 FROM run |
| 22 | WHERE repo_id = ?1 AND kind = 'check' AND issue_id IS NULL AND env = ?2 AND state = 'running' | |
| 27 | WHERE repo_id = ?1 AND kind = 'check' AND issue_id IS NULL AND env IN (?2, '${VERIFY_ENV}', '${BISECT_ENV}') AND state = 'running' | |
| 23 | 28 | LIMIT 1`, |
| 24 | 29 | ) |
| 25 | 30 | .get(repoId, branch) !== null |
test/main-verify-not-cancelled.test.ts added +51
| @@ -0,0 +1,51 @@ | ||
| 1 | /** | |
| 2 | * Main's full check (the verification lane) is never cancelled by a landing (#16966): one already | |
| 3 | * running finishes and reports, landings during it coalesce into one queued run of the newest | |
| 4 | * tip, and a release does not swap while it runs (`release/main_check_idle.ts`). | |
| 5 | */ | |
| 6 | import { expect, test } from "bun:test"; | |
| 7 | import { commitToBranch } from "../src/actions/repos.ts"; | |
| 8 | import { VERIFY_ENV } from "../src/checks/verify.ts"; | |
| 9 | import { mainCheckRunning } from "../src/release/main_check_idle.ts"; | |
| 10 | import { checkJson, checksForge } from "./helpers/checks-forge.ts"; | |
| 11 | ||
| 12 | const f = checksForge("forge-verify-keeps-"); | |
| 13 | ||
| 14 | async function land(name: string, verify: string): Promise<string> { | |
| 15 | const c = await commitToBranch(f.app, f.alice, f.repo, { | |
| 16 | message: name, | |
| 17 | files: [{ path: "forge.json", content: checkJson("true", `, "verify": ${JSON.stringify(verify)}`) }, { path: `${name}.md`, content: `${name}\n` }], | |
| 18 | }); | |
| 19 | if (!c.ok) throw new Error(JSON.stringify(c.error)); | |
| 20 | return c.value.commitOid; | |
| 21 | } | |
| 22 | ||
| 23 | test("two landings during a running full check leave it running; it finishes with a verdict", async () => { | |
| 24 | const first = await land("one", f.held("verify-one")); | |
| 25 | const run = await f.checks.request(f.repo, VERIFY_ENV, first, "schedule"); | |
| 26 | if (run === undefined) throw new Error("no verification queued"); | |
| 27 | await f.until(() => f.checksOf(first).some((r) => r.env === VERIFY_ENV && r.state === "running"), "verify running"); | |
| 28 | // The landing's own check is quick; once it is over only the full check holds a release. | |
| 29 | await f.until(() => !f.checksOf(first).some((r) => r.env === f.repo.defaultBranch && (r.state === "queued" || r.state === "running")), "landing check over"); | |
| 30 | // A release looks here before it swaps: a running full check holds it. | |
| 31 | expect(mainCheckRunning(f.app.db, f.repo.id, f.repo.defaultBranch)).toBe(true); | |
| 32 | ||
| 33 | const second = await land("two", "true"); | |
| 34 | const third = await land("three", "true"); | |
| 35 | await f.checks.request(f.repo, VERIFY_ENV, second, "schedule"); | |
| 36 | await f.checks.request(f.repo, VERIFY_ENV, third, "schedule"); | |
| 37 | ||
| 38 | // The first run was not cancelled by either: still running, no finish time. | |
| 39 | const still = f.checksOf(first).find((r) => r.id === run.id); | |
| 40 | expect(still?.state).toBe("running"); | |
| 41 | // The second landing was coalesced into the third, which waits. | |
| 42 | expect(f.checksOf(second).find((r) => r.env === VERIFY_ENV)?.state).toBe("cancelled"); | |
| 43 | expect(f.checksOf(third).find((r) => r.env === VERIFY_ENV)?.state).toBe("queued"); | |
| 44 | ||
| 45 | f.release("verify-one"); | |
| 46 | const done = await f.settled((r) => r.id === run.id); | |
| 47 | expect(done.state).toBe("ok"); | |
| 48 | const next = await f.settled((r) => r.env === VERIFY_ENV && r.commitOid === third); | |
| 49 | expect(next.state).toBe("ok"); | |
| 50 | expect(mainCheckRunning(f.app.db, f.repo.id, f.repo.defaultBranch)).toBe(false); | |
| 51 | }); |
test/release-waits-for-main-check.test.ts +11
| @@ -43,6 +43,17 @@ test("only a running full check of the default branch counts", async () => { | ||
| 43 | 43 | expect(mainCheckRunning(f.app.db, f.repo.id, b)).toBe(false); |
| 44 | 44 | }); |
| 45 | 45 | |
| 46 | test("the full check (the verification lane) and its bisection steps hold a release too (#16966)", async () => { | |
| 47 | const f = await fixture(); | |
| 48 | const b = f.repo.defaultBranch; | |
| 49 | const verify = startCheck(f, "verify"); | |
| 50 | expect(mainCheckRunning(f.app.db, f.repo.id, b)).toBe(true); | |
| 51 | finishRun(f.app.db, verify.id, { state: "ok", summary: "" }); | |
| 52 | expect(mainCheckRunning(f.app.db, f.repo.id, b)).toBe(false); | |
| 53 | startCheck(f, "verify-bisect"); | |
| 54 | expect(mainCheckRunning(f.app.db, f.repo.id, b)).toBe(true); | |
| 55 | }); | |
| 56 | ||
| 46 | 57 | test("a release waits while main's check runs, then swaps", async () => { |
| 47 | 58 | const f = await fixture(); |
| 48 | 59 | const b = f.repo.defaultBranch; |
new above
offline