From 343057aff9bd2d6d42e5e27623b7450da2943898 Mon Sep 17 00:00:00 2001 From: "congvc-bot[bot]" <3634010+congvc-bot[bot]@users.noreply.github.com> Date: Wed, 25 Nov 2026 18:39:12 +0700 Subject: [PATCH 1/2] Budget the scoped Windows job by the Windows duration seed (CHE-9817) --- .github/workflows/windows-scoped-tests.yml | 13 ++++++- changelog.d/che-9817-windows-scoped-budget.md | 1 + test/windows-path-scope-workflow.test.ts | 37 +++++++++++++++++-- 3 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 changelog.d/che-9817-windows-scoped-budget.md diff --git a/.github/workflows/windows-scoped-tests.yml b/.github/workflows/windows-scoped-tests.yml index be88c94c996..4777b7d8b22 100644 --- a/.github/workflows/windows-scoped-tests.yml +++ b/.github/workflows/windows-scoped-tests.yml @@ -139,6 +139,15 @@ jobs: echo 'No changed test file is in the curated Windows-safe subset, so no Windows job runs.' >> "$GITHUB_STEP_SUMMARY" exit 0 fi + # Budget (CHE-9817): the 4 Windows shards each get 600 s of the Windows-measured seed (an + # unseeded file counts 30 s). An upstream sync selects ~110 files, ~25 min on Windows: skip it here; + # windows-free-tests.yml runs the whole curated suite nightly on main. + seed="${GSTACK_FREE_TEST_DURATIONS:-scripts/free-test-durations-windows.json}" + predicted_ms=$(jq -Rn --slurpfile d "$seed" '[inputs | $d[0].durations[.] // 30000] | add' "$RUNNER_TEMP/selected") + if [ "$predicted_ms" -gt 2400000 ]; then + echo "The Windows seed predicts $((predicted_ms / 1000)) s for the $(wc -l < "$RUNNER_TEMP/selected" | tr -d ' ') selected files, over the 2400 s budget (4 shards x 600 s), so no Windows job runs. windows-free-tests (nightly, full curated suite) covers them." >> "$GITHUB_STEP_SUMMARY" + exit 0 + fi { echo 'files<> "$GITHUB_OUTPUT" { echo "The Windows job runs $(wc -l < "$RUNNER_TEMP/selected" | tr -d ' ') changed Windows-safe test file(s):"; sed 's/^/- /' "$RUNNER_TEMP/selected"; } >> "$GITHUB_STEP_SUMMARY" @@ -146,7 +155,7 @@ jobs: needs: windows-scope if: ${{ (github.event_name == 'workflow_dispatch' && inputs.files != '') || needs.windows-scope.outputs.files != '' }} runs-on: windows-latest - timeout-minutes: 20 + timeout-minutes: 30 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: @@ -186,6 +195,8 @@ jobs: - name: Run the scoped Windows-safe test files env: FILES: ${{ inputs.files || needs.windows-scope.outputs.files }} + # Pack and time the shards by Windows-measured durations: the Linux seed is ~7x too fast (CHE-9817). + GSTACK_FREE_TEST_DURATIONS: scripts/free-test-durations-windows.json GSTACK_FREE_RETRY_FLAKY: '1' GSTACK_FLAKE_LEDGER: ${{ runner.temp }}/flake-ledger.jsonl TEMP: ${{ runner.temp }} diff --git a/changelog.d/che-9817-windows-scoped-budget.md b/changelog.d/che-9817-windows-scoped-budget.md new file mode 100644 index 00000000000..285b63d3d77 --- /dev/null +++ b/changelog.d/che-9817-windows-scoped-budget.md @@ -0,0 +1 @@ +The scoped Windows test job packs its shards by the Windows-measured durations and skips a selection the Windows seed predicts over 2400 s (the nightly Windows suite covers it), so a large upstream-sync pull request no longer times out all four shards (CHE-9817). diff --git a/test/windows-path-scope-workflow.test.ts b/test/windows-path-scope-workflow.test.ts index 810accb2540..8100d7b71d3 100644 --- a/test/windows-path-scope-workflow.test.ts +++ b/test/windows-path-scope-workflow.test.ts @@ -233,18 +233,20 @@ describe('the path-scoped Windows shard on pull requests', () => { const CAN_SELECT = CAN_RUN && !!Bun.which('jq'); /** Filter, then select with a stub bun whose curated plan holds the given files. */ - function scopeJob(dir: string, curated: string[]) { + function scopeJob(dir: string, curated: string[], seed: Record = {}) { const filter = runStep(filterScript, dir); expect(filter.status, filter.stderr).toBe(0); const scope = fs.readFileSync(path.join(filter.temp, 'windows-scope'), 'utf8'); - if (filter.outputs.windows !== 'true') return { windows: filter.outputs.windows, scope, files: undefined as string | undefined }; + if (filter.outputs.windows !== 'true') return { windows: filter.outputs.windows, scope, files: undefined as string | undefined, summary: '' }; const bin = path.join(filter.temp, 'bin'); fs.mkdirSync(bin); fs.writeFileSync(path.join(bin, 'bun'), '#!/bin/sh\nwhile [ $# -gt 0 ]; do [ "$1" = --ci-plan ] && printf \'%s\' "$PLAN_JSON" > "$2"; shift; done\necho \'{"shard":[1]}\'\n', { mode: 0o755 }); const plan = JSON.stringify({ version: 1, revision: 'r', shards: [{ shard: 1, predictedMs: 1, files: curated }], id: 'x' }); - const select = runStep(selectScript, dir, { PATH: `${toShell(bin)}:${process.env.PATH}`, PLAN_JSON: plan }, filter.temp); + const seedFile = path.join(filter.temp, 'seed.json'); + fs.writeFileSync(seedFile, JSON.stringify({ version: 1, durations: seed })); + const select = runStep(selectScript, dir, { PATH: `${toShell(bin)}:${process.env.PATH}`, PLAN_JSON: plan, GSTACK_FREE_TEST_DURATIONS: toShell(seedFile) }, filter.temp); expect(select.status, select.stderr).toBe(0); - return { windows: filter.outputs.windows, scope, files: select.outputs.files }; + return { windows: filter.outputs.windows, scope, files: select.outputs.files, summary: select.summary }; } const CURATED = ['test/hook-scripts.test.ts', 'test/review-risk-linear.test.ts', 'test/review-risk-routing.test.ts']; @@ -290,6 +292,33 @@ describe('the path-scoped Windows shard on pull requests', () => { } }); + // CHE-9817: an upstream sync selected 112 files, the job packed them by the Linux seed (~88 s a shard) and every + // shard hit the 360 s wall on Windows, where the same files run ~7x slower (Windows seed: 1363 s for the 65 it covers; 47 had no entry). + test('the scoped run packs by the Windows seed, not the Linux one', () => { + const run = scoped.jobs['windows-scoped-shard'].steps.find((s: any) => s.name === 'Run the scoped Windows-safe test files'); + expect(run.env.GSTACK_FREE_TEST_DURATIONS).toBe('scripts/free-test-durations-windows.json'); + }); + + // Budget: 4 shards x 600 s = 2400 s of Windows seed; an unseeded file counts 30 s. + test.skipIf(!CAN_SELECT)('CHE-9817: a selection the Windows seed predicts over budget starts no Windows job and points at the nightly suite', () => { + const files = ['test/sync-a.test.ts', 'test/sync-b.test.ts']; + const dir = prRepo(['bin/gstack-example', ...files]); + try { + const job = scopeJob(dir, files, { 'test/sync-a.test.ts': 1_300_000, 'test/sync-b.test.ts': 1_300_000 }); + expect([job.windows, job.files]).toEqual(['true', undefined]); + expect(job.summary).toContain('windows-free-tests'); + } finally { fs.rmSync(dir, { recursive: true, force: true }); } + }); + + test.skipIf(!CAN_SELECT)('CHE-9817: a selection within budget runs, and the unseeded file counts 30 s', () => { + const files = ['test/sync-a.test.ts', 'test/sync-b.test.ts']; + const dir = prRepo(['bin/gstack-example', ...files]); + try { + expect(scopeJob(dir, files, { 'test/sync-a.test.ts': 2_370_000 }).files).toBe(files.join('\n')); + expect(scopeJob(dir, files, { 'test/sync-a.test.ts': 2_370_001 }).files).toBeUndefined(); + } finally { fs.rmSync(dir, { recursive: true, force: true }); } + }); + test.skipIf(!CAN_SELECT)('in scope but no changed Windows-safe test file: no files, so no Windows job', () => { const dir = prRepo(['bin/gstack-example', 'test/posix-only.test.ts']); try { From b44ba9d1f610bc83b7cafcb0426825000cdaf97d Mon Sep 17 00:00:00 2001 From: "congvc-bot[bot]" <3634010+congvc-bot[bot]@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:05:41 +0700 Subject: [PATCH 2/2] Run large Windows scoped selections instead of skipping them (CHE-9817) --- .github/workflows/windows-scoped-tests.yml | 12 ++---------- test/windows-path-scope-workflow.test.ts | 16 +++++----------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/.github/workflows/windows-scoped-tests.yml b/.github/workflows/windows-scoped-tests.yml index 4777b7d8b22..f71a2217286 100644 --- a/.github/workflows/windows-scoped-tests.yml +++ b/.github/workflows/windows-scoped-tests.yml @@ -139,23 +139,15 @@ jobs: echo 'No changed test file is in the curated Windows-safe subset, so no Windows job runs.' >> "$GITHUB_STEP_SUMMARY" exit 0 fi - # Budget (CHE-9817): the 4 Windows shards each get 600 s of the Windows-measured seed (an - # unseeded file counts 30 s). An upstream sync selects ~110 files, ~25 min on Windows: skip it here; - # windows-free-tests.yml runs the whole curated suite nightly on main. - seed="${GSTACK_FREE_TEST_DURATIONS:-scripts/free-test-durations-windows.json}" - predicted_ms=$(jq -Rn --slurpfile d "$seed" '[inputs | $d[0].durations[.] // 30000] | add' "$RUNNER_TEMP/selected") - if [ "$predicted_ms" -gt 2400000 ]; then - echo "The Windows seed predicts $((predicted_ms / 1000)) s for the $(wc -l < "$RUNNER_TEMP/selected" | tr -d ' ') selected files, over the 2400 s budget (4 shards x 600 s), so no Windows job runs. windows-free-tests (nightly, full curated suite) covers them." >> "$GITHUB_STEP_SUMMARY" - exit 0 - fi { echo 'files<> "$GITHUB_OUTPUT" { echo "The Windows job runs $(wc -l < "$RUNNER_TEMP/selected" | tr -d ' ') changed Windows-safe test file(s):"; sed 's/^/- /' "$RUNNER_TEMP/selected"; } >> "$GITHUB_STEP_SUMMARY" windows-scoped-shard: needs: windows-scope if: ${{ (github.event_name == 'workflow_dispatch' && inputs.files != '') || needs.windows-scope.outputs.files != '' }} + # CHE-9817: an upstream sync selects ~110 files, 2773 s of Windows seed. 60 min covers that run serially plus setup. runs-on: windows-latest - timeout-minutes: 30 + timeout-minutes: 60 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: diff --git a/test/windows-path-scope-workflow.test.ts b/test/windows-path-scope-workflow.test.ts index 8100d7b71d3..654826ea43a 100644 --- a/test/windows-path-scope-workflow.test.ts +++ b/test/windows-path-scope-workflow.test.ts @@ -299,24 +299,18 @@ describe('the path-scoped Windows shard on pull requests', () => { expect(run.env.GSTACK_FREE_TEST_DURATIONS).toBe('scripts/free-test-durations-windows.json'); }); - // Budget: 4 shards x 600 s = 2400 s of Windows seed; an unseeded file counts 30 s. - test.skipIf(!CAN_SELECT)('CHE-9817: a selection the Windows seed predicts over budget starts no Windows job and points at the nightly suite', () => { + // A large selection is never skipped: a green run with no Windows job proves nothing (CHE-9817). + test.skipIf(!CAN_SELECT)('CHE-9817: a selection the Windows seed predicts at 2600 s is still selected, not skipped', () => { const files = ['test/sync-a.test.ts', 'test/sync-b.test.ts']; const dir = prRepo(['bin/gstack-example', ...files]); try { const job = scopeJob(dir, files, { 'test/sync-a.test.ts': 1_300_000, 'test/sync-b.test.ts': 1_300_000 }); - expect([job.windows, job.files]).toEqual(['true', undefined]); - expect(job.summary).toContain('windows-free-tests'); + expect([job.windows, job.files]).toEqual(['true', files.join('\n')]); } finally { fs.rmSync(dir, { recursive: true, force: true }); } }); - test.skipIf(!CAN_SELECT)('CHE-9817: a selection within budget runs, and the unseeded file counts 30 s', () => { - const files = ['test/sync-a.test.ts', 'test/sync-b.test.ts']; - const dir = prRepo(['bin/gstack-example', ...files]); - try { - expect(scopeJob(dir, files, { 'test/sync-a.test.ts': 2_370_000 }).files).toBe(files.join('\n')); - expect(scopeJob(dir, files, { 'test/sync-a.test.ts': 2_370_001 }).files).toBeUndefined(); - } finally { fs.rmSync(dir, { recursive: true, force: true }); } + test('CHE-9817: the Windows job timeout leaves headroom for a 2773 s selection plus setup', () => { + expect(scoped.jobs['windows-scoped-shard']['timeout-minutes']).toBeGreaterThanOrEqual(60); }); test.skipIf(!CAN_SELECT)('in scope but no changed Windows-safe test file: no files, so no Windows job', () => {