mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-23 08:31:44 +01:00
The weekly test-time recording can land again on its own (GST-3303) (#4581)
The weekly job that re-records how long each test file takes can land its update again without someone fixing it by hand. Free Tests uses those times to split the suite evenly. It had not landed an update since 11-09: the Windows half kept failing, and its pull request waited for a maintainer whenever a new file ran past 60 seconds. Nothing to do. The bot's commit and pull-request step runs for real only on the weekly schedule, so the next Monday run is its first live test. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Refs: GST-3303
This commit is contained in:
1 parent
ef4a7f5cbf
commit
507ebfc16d
8 files changed
+146
-9
No files matched your search
Executable
+37
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env -S bun --no-env-file --config=/dev/null
|
||||
/**
|
||||
* free-seed-allowlist — bring the seed allowlist in line with a fresh recording
|
||||
* (docs/TESTING_INTERNALS.md#free-suite-duration-seed).
|
||||
*
|
||||
* bun run scripts/free-seed-allowlist.ts --reconcile --recording <run url>
|
||||
*
|
||||
* Reads scripts/free-test-durations.json, drops allowlist entries for files no
|
||||
* longer over the 60 s ceiling, admits each unlisted file over it as an
|
||||
* annotated exception naming the recording, rewrites the allowlist, and prints
|
||||
* one ADMITTED or PRUNED line per change. The weekly recorder runs it so its
|
||||
* seed PR passes the ratchet; the admitted files stay listed for splitting.
|
||||
*/
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { formatSeedAllowlist, parseSeedAllowlist, reconcileSeedAllowlist, SEED_ALLOWLIST_FILE } from './lib/free-ci-health';
|
||||
|
||||
const ROOT = path.resolve(import.meta.dir, '..');
|
||||
|
||||
if (import.meta.main) {
|
||||
const args = process.argv.slice(2);
|
||||
const recording = args[args.indexOf('--recording') + 1];
|
||||
if (args[0] !== '--reconcile' || args.length !== 3 || args[1] !== '--recording' || !recording) {
|
||||
console.error('usage: free-seed-allowlist.ts --reconcile --recording <run url>');
|
||||
process.exit(2);
|
||||
}
|
||||
const durations = (JSON.parse(fs.readFileSync(path.join(ROOT, 'scripts/free-test-durations.json'), 'utf8')) as { durations: Record<string, number> }).durations;
|
||||
const file = path.join(ROOT, SEED_ALLOWLIST_FILE);
|
||||
const { entries, admitted, pruned } = reconcileSeedAllowlist(durations, parseSeedAllowlist(fs.readFileSync(file, 'utf8')), (name, ms) => ({
|
||||
file: name,
|
||||
reason: `${Math.round(ms / 1000)}s in the weekly recording ${recording}; admitted by the recorder so the refreshed seed can land`,
|
||||
todo: 'split or speed up until it runs under 60 s, then delete this entry',
|
||||
}));
|
||||
if (admitted.length || pruned.length) fs.writeFileSync(file, formatSeedAllowlist(entries));
|
||||
for (const name of admitted) console.log(`ADMITTED ${name} ${Math.round(durations[name] / 1000)}s`);
|
||||
for (const name of pruned) console.log(`PRUNED ${name}`);
|
||||
}
|
||||
@@ -148,6 +148,29 @@ export function seedRatchet({ durations, allowlist, baseAllowlist }: SeedRatchet
|
||||
return { violations, exceptions };
|
||||
}
|
||||
|
||||
/**
|
||||
* The allowlist a fresh recording needs, for the weekly recorder's seed PR: drop
|
||||
* entries for files now at or under the ceiling or gone from the seed, and admit
|
||||
* every unlisted file over it with `admit`'s annotated entry (a todo is required).
|
||||
* Other entries keep their text. Returns the new entries and what changed.
|
||||
*/
|
||||
export function reconcileSeedAllowlist(
|
||||
durations: Record<string, number>, allowlist: SeedAllowlistEntry[],
|
||||
admit: (file: string, ms: number) => SeedAllowlistEntry & { todo: string },
|
||||
): { entries: SeedAllowlistEntry[]; admitted: string[]; pruned: string[] } {
|
||||
const pruned = allowlist.filter(entry => !(durations[entry.file] > SEED_CEILING_MS)).map(entry => entry.file);
|
||||
const kept = allowlist.filter(entry => !pruned.includes(entry.file));
|
||||
const listed = new Set(kept.map(entry => entry.file));
|
||||
const admitted = Object.keys(durations).filter(file => durations[file] > SEED_CEILING_MS && !listed.has(file)).sort();
|
||||
return { entries: [...kept, ...admitted.map(file => admit(file, durations[file]))], admitted, pruned };
|
||||
}
|
||||
|
||||
/** The allowlist file's own layout: one entry per line. */
|
||||
export function formatSeedAllowlist(entries: SeedAllowlistEntry[]): string {
|
||||
const line = (entry: SeedAllowlistEntry) => `{${Object.entries(entry).map(([key, value]) => `${JSON.stringify(key)}: ${JSON.stringify(value)}`).join(', ')}}`;
|
||||
return `{\n "entries": [\n${entries.map(entry => ` ${line(entry)}`).join(',\n')}\n ]\n}\n`;
|
||||
}
|
||||
|
||||
export type BaseAllowlistRead =
|
||||
| { status: 'ok'; entries: SeedAllowlistEntry[] | null }
|
||||
| { status: 'unavailable'; reason: string };
|
||||
|
||||
Reference in new issue
Block a user