Nightly Windows tests stop timing out: shards pack by Windows test times (GST-3440) (#4661)

The nightly Windows test run no longer cancels a shard at its 15-minute
limit: files without a Windows time use their Linux time instead of a
161 s guess, and the plan adds shards past eight until no shard holds
more than 12 minutes.

Why: one shard on #4646's tree held 946 s of Windows work against a 900
s job and was cancelled twice (run 44971202453); any PR adding test
files could trip it.

Nothing to do: the Windows run is nightly-only and this changes no test
selection, timeout or retry.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-22 03:32:40 +00:00
1 parent 69ad1031a1
commit 6484fd58ae
7 files changed
+108 -17

No files matched your search

@@ -1 +1 @@
{"blob":"7de8d1dd5060bc0ec25fca1f3b348c354e5938a1","since":7,"nonBehavioral":"GST-3386 adds .github/workflows/test-changes.yml to FREE_ONLY_PR_FILES in scripts/test-pr-profile.ts: the new workflow is a free, flag-only check, so it only classifies that file as free-lane in the workflow inventory; no paid case's selection, prompt, threshold, samples or verdict can change"}
{"blob":"16093cf648950c2a863689e261ea2d06279a8740","since":7,"nonBehavioral":"GST-3440 adds scripts/free-test-durations-windows.json to FREE_ONLY_PR_FILES in scripts/test-pr-profile.ts: the Windows duration seed is read only by the free Windows shard plan, so it only stops a seed refresh from selecting paid cases; no paid case's selection, prompt, threshold, samples or verdict can change"}
+54 -3
View File
@@ -77,6 +77,9 @@
* bun run scripts/test-free-shards.ts --attribute-home # name real-home writers: each file alone, private HOME
* bun run scripts/test-free-shards.ts --ci-plan plan.json --shards 20
* bun run scripts/test-free-shards.ts --ci-run plan.json --shard 1 --result result.json
* bun run scripts/test-free-shards.ts --windows-only --ci-plan plan.json --shards 8 --shard-budget-seconds 720
* # --shards becomes a floor: the Windows plan adds shards, up to twice it, until every
* # shard predicts at most 720 s, and fails past that (GST-3440).
* bun run scripts/test-free-shards.ts --ci-plan plan.json --shards 20 --shard-jobs 2
* # the plan stores a per-shard k: min(k, the shard's files that may run in parallel),
* # kept only when above 1, so the exclusive TREE_MUTATING shard stays one child.
@@ -382,6 +385,23 @@ export function loadFreeTestDurations(rootDir = ROOT): Record<string, number> |
return Object.keys(seed.durations).length === 0 ? null : seed.durations;
}
export const WINDOWS_FREE_TEST_DURATIONS_FILE = 'scripts/free-test-durations-windows.json';
/**
* Windows plans pack by Windows-recorded time. A file the Windows seed lacks
* falls back to its Linux time instead of the Windows 99th percentile (161 s),
* which once packed 27 such files as phantom load and left one shard with
* 946 s of real Windows work against a 900 s job (GST-3440).
*/
export function loadWindowsFreeTestDurations(rootDir = ROOT): Record<string, number> {
const read = (file: string) => {
const seed = readDurationSeed(path.join(rootDir, file), FREE_LANE_POLICY.acceptsSeedDuration);
if (seed.status === 'corrupt') console.error(`[test:free] WARNING: corrupt durations seed ${file} (${seed.error.message})`);
return seed.status === 'ok' ? seed.durations : {};
};
return { ...read(FREE_TEST_DURATIONS_FILE), ...read(WINDOWS_FREE_TEST_DURATIONS_FILE) };
}
export interface PackedShards {
shards: string[][];
/** Predicted total per shard, aligned with `shards` — feeds walls + logs. */
@@ -493,6 +513,20 @@ export function createFreeCiPlan(files: string[], count: number, durations: Reco
return { ...body, id: planDigest(body) };
}
/**
* The Windows plan with the fewest shards, from `minimum` up to twice it, whose
* every shard predicts at most `budgetMs` (--shard-budget-seconds). Needing more
* than that means a stale Windows seed, so the plan fails instead of growing further.
*/
export function createWindowsCiPlan(files: string[], minimum: number, budgetMs: number, durations: Record<string, number>, revision: string, shardJobs = 1): FreeCiPlan {
for (let count = minimum; count <= minimum * 2; count += 1) {
const plan = createFreeCiPlan(files, count, durations, revision, shardJobs);
if (plan.shards.every(shard => shard.predictedMs <= budgetMs)) return plan;
}
throw new Error(`No Windows plan of ${minimum} to ${minimum * 2} shards keeps every shard within ${budgetMs / 1000} s.`
+ ` Refresh ${WINDOWS_FREE_TEST_DURATIONS_FILE} with a record_durations dispatch of windows-free-tests.yml.`);
}
/**
* --ci-plan's stdout, the GitHub matrix. With --job-setup-seconds each entry
* carries the shard's job timeout (ciShardJobTimeoutMinutes); without it, the
@@ -629,6 +663,8 @@ type CliOptions = {
shardJobs?: number;
/** Set only by --job-setup-seconds (with --ci-plan): the matrix then carries each shard's job timeout. */
jobSetupSeconds?: number;
/** Set only by --shard-budget-seconds (with --windows-only --ci-plan): --shards is then a floor. */
shardBudgetSeconds?: number;
};
export function parseCliOptions(argv: string[]): CliOptions {
@@ -646,6 +682,7 @@ export function parseCliOptions(argv: string[]): CliOptions {
let jobs: number | undefined;
let shardJobs: number | undefined;
let jobSetupSeconds: number | undefined;
let shardBudgetSeconds: number | undefined;
let junitDir: string | undefined;
const paths: Record<'ciPlan' | 'ciRun' | 'ciVerify' | 'result' | 'results' | 'filesFrom', string | null> = {
ciPlan: null, ciRun: null, ciVerify: null, result: null, results: null, filesFrom: null,
@@ -682,6 +719,11 @@ export function parseCliOptions(argv: string[]): CliOptions {
jobSetupSeconds = /^\d+$/.test(value) ? Number(value) : NaN;
if (!(jobSetupSeconds > 0 && jobSetupSeconds <= 3600)) throw new Error('--job-setup-seconds needs a whole number of seconds from 1 to 3600');
},
'--shard-budget-seconds': (next) => {
const value = next() ?? '';
shardBudgetSeconds = /^\d+$/.test(value) ? Number(value) : NaN;
if (!(shardBudgetSeconds > 0 && shardBudgetSeconds <= 21600)) throw new Error('--shard-budget-seconds needs a whole number of seconds from 1 to 21600');
},
'--shards': (next) => {
const value = next();
if (!value) throw new Error('Missing value for --shards');
@@ -709,8 +751,9 @@ export function parseCliOptions(argv: string[]): CliOptions {
if (jobs !== undefined && !paths.ciRun) rejectJobsWithoutCiRun();
if (shardJobs !== undefined && !paths.ciPlan) rejectShardJobsWithoutCiPlan();
if (jobSetupSeconds !== undefined && !paths.ciPlan) throw new Error('--job-setup-seconds applies only to --ci-plan');
if (shardBudgetSeconds !== undefined && !(paths.ciPlan && windowsOnly)) throw new Error('--shard-budget-seconds applies only to --windows-only --ci-plan');
if (quick && (recordDurations || windowsOnly || shardIndex !== null)) throw new Error('--quick cannot change recording, Windows or shard selection');
return { dryRun, listOnly, recordDurations, windowsOnly, verbose, shardCount, shardIndex, wallTimeoutMs, wallTimeoutExplicit, quick, attributeHome, ...paths, ...(jobs === undefined ? {} : { jobs }), ...(shardJobs === undefined ? {} : { shardJobs }), ...(jobSetupSeconds === undefined ? {} : { jobSetupSeconds }), ...(junitDir === undefined ? {} : { junitDir }) };
return { dryRun, listOnly, recordDurations, windowsOnly, verbose, shardCount, shardIndex, wallTimeoutMs, wallTimeoutExplicit, quick, attributeHome, ...paths, ...(jobs === undefined ? {} : { jobs }), ...(shardJobs === undefined ? {} : { shardJobs }), ...(jobSetupSeconds === undefined ? {} : { jobSetupSeconds }), ...(shardBudgetSeconds === undefined ? {} : { shardBudgetSeconds }), ...(junitDir === undefined ? {} : { junitDir }) };
}
const describeLines = (lines: string[]) => `${lines.slice(0, 5).join(', ')}${lines.length > 5 ? ` (+${lines.length - 5} more)` : ''}`;
@@ -2047,14 +2090,22 @@ async function main(): Promise<number> {
fs.renameSync(temporary, file);
};
if (options.ciPlan) {
const durations = loadFreeTestDurations() ?? {};
const durations = curation ? loadWindowsFreeTestDurations() : loadFreeTestDurations() ?? {};
if (curation) {
const line = windowsCurationLine(curation);
console.error(`[test:free] ${line}`);
appendStepSummary(line);
}
warnUnseededFreeFiles(ciFiles, durations);
const plan = createFreeCiPlan(ciFiles, options.shardCount, durations, revision, options.shardJobs, options.jobSetupSeconds);
const budgetSeconds = options.shardBudgetSeconds;
const plan = budgetSeconds !== undefined
? createWindowsCiPlan(ciFiles, options.shardCount, budgetSeconds * 1000, durations, revision, options.shardJobs)
: createFreeCiPlan(ciFiles, options.shardCount, durations, revision, options.shardJobs, options.jobSetupSeconds);
if (budgetSeconds !== undefined) {
const line = `Windows plan: ${plan.shards.length} shards, heaviest ${Math.round(Math.max(...plan.shards.map(shard => shard.predictedMs)) / 1000)} s of a ${budgetSeconds} s budget`;
console.error(`[test:free] ${line}`);
appendStepSummary(line);
}
validateFreeCiPlan(plan, ciFiles, revision);
const matrix = ciPlanMatrix(plan, options.jobSetupSeconds);
if ('include' in matrix) {
+1
View File
@@ -238,6 +238,7 @@ export const FREE_ONLY_PR_FILES = [
'test/helpers/auq-parallel-worker.ts',
'test/helpers/stored-zip.ts', // Read only by the free test-health report tests.
'scripts/free-test-durations.json',
'scripts/free-test-durations-windows.json', // Read only by the free Windows plan (scripts/test-free-shards.ts --windows-only --ci-plan).
'scripts/free-test-seed-allowlist.json', // Read only by the free seed ratchet (test/free-seed-ratchet.test.ts).
'scripts/paid-test-durations.json',
'scripts/ubicloud/**',