Skip to content

Commit b5a16ae

Browse files
committed
ci(ui): start the Test UI shards when a ui-consumed package changes
The shards read the `ui` filter output alone, so a diff confined to one of the seven packages ui consumes (packages/lint/**, spec, ...) never ran a ui test, though the affected-test selector already answers mode=full for it. They now start on `ui || ui_consumers`, the shape Build UI Deps, Type Check UI and Build & E2E UI read; the Test UI aggregate explains a skip only when both outputs said false. A select-affected-tests pin holds the shards' if: to every outer package the selector turns full for. Claude-Session: https://claude.ai/code/session_01QUs3BsPpUdAGmm7wLdoKaK Co-authored-by: Claude <noreply@anthropic.com>
1 parent ea74ebf commit b5a16ae

3 files changed

Lines changed: 102 additions & 17 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,16 @@ jobs:
173173
# the objectui skill bundle; see the filter below);
174174
# ui_consumers — one of the seven packages objectui installs from this
175175
# tree changed, so the Console is compiled (Type Check
176-
# UI) and built (Build & E2E UI) against the new shape in
177-
# the PR that moves it;
176+
# UI), built (Build & E2E UI) and tested (Test UI, since
177+
# objectstack#28220) against the new shape in the PR
178+
# that moves it;
178179
# ui_tree — `ui/package.json` exists in this checkout.
179180
# On merge_group `ui` and `ui_consumers` come from the queue diff
180181
# (objectstack#25867): an entry whose merged diff against
181182
# `merge_group.base_sha` touches no ui path and none of the seven
182183
# packages skips the five ui jobs, exactly as the same diff does on its
183-
# PR head; an entry that touches one runs them. If the step fails (the
184+
# PR head; an entry that touches one runs them (Lint UI reads `ui`
185+
# alone, so one of the seven by itself does not start it). If the step fails (the
184186
# base cannot be fetched, the diff errors), it is `continue-on-error`
185187
# there, its outputs are empty and `|| 'true'` runs every ui job.
186188
#
@@ -557,9 +559,12 @@ jobs:
557559
# skipped on the PR and in the queue alike.
558560
- 'package.json'
559561
# The seven packages objectui installs from this tree (the set its
560-
# `.objectstack-pin` used to pack). A change here compiles and builds
561-
# the Console in the same PR — the check the retired Spec Shape Gate
562-
# ran hourly against a clone of objectui main.
562+
# `.objectstack-pin` used to pack). A change here compiles, builds
563+
# and tests the Console in the same PR — the check the retired Spec
564+
# Shape Gate ran hourly against a clone of objectui main. Test UI
565+
# reads this list since objectstack#28220; its selector turns full
566+
# for any of these packages, and its test pins this list against
567+
# the package graph the selector reads.
563568
ui_consumers:
564569
- 'packages/spec/**'
565570
- 'packages/client/**'
@@ -3727,10 +3732,25 @@ jobs:
37273732
# non-documentation root file, `patches/`, one of the seven packages the
37283733
# `ui_consumers` filter names). The selector's header states the rules and
37293734
# what it does not see; the full battery on `main` is the backstop.
3735+
#
3736+
# ── Test UI: when the shards start (objectstack#28220, ruling A) ─────────
3737+
# On `ui` OR `ui_consumers`, the shape Build UI Deps, Type Check UI and
3738+
# Build & E2E UI already read. Until this entry the shards read `ui` alone,
3739+
# so a diff confined to one of the seven packages compiled and built the
3740+
# Console against the new shape and never ran a ui test that pins it: the
3741+
# selector above already answered `mode=full` for such a diff, but the job
3742+
# it answers in never started. The queue build of objectstack#28192
3743+
# (packages/lint/** + packages/metadata-protocol/**, run 41091107812)
3744+
# skipped all sixteen shards; the next queue build that started them
3745+
# (objectstack#28197) failed a ui test that imports @objectstack/lint, and a
3746+
# bystander was ejected for it. Which files run stays the selector's answer.
3747+
# `ui/scripts/__tests__/select-affected-tests.test.ts` holds the join: every
3748+
# package outside ui/ the selector turns full for is covered by a list this
3749+
# `if:` reads. Lint UI keeps `ui` alone (its eslint reads none of the seven).
37303750
test-ui:
37313751
name: Test UI (${{ matrix.shard }}/16)
37323752
needs: [filter, ui-deps]
3733-
if: ${{ !cancelled() && needs.filter.outputs.ui_tree != 'false' && needs.filter.outputs.ui != 'false' }}
3753+
if: ${{ !cancelled() && needs.filter.outputs.ui_tree != 'false' && (needs.filter.outputs.ui != 'false' || needs.filter.outputs.ui_consumers != 'false') }}
37343754
runs-on: ubuntu-latest
37353755
timeout-minutes: 30
37363756
permissions:
@@ -3895,7 +3915,8 @@ jobs:
38953915
#
38963916
# The verdict reads the matrix rollup `needs.test-ui.result`, and only
38973917
# `success` passes, with one exception: `skipped`, when `filter` concluded
3898-
# `success` AND said the diff reaches no ui path (the shards' own `if:`).
3918+
# `success` AND said the diff reaches no ui path and none of the seven
3919+
# packages ui consumes (the shards' own `if:`, objectstack#28220).
38993920
# That is #4928's skipped-only-when-filter-succeeded guard, and it makes a
39003921
# queue build or PR that touches no ui path read green here the way Lint
39013922
# UI and Build & E2E UI read `skipped` there. Everything else is red:
@@ -3926,17 +3947,18 @@ jobs:
39263947
OS_FILTER_RESULT: ${{ needs.filter.result }}
39273948
OS_UI_TREE: ${{ needs.filter.outputs.ui_tree }}
39283949
OS_UI: ${{ needs.filter.outputs.ui }}
3950+
OS_UI_CONSUMERS: ${{ needs.filter.outputs.ui_consumers }}
39293951
run: |
3930-
echo "Test UI (k/16) rollup: '$OS_TEST_UI_RESULT'; filter: '$OS_FILTER_RESULT' (ui_tree='$OS_UI_TREE', ui='$OS_UI')."
3952+
echo "Test UI (k/16) rollup: '$OS_TEST_UI_RESULT'; filter: '$OS_FILTER_RESULT' (ui_tree='$OS_UI_TREE', ui='$OS_UI', ui_consumers='$OS_UI_CONSUMERS')."
39313953
case "$OS_TEST_UI_RESULT" in
39323954
success)
39333955
echo "✓ Test UI: every shard concluded success."
39343956
;;
39353957
skipped)
3936-
if [ "$OS_FILTER_RESULT" = 'success' ] && { [ "$OS_UI_TREE" = 'false' ] || [ "$OS_UI" = 'false' ]; }; then
3937-
echo "✓ Test UI: the shards were skipped because filter found no ui path in this diff."
3958+
if [ "$OS_FILTER_RESULT" = 'success' ] && { [ "$OS_UI_TREE" = 'false' ] || { [ "$OS_UI" = 'false' ] && [ "$OS_UI_CONSUMERS" = 'false' ]; }; }; then
3959+
echo "✓ Test UI: the shards were skipped because filter found no ui path and no ui-consumed package in this diff."
39383960
else
3939-
echo "::error title=Test UI::the Test UI shards were skipped, but filter (result '$OS_FILTER_RESULT', ui_tree='$OS_UI_TREE', ui='$OS_UI') does not explain the skip. A skip passes only when filter succeeded and said the diff reaches no ui path (#4928)."
3961+
echo "::error title=Test UI::the Test UI shards were skipped, but filter (result '$OS_FILTER_RESULT', ui_tree='$OS_UI_TREE', ui='$OS_UI', ui_consumers='$OS_UI_CONSUMERS') does not explain the skip. A skip passes only when filter succeeded and said the diff reaches no ui path and none of the seven packages ui consumes (#4928)."
39403962
exit 1
39413963
fi
39423964
;;

‎ui/scripts/__tests__/helpers/root-ci.ts‎

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,45 @@ export function triggerBlock(ci: string): string {
125125
* list, the reading that would make every "is not hidden" pin vacuous.
126126
*/
127127
export function uiFilterGlobs(ci: string): string[] {
128+
return filterGlobs(ci, 'ui');
129+
}
130+
131+
/**
132+
* The globs of one named list of the `filter` job's paths filter (`ui`,
133+
* `ui_consumers`, `core`, ...), read the way `uiFilterGlobs` reads `ui:`.
134+
* Throws when the filter declares no such list or it lists no globs.
135+
*/
136+
export function filterGlobs(ci: string, name: string): string[] {
128137
const filter = jobBlock(ci, 'filter');
129138
const lines = filter.split('\n');
130-
const at = lines.findIndex((line) => /^ +ui:[ \t]*$/.test(line));
131-
if (at === -1) throw new Error(`${rootCiPath}: the \`filter\` job declares no \`ui:\` paths filter`);
139+
const at = lines.findIndex((line) => new RegExp(`^ +${name}:[ \\t]*$`).test(line));
140+
if (at === -1) throw new Error(`${rootCiPath}: the \`filter\` job declares no \`${name}:\` paths filter`);
132141
const indent = lines[at].search(/\S/);
133142
const globs: string[] = [];
134143
for (const line of lines.slice(at + 1)) {
135144
if (/^\s*(#.*)?$/.test(line)) continue;
136145
if (line.search(/\S/) <= indent) break;
137146
const m = line.match(/^\s+-\s+'([^']+)'\s*$/);
138-
if (!m) throw new Error(`${rootCiPath}: cannot read the \`ui:\` filter entry ${JSON.stringify(line)}`);
147+
if (!m) throw new Error(`${rootCiPath}: cannot read the \`${name}:\` filter entry ${JSON.stringify(line)}`);
139148
globs.push(m[1]);
140149
}
141-
if (globs.length === 0) throw new Error(`${rootCiPath}: the \`ui:\` paths filter lists no globs`);
150+
if (globs.length === 0) throw new Error(`${rootCiPath}: the \`${name}:\` paths filter lists no globs`);
142151
return globs;
143152
}
144153

154+
/**
155+
* The `filter` outputs a job's `if:` starts it on: every
156+
* `needs.filter.outputs.<o> != 'false'` it spells, in order. Throws when the
157+
* job carries no `if:` line or the line reads no filter output.
158+
*/
159+
export function jobFilterOutputs(ci: string, key: string): string[] {
160+
const line = jobBlock(ci, key).match(/^ {4}if: (.+)$/m);
161+
if (!line) throw new Error(`${rootCiPath}: the \`${key}\` job carries no one-line \`if:\``);
162+
const outputs = [...line[1].matchAll(/needs\.filter\.outputs\.([A-Za-z_][\w-]*) != 'false'/g)].map((m) => m[1]);
163+
if (outputs.length === 0) throw new Error(`${rootCiPath}: the \`${key}\` job's \`if:\` reads no filter output`);
164+
return outputs;
165+
}
166+
145167
/** A path relative to this tree, as the root workflow's filters see it (`ui/<path>`). */
146168
export function repoPath(uiRelative: string): string {
147169
return `${nestedPrefix()}${uiRelative}`;

‎ui/scripts/__tests__/select-affected-tests.test.ts‎

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,18 @@ import {
2020
trackedFiles,
2121
} from '../select-affected-tests.mjs';
2222
import { shardTotal } from '../../../scripts/ci-shard-matrix.mjs';
23-
import { jobBlock, rootCi, triggerBlock, UI_JOBS, uiRun, withoutComments } from './helpers/root-ci';
23+
import { workspaceRoot } from '../workspace-root.mjs';
24+
import {
25+
filterGlobs,
26+
globMatches,
27+
jobBlock,
28+
jobFilterOutputs,
29+
rootCi,
30+
triggerBlock,
31+
UI_JOBS,
32+
uiRun,
33+
withoutComments,
34+
} from './helpers/root-ci';
2435

2536
/**
2637
* objectui#12214 — the affected-test selector behind the two-speed `Test` lane.
@@ -447,6 +458,36 @@ describe("the root ci.yml's Test UI job wires the selector fail-open (objectui#1
447458
expect(job).toMatch(/uses: actions\/checkout@\S+\n\s+with:\n\s+fetch-depth: 0\n/);
448459
});
449460

461+
// objectstack#28220: the selector answered `mode=full` for a diff confined
462+
// to packages/lint/**, but the shards read only the `ui` output, so the job
463+
// that answer lives in never started and a ui test pinning a lint value went
464+
// unrun until a bystander's queue build. The selector and the job's `if:`
465+
// answer one question from two ends, so this holds them together: every
466+
// workspace package outside this tree that the selector turns full for (read
467+
// from the package graph, never listed here) must match a glob of a filter
468+
// list the shards' `if:` reads.
469+
it('starts the shards on every package outside the tree the selector turns full for (objectstack#28220)', () => {
470+
const ci = rootCi();
471+
const wsRoot = workspaceRoot(repoRoot);
472+
const manifests = trackedFiles(wsRoot).filter(
473+
(rel) => rel.includes('/') && rel.endsWith('/package.json') && !rel.startsWith('ui/') && !rel.startsWith('patches/'),
474+
);
475+
const full = outsideTreeReasons({ root: repoRoot, outside: manifests }).map((reason) => reason.slice(0, reason.indexOf(': ')));
476+
// The live graph reaches the seven packages the root `ui_consumers` list names.
477+
expect(full.length, 'the selector turned full for no outer package: the graph read nothing').toBeGreaterThanOrEqual(7);
478+
expect(full).toContain('packages/lint/package.json');
479+
480+
const outputs = jobFilterOutputs(ci, UI_JOBS.test).filter((o) => o !== 'ui_tree');
481+
const covered = (globs: string[]) => full.filter((rel) => globs.some((glob) => globMatches(glob, rel)));
482+
const globs = outputs.flatMap((o) => filterGlobs(ci, o));
483+
expect(
484+
full.filter((rel) => !covered(globs).includes(rel)),
485+
`a package the selector runs every ui test for matches none of the lists \`${UI_JOBS.test}\` starts on (${outputs.join(', ')})`,
486+
).toEqual([]);
487+
// Able to say no: the shards' old condition, \`ui\` alone, misses packages/lint.
488+
expect(covered(filterGlobs(ci, 'ui'))).not.toContain('packages/lint/package.json');
489+
});
490+
450491
it('keeps the matrix width and the full-suite command for the full battery', () => {
451492
// The width is the job's own `shard:` list, read by the monorepo's one reader of
452493
// shard sizes (it refuses any other spelling); every `/N` the job's run step

0 commit comments

Comments
 (0)