Skip to content

Commit fda2fbe

Browse files
committed
test(ui-merge): the ui jobs' cache-save bounds and the ui-deps hand-off are pinned against the root ci.yml
Claude-Session: https://claude.ai/code/session_01XpG2CKzNjLujzcMmSxKCHy Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1b1ce14 commit fda2fbe

2 files changed

Lines changed: 272 additions & 5 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2714,9 +2714,10 @@ jobs:
27142714
#
27152715
# Scope: `turbo run build` steps only, i.e. `build` tasks. Since #22077
27162716
# that is this step plus the build steps of the Test Core shards, the
2717-
# dogfood shards, Temporal Conformance and lint.yml's three Type Check
2718-
# build lanes, each carrying the four lines below verbatim; the PINS
2719-
# paragraph at the end says what keeps that set honest. `test` /
2717+
# dogfood shards, Temporal Conformance, Build UI Deps and lint.yml's
2718+
# three Type Check build lanes, each carrying the four lines below
2719+
# verbatim; the PINS paragraph at the end says what keeps that set
2720+
# honest. `test` /
27202721
# `test:repo` stay off the remote: their cross-package inputs are
27212722
# hand-declared, and a wrong hash replayed from a remote reaches every
27222723
# run and cloud too. Build Docs forces execution and carries no
@@ -2756,8 +2757,8 @@ jobs:
27562757
# `remote:rw` branch above) when the cache is off; a read-only run only
27572758
# warns. Neither flag enters a task hash (83 of 83 identical with and
27582759
# without, `--dry=json`, turbo 2.11.5). The carriers that assert are this
2759-
# step, Test Core's closure and lint.yml's three Type Check lanes; the
2760-
# verdict table is the script header's.
2760+
# step, Test Core's closure, Build UI Deps and lint.yml's three Type
2761+
# Check lanes; the verdict table is the script header's.
27612762
#
27622763
# PINS, for every step that carries these four lines (#22077). Each
27632764
# carrier points back here.
Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
import { describe, expect, it } from 'vitest';
2+
import fs from 'node:fs';
3+
import { parse as parseYaml } from 'yaml';
4+
5+
import { rootCiPath, UI_JOBS } from './helpers/root-ci';
6+
7+
/**
8+
* objectui#6577 — cache bookkeeping voided a verdict the gate had already
9+
* recorded; objectstack#25869 — the root ui jobs that objectui's CI became.
10+
*
11+
* On 2026-08-26 the merge-group build of objectui#6571 was ejected from the
12+
* queue with `CI_FAILURE` while every substantive check passed. All 21 real
13+
* steps of objectui's `Type Check` job succeeded, and then `Post Turbo Cache`,
14+
* the save phase of `actions/cache@v6`, spent 13m09s inside the upload and was
15+
* still there when the job's ceiling fired. The job went `cancelled`, the merge
16+
* queue cannot tell `cancelled` from `failure`, and a pull request that had
17+
* passed was dequeued. The same job on the same head thirteen minutes earlier
18+
* saved its cache in ONE SECOND: a transient, not a property of the workflow.
19+
*
20+
* The ordering is the whole point: a job's verdict is recorded by its command
21+
* steps, and everything after them is bookkeeping, which must be bounded and
22+
* must not be able to speak for the code. objectui pinned that on its own
23+
* `type-check` job. The port to the objectstack monorepo's root `ci.yml`
24+
* (objectstack#25697) carried the jobs over on combined `actions/cache` steps
25+
* and unbounded saves, and objectstack#25879 retired this file with the nested
26+
* workflow it read; objectstack#25869 bounded the root jobs' saves and
27+
* restores it here, by path, over every ui job and `ui-deps`, the job that
28+
* builds the seven @objectstack packages once per run for the other four.
29+
*
30+
* Why this needs a pin at all — the fix is invisible when reverted. Folding a
31+
* split back into one `actions/cache` step, or dropping either key from a
32+
* save, restores the defect with nothing going red: the cache still works,
33+
* every run still passes, and the next transient upload stall cancels the next
34+
* green check (objectui#3009, #3181, #3494: "looks like enforcement, isn't").
35+
*
36+
* Deliberately NOT asserted: that a restore is bounded. A restore stall fails
37+
* BEFORE any verdict exists — a gate that did not run, which is honest.
38+
*/
39+
40+
interface Step {
41+
name?: string;
42+
uses?: string;
43+
run?: string;
44+
id?: string;
45+
if?: string;
46+
'timeout-minutes'?: number;
47+
'continue-on-error'?: boolean;
48+
with?: Record<string, string>;
49+
}
50+
interface Job {
51+
name?: string;
52+
needs?: string | string[];
53+
if?: string;
54+
'timeout-minutes'?: number;
55+
steps: Step[];
56+
}
57+
58+
const workflow = parseYaml(fs.readFileSync(rootCiPath, 'utf8')) as { jobs: Record<string, Job> };
59+
60+
/** The job that builds the seven packages once and hands them to the four. */
61+
const DEPS_JOB = 'ui-deps';
62+
const CACHE_JOBS = [DEPS_JOB, ...Object.values(UI_JOBS)];
63+
64+
/**
65+
* Each job's ceiling as derived beside it in ci.yml. A pin, not a restatement
66+
* of a derivation: moving one is a decision that re-derives it there and moves
67+
* it here in the same commit.
68+
* - type-check-ui: the value it was ported with; objectui's own rule here
69+
* was "does not rise" (#6577's ruled-out non-fix).
70+
* - lint-ui, build-e2e-ui: #25869 row F13, the ceiling comment above lint-ui.
71+
* - ui-deps: the derivation on that job.
72+
*/
73+
const CEILINGS: Record<string, number> = {
74+
[DEPS_JOB]: 25,
75+
[UI_JOBS.typeCheck]: 40,
76+
[UI_JOBS.lint]: 30,
77+
[UI_JOBS.buildE2e]: 25,
78+
};
79+
80+
function job(key: string): Job {
81+
const found = workflow.jobs[key];
82+
expect(found, `ci.yml must still define a \`${key}:\` job`).toBeDefined();
83+
// Non-vacuity: every assertion below scans this step list, so a parse that
84+
// collapsed it to nothing would make all of them pass while reading nothing.
85+
expect(found.steps.length, `the \`${key}\` job parsed to implausibly few steps`).toBeGreaterThan(5);
86+
return found;
87+
}
88+
89+
const isSave = (s: Step) => (s.uses ?? '').startsWith('actions/cache/save@');
90+
const isRestore = (s: Step) => (s.uses ?? '').startsWith('actions/cache/restore@');
91+
const BUILD_STEP = 'Build the @objectstack packages objectui consumes';
92+
const DOWNLOAD_STEP = 'Download the @objectstack packages objectui consumes';
93+
94+
describe('root ci.yml — the ui jobs\' cache saves are bounded and non-fatal (objectui#6577)', () => {
95+
it('reads the saves it is about', () => {
96+
// Non-vacuity for the per-save cases below: ui-deps saves the turbo seed
97+
// and the pnpm store; type-check-ui and lint-ui save their turbo seeds.
98+
const saves = CACHE_JOBS.flatMap((key) => job(key).steps.filter(isSave));
99+
expect(saves.length, 'the five ui jobs declare implausibly few cache saves').toBeGreaterThanOrEqual(4);
100+
expect(
101+
job(UI_JOBS.typeCheck).steps.filter((s) => isSave(s) && s.with?.path === '.turbo/cache').length,
102+
'the `type-check-ui` job must save `.turbo/cache` through exactly one `actions/cache/save` step',
103+
).toBe(1);
104+
});
105+
106+
it.each(CACHE_JOBS)('%s saves through MAIN-phase steps, never the combined action', (key) => {
107+
// Combined `actions/cache` declares `post: dist/save/index.js`: its save is
108+
// a step the RUNNER generates at job end, and no workflow syntax attaches
109+
// `timeout-minutes` or `continue-on-error` to a generated post step.
110+
// Splitting is the only way the keys below can exist at all.
111+
const combined = job(key)
112+
.steps.filter((s) => /^actions\/cache@/.test(s.uses ?? ''))
113+
.map((s) => s.name ?? '(unnamed)');
114+
expect(
115+
combined,
116+
`the \`${key}\` job is back on the combined \`actions/cache\` action:\n` +
117+
combined.map((n) => ` - ${n}`).join('\n') +
118+
'\n\nIts save runs as a runner-generated POST step, which cannot carry `timeout-minutes` or ' +
119+
'`continue-on-error`, so an upload stall runs the job into its ceiling and cancels a check ' +
120+
'that had already passed (objectui#6577). Use `actions/cache/restore` plus a bounded ' +
121+
'`actions/cache/save`.',
122+
).toEqual([]);
123+
});
124+
125+
it.each(CACHE_JOBS)('%s bounds every save, and no failed save speaks for the code', (key) => {
126+
for (const save of job(key).steps.filter(isSave)) {
127+
expect(
128+
typeof save['timeout-minutes'],
129+
`\`${key}\` › "${save.name}" must declare \`timeout-minutes\`: it is the only thing between a ` +
130+
'stalled upload and the job ceiling, and the ceiling reports `cancelled` (objectui#6577).',
131+
).toBe('number');
132+
expect(
133+
save['continue-on-error'],
134+
`\`${key}\` › "${save.name}" must declare \`continue-on-error: true\`. Without it the bound only ` +
135+
'trades a `cancelled` check for a red one, and a cache that failed to upload says nothing ' +
136+
'about the code under test.',
137+
).toBe(true);
138+
}
139+
});
140+
141+
it.each(CACHE_JOBS)('%s leaves the verdict at least as much ceiling as bookkeeping can take', (key) => {
142+
const j = job(key);
143+
const ceiling = j['timeout-minutes'];
144+
expect(typeof ceiling, `the \`${key}\` job must declare \`timeout-minutes\``).toBe('number');
145+
for (const save of j.steps.filter(isSave)) {
146+
expect(
147+
(save['timeout-minutes'] as number) * 2,
148+
`\`${key}\` › "${save.name}" may run for ${save['timeout-minutes']} of the job's ${ceiling} ` +
149+
'minutes; a bound that large can still starve the checking steps and cancel the job.',
150+
).toBeLessThanOrEqual(ceiling as number);
151+
}
152+
});
153+
154+
it.each(CACHE_JOBS)('%s saves AFTER every command step — bookkeeping follows the verdict', (key) => {
155+
const steps = job(key).steps;
156+
// The prune before a seed save is bookkeeping too, and a `run:` step; the
157+
// verdict is the last command that is neither.
158+
const lastCommand = steps
159+
.map((s) => s.run !== undefined && !/prune-turbo-cache\.mjs/.test(s.run))
160+
.lastIndexOf(true);
161+
expect(lastCommand, `the \`${key}\` job must still run commands`).toBeGreaterThan(-1);
162+
for (const save of steps.filter(isSave)) {
163+
expect(
164+
steps.indexOf(save),
165+
`\`${key}\` › "${save.name}" must come after the job's last command step, ` +
166+
`"${steps[lastCommand].name}": everything after it is bookkeeping, and that ordering is ` +
167+
'what makes the save safe to bound and safe to lose (objectui#6577).',
168+
).toBeGreaterThan(lastCommand);
169+
}
170+
});
171+
172+
it.each(CACHE_JOBS)('%s still caches what the combined step did', (key) => {
173+
// Same path, same key, and the save skipped on an exact hit of the
174+
// restore's primary key — which is how the combined action decided.
175+
const steps = job(key).steps;
176+
for (const save of steps.filter(isSave)) {
177+
const restores = steps.filter((s) => isRestore(s) && s.with?.path === save.with?.path);
178+
expect(restores.length, `\`${key}\` › "${save.name}" saves a path no step restores`).toBe(1);
179+
const [restore] = restores;
180+
expect(
181+
save.with?.key,
182+
`\`${key}\` › "${save.name}" must write the key "${restore.name}" asks for, or every run misses`,
183+
).toBe(restore.with?.key);
184+
expect(restore.id, `\`${key}\` › "${restore.name}" needs an \`id\` for the save's guard`).toBeTruthy();
185+
expect(
186+
save.if ?? '',
187+
`\`${key}\` › "${save.name}" must skip on an exact hit of the primary key — ` +
188+
`\`steps.${restore.id}.outputs.cache-hit != 'true'\`; without it every re-run re-uploads a ` +
189+
'cache that already exists.',
190+
).toContain(`steps.${restore.id}.outputs.cache-hit != 'true'`);
191+
}
192+
});
193+
194+
it.each(Object.entries(CEILINGS))('%s keeps its derived ceiling of %i minutes', (key, ceiling) => {
195+
// Raising a ceiling does not fix a hung save: the hang runs longer and the
196+
// check still reports `cancelled` (objectui#6577, objectui#7048). Moving
197+
// one is a deliberate act: re-derive it beside the job, move it here.
198+
expect(job(key)['timeout-minutes'], `the \`${key}\` job ceiling moved`).toBe(ceiling);
199+
});
200+
});
201+
202+
describe('root ci.yml — ui-deps builds the seven packages once for the ui jobs (objectstack#25869)', () => {
203+
const deps = () => job(DEPS_JOB);
204+
const step = (key: string, name: string) => {
205+
const found = job(key).steps.filter((s) => s.name === name);
206+
expect(found.length, `the \`${key}\` job must carry exactly one "${name}" step`).toBe(1);
207+
return found[0];
208+
};
209+
/** The build command with the carrier-only flags taken off. */
210+
const buildCommand = (run: string) =>
211+
run
212+
.replace(/\s*\\?\n?\s*--summarize --log-file=\S+/, '')
213+
.replace(/\s+/g, ' ')
214+
.trim();
215+
const upload = () => {
216+
const found = deps().steps.filter((s) => (s.uses ?? '').startsWith('actions/upload-artifact@'));
217+
expect(found.length, '`ui-deps` must upload exactly one artifact').toBe(1);
218+
return found[0];
219+
};
220+
221+
it('runs whenever any ui job runs', () => {
222+
// The union of the four conditions is Type Check UI's (and Build & E2E
223+
// UI's): Test UI and Lint UI run on a subset of it.
224+
expect(deps().if).toBe(job(UI_JOBS.typeCheck).if);
225+
expect(job(UI_JOBS.buildE2e).if).toBe(job(UI_JOBS.typeCheck).if);
226+
});
227+
228+
it('hands over the pruned turbo cache, only when the prune found the build', () => {
229+
const up = upload();
230+
expect(up.with?.path?.replace(/\/$/, '')).toBe('.turbo/cache');
231+
expect(up.if ?? '').toContain("steps.prune-turbo-cache.outputs.save == 'true'");
232+
const steps = deps().steps;
233+
expect(steps.indexOf(up), 'the upload must follow the build').toBeGreaterThan(
234+
steps.indexOf(step(DEPS_JOB, BUILD_STEP)),
235+
);
236+
});
237+
238+
it.each(Object.values(UI_JOBS))('%s waits for ui-deps without letting its result skip the job', (key) => {
239+
const j = job(key);
240+
const needs = Array.isArray(j.needs) ? j.needs : [j.needs];
241+
expect(needs).toContain(DEPS_JOB);
242+
// A job whose `if:` names no status function is SKIPPED when a job it
243+
// needs did not succeed. `!cancelled()` is what keeps a red or skipped
244+
// ui-deps from silently skipping a required ui check.
245+
expect(j.if ?? '', `the \`${key}\` job's \`if:\` must start with \`!cancelled()\``).toMatch(/^\$\{\{ !cancelled\(\) && /);
246+
});
247+
248+
it.each(Object.values(UI_JOBS))('%s downloads the build fail-open, before the step that replays it', (key) => {
249+
const download = step(key, DOWNLOAD_STEP);
250+
expect(download.uses ?? '').toMatch(/^actions\/download-artifact@/);
251+
expect(download.with?.name, 'the download must name the artifact ui-deps uploads').toBe(upload().with?.name);
252+
expect(download.with?.path).toBe('.turbo/cache');
253+
expect(
254+
download['continue-on-error'],
255+
'no artifact must mean "build cold", never a red or skipped ui check',
256+
).toBe(true);
257+
const steps = job(key).steps;
258+
expect(steps.indexOf(download)).toBeLessThan(steps.indexOf(step(key, BUILD_STEP)));
259+
});
260+
261+
it.each(Object.values(UI_JOBS))('%s builds the closure ui-deps built, so every task replays', (key) => {
262+
// Filters do not enter a task hash, but a filter one side lacks is a task
263+
// the other never built: it would build cold in every ui job again.
264+
expect(buildCommand(step(key, BUILD_STEP).run ?? '')).toBe(buildCommand(step(DEPS_JOB, BUILD_STEP).run ?? ''));
265+
});
266+
});

0 commit comments

Comments
 (0)