Public: anyone can read this; the crew can change it.
The release was held: could not cut the tag v0.7.741 #18299
Merged 5h 11m ago, live in production
torque/forge:torque/18298-the-release-was-held-could-not-cut-the-t → main 0 commits fork 3 threads · 3 unresolved
4 files
changed +82
−11
docs/ops/ROLL.md +5 −1
| @@ -153,7 +153,11 @@ runs the game agent tests (`test/game-agent-*.test.ts`) in `ubuntu:24.04` with | ||
| 153 | 153 | docker (the box's OS), refuses the tag if they fail, and records |
| 154 | 154 | `"agentTests": {"image", "files", "at"}` in the tag message (#18271). The |
| 155 | 155 | container installs curl and jq first (the one use of the network) and fails if a tool is missing, |
| 156 | so skipped tests cannot pass. The release keeper's own cut does not run them: when agent.sh | |
| 156 | so skipped tests cannot pass. When the box itself cannot be made (docker missing or | |
| 157 | down, apt or a tool failing: exit 70, 125, 126, 127) the tag is cut with | |
| 158 | `"agentUnchecked": true`, as the keeper's is, so an unattended tick is not held by | |
| 159 | docker (#18298); a red test still refuses. The release keeper's own cut does not run | |
| 160 | them: when agent.sh | |
| 157 | 161 | changed since the last tag it writes `"agentUnchecked": true` in the record instead. Both are |
| 158 | 162 | shown: `/releases.json` carries an `agentTests` sentence on such a release and the terminal's |
| 159 | 163 | changelog row repeats it. |
scripts/cut-release.ts +8 −4
| @@ -16,7 +16,8 @@ import { | ||
| 16 | 16 | agentTestFiles, |
| 17 | 17 | decideAgentTests, |
| 18 | 18 | dockerArgs, |
| 19 | withAgentTests, | |
| 19 | recordWithVerdict, | |
| 20 | runBox, | |
| 20 | 21 | } from "../src/release/agent_tests.ts"; |
| 21 | 22 | import { migrationFiles, NUMBERED } from "../src/core/schema.ts"; |
| 22 | 23 | import { loadCheckHint } from "../src/perf/baseline.ts"; |
| @@ -51,15 +52,18 @@ const verdict = decideAgentTests({ | ||
| 51 | 52 | now: Date.now, |
| 52 | 53 | run: (files) => { |
| 53 | 54 | console.error(`cut-release: ${AGENT_SCRIPT} changed; running ${files.length} game agent test files in ${AGENT_IMAGE}`); |
| 54 | return Bun.spawnSync(dockerArgs(root, process.execPath, files), { stdout: "inherit", stderr: "inherit" }).exitCode; | |
| 55 | return runBox( | |
| 56 | () => Bun.spawnSync(dockerArgs(root, process.execPath, files), { stdout: "inherit", stderr: "inherit" }).exitCode, | |
| 57 | (m) => console.error(`cut-release: docker could not be started: ${m}`), | |
| 58 | ); | |
| 55 | 59 | }, |
| 56 | 60 | }); |
| 57 | 61 | if ("refuse" in verdict) { |
| 58 | 62 | console.error(`cut-release: ${verdict.refuse}; no release cut`); |
| 59 | 63 | process.exit(1); |
| 60 | 64 | } |
| 61 | const agentTests = verdict.agentTests; | |
| 62 | const record = JSON.stringify(withAgentTests(recordFor(version, migrationFiles, NUMBERED), agentTests)); | |
| 65 | if (verdict.unchecked !== undefined) console.error(`cut-release: ${verdict.unchecked.why}; cutting the tag marked unchecked`); | |
| 66 | const record = JSON.stringify(recordWithVerdict(recordFor(version, migrationFiles, NUMBERED), verdict)); | |
| 63 | 67 | if (flag === "--tag") { |
| 64 | 68 | const made = Bun.spawnSync(["git", "tag", "--annotate", "--file=-", `v${version}`, "HEAD"], { |
| 65 | 69 | cwd: root, |
src/release/agent_tests.ts +43 −5
| @@ -35,10 +35,18 @@ export function agentTestFiles(names: readonly string[]): string[] { | ||
| 35 | 35 | */ |
| 36 | 36 | const BOX_SCRIPT = |
| 37 | 37 | "export DEBIAN_FRONTEND=noninteractive; " + |
| 38 | "apt-get update -qq >/dev/null && apt-get install -y -qq --no-install-recommends curl jq ca-certificates >/dev/null || exit 1; " + | |
| 39 | "for t in bash curl jq timeout sha256sum; do command -v $t >/dev/null || { echo \"missing $t\" >&2; exit 1; }; done; " + | |
| 38 | "apt-get update -qq >/dev/null && apt-get install -y -qq --no-install-recommends curl jq ca-certificates >/dev/null || exit 70; " + | |
| 39 | "for t in bash curl jq timeout sha256sum; do command -v $t >/dev/null || { echo \"missing $t\" >&2; exit 70; }; done; " + | |
| 40 | 40 | 'exec bun test "$@"'; |
| 41 | 41 | |
| 42 | /** | |
| 43 | * Exit codes that mean the box could not be made, not that a test failed: 70 from the script above | |
| 44 | * (apt or a tool missing), and docker's own 125 (daemon), 126 (cannot invoke) and 127 (not found). | |
| 45 | * The unattended tick has no one to fix its docker, so these cut the tag marked unchecked, as the | |
| 46 | * keeper's cut is, rather than holding every release behind them (#18298). | |
| 47 | */ | |
| 48 | export const BOX_UNAVAILABLE: readonly number[] = [70, 125, 126, 127]; | |
| 49 | ||
| 42 | 50 | /** |
| 43 | 51 | * The docker argv that runs `files` in the box's OS: the checkout read-only at /repo, the bun |
| 44 | 52 | * binary at /usr/local/bin/bun, a tmpfs for scratch. |
| @@ -71,13 +79,15 @@ export function parseAgentTests(raw: unknown): AgentTests | undefined { | ||
| 71 | 79 | /** |
| 72 | 80 | * What the standing rule decides: refuse the tag, or the record to carry (none when not needed). |
| 73 | 81 | */ |
| 74 | export type Verdict = { readonly refuse: string } | { readonly agentTests: AgentTests | undefined }; | |
| 82 | export type Verdict = | |
| 83 | | { readonly refuse: string } | |
| 84 | | { readonly agentTests: AgentTests | undefined; readonly unchecked?: { readonly why: string } }; | |
| 75 | 85 | |
| 76 | 86 | /** |
| 77 | 87 | * The rule as one decision. `changed` is the paths changed since the last tag, or undefined when |
| 78 | 88 | * there is no earlier tag (the agent counts as changed). Nothing runs unless the tag is being |
| 79 | * cut (`tag`) and the agent changed; a red run refuses and records nothing. `run` gets the test | |
| 80 | * files and answers the exit code. | |
| 89 | * cut (`tag`) and the agent changed; a red run refuses and records nothing; a box that could not be | |
| 90 | * made records `unchecked`. `run` gets the test files and answers the exit code. | |
| 81 | 91 | */ |
| 82 | 92 | export function decideAgentTests(input: { |
| 83 | 93 | readonly changed: readonly string[] | undefined; |
| @@ -90,6 +100,9 @@ export function decideAgentTests(input: { | ||
| 90 | 100 | if (!input.tag || !changed) return { agentTests: undefined }; |
| 91 | 101 | if (input.files.length === 0) return { refuse: `${AGENT_SCRIPT} changed and no game agent test file was found` }; |
| 92 | 102 | const code = input.run(input.files); |
| 103 | if (BOX_UNAVAILABLE.includes(code)) { | |
| 104 | return { agentTests: undefined, unchecked: { why: `the box for the game agent tests could not be made in ${AGENT_IMAGE} (exit ${code})` } }; | |
| 105 | } | |
| 93 | 106 | if (code !== 0) return { refuse: `the game agent tests failed in ${AGENT_IMAGE} (exit ${code})` }; |
| 94 | 107 | return { agentTests: { image: AGENT_IMAGE, files: input.files.length, at: input.now() } }; |
| 95 | 108 | } |
| @@ -109,3 +122,28 @@ export function agentWords(r: { agentTests?: AgentTests; agentUnchecked?: boolea | ||
| 109 | 122 | export function uncheckedMark(changed: readonly string[] | undefined): { agentUnchecked?: true } { |
| 110 | 123 | return changed === undefined || touchesAgent(changed) ? { agentUnchecked: true } : {}; |
| 111 | 124 | } |
| 125 | ||
| 126 | /** | |
| 127 | * The record a verdict that did not refuse carries: the run, or `agentUnchecked` when the box could | |
| 128 | * not be made. | |
| 129 | */ | |
| 130 | export function recordWithVerdict<T extends object>( | |
| 131 | record: T, | |
| 132 | verdict: { readonly agentTests: AgentTests | undefined; readonly unchecked?: { readonly why: string } }, | |
| 133 | ): T & { agentTests?: AgentTests; agentUnchecked?: true } { | |
| 134 | const withRun = withAgentTests(record, verdict.agentTests); | |
| 135 | return verdict.unchecked === undefined ? withRun : { ...withRun, agentUnchecked: true }; | |
| 136 | } | |
| 137 | ||
| 138 | /** | |
| 139 | * Runs the box with `spawn` (answering an exit code); a spawn that throws, docker not there, | |
| 140 | * is 127. | |
| 141 | */ | |
| 142 | export function runBox(spawn: () => number, onError: (message: string) => void): number { | |
| 143 | try { | |
| 144 | return spawn(); | |
| 145 | } catch (e) { | |
| 146 | onError(e instanceof Error ? e.message : String(e)); | |
| 147 | return 127; | |
| 148 | } | |
| 149 | } |
test/release-agent-tests.test.ts +26 −1
| @@ -8,7 +8,7 @@ import { serve } from "../src/http/server.ts"; | ||
| 8 | 8 | import { mkdtemp } from "node:fs/promises"; |
| 9 | 9 | import { tmpdir } from "node:os"; |
| 10 | 10 | import { join } from "node:path"; |
| 11 | import { AGENT_IMAGE, uncheckedMark, agentWords, decideAgentTests, agentTestFiles, dockerArgs, parseAgentTests, touchesAgent, withAgentTests } from "../src/release/agent_tests.ts"; | |
| 11 | import { AGENT_IMAGE, uncheckedMark, agentWords, decideAgentTests, agentTestFiles, dockerArgs, parseAgentTests, recordWithVerdict, runBox, touchesAgent, withAgentTests } from "../src/release/agent_tests.ts"; | |
| 12 | 12 | import { parseRecord, setTagged } from "../src/release/shipped.ts"; |
| 13 | 13 | |
| 14 | 14 | const ran = { image: AGENT_IMAGE, files: 6, at: 1_700_000_000_000 }; |
| @@ -39,6 +39,31 @@ describe("the rule: when the tests run and what refuses", () => { | ||
| 39 | 39 | expect("refuse" in r.verdict && r.verdict.refuse).toContain("exit 1"); |
| 40 | 40 | expect("agentTests" in r.verdict).toBe(false); |
| 41 | 41 | }); |
| 42 | test("a box that could not be made cuts the tag unchecked instead of holding it", () => { | |
| 43 | for (const code of [70, 125, 126, 127]) { | |
| 44 | const v = decide(["src/games/agent.sh"], true, code).verdict; | |
| 45 | expect("refuse" in v).toBe(false); | |
| 46 | expect("agentTests" in v && v.agentTests).toBeUndefined(); | |
| 47 | expect("unchecked" in v && v.unchecked?.why).toContain(`exit ${code}`); | |
| 48 | } | |
| 49 | expect("refuse" in decide(["src/games/agent.sh"], true, 2).verdict).toBe(true); | |
| 50 | }); | |
| 51 | test("an unchecked verdict yields agentUnchecked and no agentTests; a run yields agentTests", () => { | |
| 52 | const base = { version: "1.2.3", migrations: 4 }; | |
| 53 | const un = recordWithVerdict(base, { agentTests: undefined, unchecked: { why: "x" } }); | |
| 54 | expect(un).toEqual({ ...base, agentUnchecked: true }); | |
| 55 | expect("agentTests" in un).toBe(false); | |
| 56 | expect(parseRecord(JSON.stringify(un))?.agentUnchecked).toBe(true); | |
| 57 | expect(recordWithVerdict(base, { agentTests: ran })).toEqual({ ...base, agentTests: ran }); | |
| 58 | expect(recordWithVerdict(base, { agentTests: undefined })).toEqual(base); | |
| 59 | }); | |
| 60 | test("a spawn that throws is exit 127 and says why; otherwise its code passes through", () => { | |
| 61 | const said: string[] = []; | |
| 62 | expect(runBox(() => { throw new Error("ENOENT docker"); }, (m) => said.push(m))).toBe(127); | |
| 63 | expect(said).toEqual(["ENOENT docker"]); | |
| 64 | expect(runBox(() => 3, () => said.push("no"))).toBe(3); | |
| 65 | expect(said).toHaveLength(1); | |
| 66 | }); | |
| 42 | 67 | test("changed without --tag runs nothing", () => { |
| 43 | 68 | const r = decide(["src/games/agent.sh"], false, 1); |
| 44 | 69 | expect(r.calls).toEqual([]); |
new above
offline
Rewrap this very long line to match the paragraph around it.