mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-17 05:41:50 +01:00
gstack-evidence: sum bun --shard processes in a lane's tests_ran; docs: dispatch-carry warning and record-ci recheck order (GBEV-3, GSTA-258 L6 follow-up)
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
0f6ad9d2b6
commit
e4e35467cb
4 files changed
+58
-13
No files matched your search
+20
-9
@@ -37,7 +37,9 @@
|
||||
* the tail is the stdout tail then the stderr tail, so a line's position says
|
||||
* nothing about when it was printed across streams, and bun's own counts (on
|
||||
* stderr) would otherwise outrank a 10k-test run whichever of the two ran
|
||||
* first. Any summary when it did not speak follows the last-summary-wins rule;
|
||||
* first. Any summary when it did not speak follows the last-summary-wins rule,
|
||||
* except that a complete set of `bun test --shard=i/N` processes ending the log
|
||||
* is summed (GBEV-3);
|
||||
* anything else is "unknown".
|
||||
* Three states, never merged:
|
||||
* a count, 0 (ZERO-RUN, graded like STALE by `check`) and unknown (non-blocking).
|
||||
@@ -169,7 +171,10 @@ const count = (text: string, word: string): number => Number(new RegExp(`(\\d+)
|
||||
|
||||
/**
|
||||
* Bun: the last "Ran N tests across M files" block; executed = its " N pass" +
|
||||
* " N fail" lines. Bun always prints that counts block (" 0 pass" / " 0 fail"
|
||||
* " N fail" lines. When that block ends a `bun test --shard=i/N` process (bun's
|
||||
* "--shard=i/N: running" line since the previous block), the blocks of the N
|
||||
* distinct shards that end the log are summed (a sharded runner prints every
|
||||
* shard, GBEV-3); an incomplete or repeated shard set counts the last block alone. Bun always prints that counts block (" 0 pass" / " 0 fail"
|
||||
* even for an all-skip or empty run), so a terminal line with no " N pass"
|
||||
* above it is a line gstack's quiet shard runner forwarded (it forwards the
|
||||
* terminal line without the " N pass" line), not a bun summary:
|
||||
@@ -186,7 +191,9 @@ async function bunTestsRan(lines: string[]): Promise<{ at: number; ran: number }
|
||||
} catch {
|
||||
warn("shard-engine classifier not importable; using the built-in bun summary parser");
|
||||
}
|
||||
for (let i = lines.length - 1; i >= 0; i--) {
|
||||
const blocks: { at: number; ran: number; shard?: string }[] = [];
|
||||
let since = 0;
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
if (!isTerminal(lines[i])) continue;
|
||||
let pass: number | null = null;
|
||||
let fail = 0;
|
||||
@@ -197,13 +204,17 @@ async function bunTestsRan(lines: string[]): Promise<{ at: number; ran: number }
|
||||
if (p) pass = Number(p[1]);
|
||||
if (f) fail = Number(f[1]);
|
||||
}
|
||||
if (pass === null) {
|
||||
if (/^Ran 0 tests? across/.test(lines[i])) return { at: i, ran: 0 };
|
||||
continue;
|
||||
}
|
||||
return { at: i, ran: pass + fail };
|
||||
const shard = lines.slice(since, i).map((l) => /^--shard=(\d+\/\d+): running /.exec(l)?.[1]).findLast(Boolean);
|
||||
since = i + 1;
|
||||
if (pass !== null) blocks.push({ at: i, ran: pass + fail, shard });
|
||||
else if (/^Ran 0 tests? across/.test(lines[i])) blocks.push({ at: i, ran: 0 });
|
||||
}
|
||||
return null;
|
||||
const last = blocks.at(-1);
|
||||
if (!last) return null;
|
||||
const total = Number(last.shard?.split("/")[1] ?? 1);
|
||||
const set = blocks.slice(-total);
|
||||
const complete = total > 1 && set.length === total && new Set(set.map((b) => b.shard)).size === total && set.every((b) => b.shard?.endsWith(`/${total}`));
|
||||
return { at: last.at, ran: complete ? set.reduce((n, b) => n + b.ran, 0) : last.ran };
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
- A lane whose command runs several `bun test --shard=i/N` processes now records the sum of the shards' counts, not the last shard's (GBEV-3, gbrain-evals#317: 3336 recorded against 6,095 run across 2 shards). The sum needs one block from each of the N distinct shards at the end of the log; an incomplete or repeated set records the last summary as before, so a command that runs a suite twice still reports its last run.
|
||||
- docs/pregate.md#dispatch-carry warns that a `workflow_dispatch` run reports under the same job names on the head commit, so without strict branch protection a green dispatch run can hide a red merge-commit check. It recommends strict protection or distinct job names for dispatch runs, and notes that gstack's own merge trains test the merged tree.
|
||||
- docs/pregate.md#skipped-files names the order of record-ci's checks after a skipped-file remainder, including the final `tree_changed` recheck.
|
||||
|
||||
### Tests
|
||||
- `test/evidence.test.ts`: two `--shard=i/2` processes in one log record 6095, and an incomplete or repeated shard set records the last summary. The sum case fails without the change (it recorded 3336).
|
||||
+19
-4
@@ -762,10 +762,12 @@ once:
|
||||
such as `"per_file": "bun test --timeout=30000 {files}"`, the same form as the
|
||||
tests stage's `runner`). That run is recorded under `<label>.skipped`, the
|
||||
`LANE:` line adds `skipped_here=<n> file(s) tests_ran_here=<n>`, and the CI row
|
||||
is written only after it passes with a test count above zero and every carried
|
||||
run still stands (`run_changed` otherwise). A failure there is
|
||||
`skipped_failed` and a run of zero tests is `skipped_zero_run`; either way the
|
||||
whole lane runs here. An entry with no `per_file` refuses as
|
||||
is written only after four checks pass. In order, they are the remainder's
|
||||
exit (`skipped_failed`), its test count above zero (`skipped_zero_run`), every
|
||||
carried run again (`run_changed`), and the working tree once more
|
||||
(`tree_changed`, for an edit made during those checks). An edit made while the
|
||||
remainder itself runs leaves its ledger row without a tree, so it shows as
|
||||
`skipped_zero_run`. Any of these refusals runs the whole lane here. An entry with no `per_file` refuses as
|
||||
`inventory_skipped`, naming the files, and the lane runs here whole. A partly
|
||||
skipped file ran tests and stays covered. gstack's own Free Tests writer does
|
||||
not emit the list yet: it starts in the same follow-up pull request that
|
||||
@@ -1017,6 +1019,19 @@ run here. The macOS and Windows lane
|
||||
obligations still clear with `gstack-pregate clear --remote <lane> --run-url
|
||||
<url>` from their CI runs.
|
||||
|
||||
<a id="dispatch-carry"></a>**A dispatched run can hide a red merge commit.** A
|
||||
`workflow_dispatch` run reports its checks on the head commit under the same
|
||||
job names as the `pull_request` run, and GitHub counts the newest check of a
|
||||
name. So a green dispatch run of HEAD's own tree can satisfy a required check
|
||||
whose `pull_request` run failed on the merge commit, and without strict branch
|
||||
protection ("Require branches to be up to date before merging") the pull
|
||||
request can merge with that failure hidden (GBEV-3). Turn on strict protection
|
||||
for the base branch, or give dispatch runs distinct job names (for example a
|
||||
job `name:` that includes `github.event_name`), so a dispatch run never stands
|
||||
in for the required `pull_request` check. gstack's own merge trains test the
|
||||
merged tree before they merge, so gstack is covered; a repo that merges
|
||||
without a train is not.
|
||||
|
||||
**/ship lanes: `ship_lanes_from`.** A lane carries only when the base branch's
|
||||
`.gstack/pregate.json` maps its exact command (the evidence ledger binds the
|
||||
command's sha256; a label alone never carries) to the profiles whose runs carry
|
||||
|
||||
@@ -495,6 +495,19 @@ describe('gstack-evidence tests_ran — zero-run green is a third state, never m
|
||||
expect(chk.stdout).not.toContain('STALE');
|
||||
});
|
||||
|
||||
test('bun --shard processes in one log record their sum; an incomplete or repeated shard set falls back to the last summary', () => {
|
||||
// GBEV-3 (gbrain-evals#317): scripts/test-shards.ts prints each `bun test --shard=i/N` process's whole output, then its own
|
||||
// total. The lane recorded 3336 (the last shard) against 6095 run across 2 shards.
|
||||
const shard = (i: number, pass: number, skip: number) => `===== shard ${i}/2 (exit 0) =====\nbun test v1\n--shard=${i}/2: running 80/160 test files\n\n ${pass} pass\n ${skip} skip\n 0 fail\nRan ${pass + skip} tests across 80 files. [10.00ms]\n`;
|
||||
const log = (name: string, text: string) => { const p = path.join(gstackHome, name); fs.writeFileSync(p, text); return `cat '${p}' >&2`; };
|
||||
run(['run', '--label', 'tests', '--', log('shards.out', shard(1, 2759, 20) + shard(2, 3336, 18) + '\n2 shards: 6095 pass, 38 skip, 0 fail in 400s\n')]);
|
||||
expect(records().pop().tests_ran).toBe(6095);
|
||||
run(['run', '--label', 'tests', '--', log('one.out', shard(2, 3336, 18))]);
|
||||
expect(records().pop().tests_ran).toBe(3336);
|
||||
run(['run', '--label', 'tests', '--', log('again.out', shard(2, 9, 0) + shard(2, 3336, 18))]);
|
||||
expect(records().pop().tests_ran).toBe(3336);
|
||||
});
|
||||
|
||||
test('an unrecognised runner is unknown: non-blocking, labelled in the detail', () => {
|
||||
expect(run(['run', '--label', 'tests', '--', 'echo green']).status).toBe(0);
|
||||
expect(records().pop().tests_ran).toBe('unknown');
|
||||
|
||||
Reference in new issue
Block a user