Public: anyone can read this; the crew can change it.

The release was held: could not cut the tag v0.7.741 #18299

opened this in answer to

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

  • Merged. torque/18298-the-release-was-held-could-not-cut-the-t was merged into main as 4d3523d.

Review

Sign in to review this change.
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
153153 docker (the box's OS), refuses the tag if they fail, and records
154154 `"agentTests": {"image", "files", "at"}` in the tag message (#18271). The
155155 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
outdated

Rewrap this very long line to match the paragraph around it.

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
157161 changed since the last tag it writes `"agentUnchecked": true` in the record instead. Both are
158162 shown: `/releases.json` carries an `agentTests` sentence on such a release and the terminal's
159163 changelog row repeats it.
scripts/cut-release.ts +8 −4
@@ -16,7 +16,8 @@ import {
1616 agentTestFiles,
1717 decideAgentTests,
1818 dockerArgs,
19 withAgentTests,
19 recordWithVerdict,
20 runBox,
2021 } from "../src/release/agent_tests.ts";
2122 import { migrationFiles, NUMBERED } from "../src/core/schema.ts";
2223 import { loadCheckHint } from "../src/perf/baseline.ts";
@@ -51,15 +52,18 @@ const verdict = decideAgentTests({
5152 now: Date.now,
5253 run: (files) => {
5354 console.error(`cut-release: ${AGENT_SCRIPT} changed; running ${files.length} game agent test files in ${AGENT_IMAGE}`);
outdated

This try/catch maps a throw to 127 but no test covers it. Move into src/release/agent_tests.ts as a function taking the spawn and test it with one that throws.

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 );
5559 },
5660 });
5761 if ("refuse" in verdict) {
5862 console.error(`cut-release: ${verdict.refuse}; no release cut`);
5963 process.exit(1);
6064 }
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));
6367 if (flag === "--tag") {
6468 const made = Bun.spawnSync(["git", "tag", "--annotate", "--file=-", `v${version}`, "HEAD"], {
6569 cwd: root,
outdated

The unchecked record is assembled here, outside the tested module. Build it in agent_tests.ts from the verdict and assert agentUnchecked: true and no agentTests in a test.

src/release/agent_tests.ts +43 −5
@@ -35,10 +35,18 @@ export function agentTestFiles(names: readonly string[]): string[] {
3535 */
3636 const BOX_SCRIPT =
3737 "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; " +
4040 'exec bun test "$@"';
4141
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
4250 /**
4351 * The docker argv that runs `files` in the box's OS: the checkout read-only at /repo, the bun
4452 * binary at /usr/local/bin/bun, a tmpfs for scratch.
@@ -71,13 +79,15 @@ export function parseAgentTests(raw: unknown): AgentTests | undefined {
7179 /**
7280 * What the standing rule decides: refuse the tag, or the record to carry (none when not needed).
7381 */
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 } };
7585
7686 /**
7787 * The rule as one decision. `changed` is the paths changed since the last tag, or undefined when
7888 * 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.
8191 */
8292 export function decideAgentTests(input: {
8393 readonly changed: readonly string[] | undefined;
@@ -90,6 +100,9 @@ export function decideAgentTests(input: {
90100 if (!input.tag || !changed) return { agentTests: undefined };
91101 if (input.files.length === 0) return { refuse: `${AGENT_SCRIPT} changed and no game agent test file was found` };
92102 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 }
93106 if (code !== 0) return { refuse: `the game agent tests failed in ${AGENT_IMAGE} (exit ${code})` };
94107 return { agentTests: { image: AGENT_IMAGE, files: input.files.length, at: input.now() } };
95108 }
@@ -109,3 +122,28 @@ export function agentWords(r: { agentTests?: AgentTests; agentUnchecked?: boolea
109122 export function uncheckedMark(changed: readonly string[] | undefined): { agentUnchecked?: true } {
110123 return changed === undefined || touchesAgent(changed) ? { agentUnchecked: true } : {};
111124 }
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";
88 import { mkdtemp } from "node:fs/promises";
99 import { tmpdir } from "node:os";
1010 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";
1212 import { parseRecord, setTagged } from "../src/release/shipped.ts";
1313
1414 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", () => {
3939 expect("refuse" in r.verdict && r.verdict.refuse).toContain("exit 1");
4040 expect("agentTests" in r.verdict).toBe(false);
4141 });
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 });
4267 test("changed without --tag runs nothing", () => {
4368 const r = decide(["src/games/agent.sh"], false, 1);
4469 expect(r.calls).toEqual([]);

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs