From 1e3d79c777876e4ca4a97b4bac8df449c22517ce 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:27:09 +0700 Subject: [PATCH 1/2] ci: skip the scoped Windows lane past 40 changed tests (CHE-9815) --- .github/workflows/windows-scoped-tests.yml | 8 ++++++++ test/windows-path-scope-workflow.test.ts | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/.github/workflows/windows-scoped-tests.yml b/.github/workflows/windows-scoped-tests.yml index be88c94c996..28d8d5cceb2 100644 --- a/.github/workflows/windows-scoped-tests.yml +++ b/.github/workflows/windows-scoped-tests.yml @@ -139,6 +139,14 @@ jobs: echo 'No changed test file is in the curated Windows-safe subset, so no Windows job runs.' >> "$GITHUB_STEP_SUMMARY" exit 0 fi + # CHE-9815: one windows-latest job runs 4 shards with a 360s deadline each; 113 files (an upstream sync) timed out every shard. + # Past the cap the nightly Windows Free Tests (10 runner jobs) covers them; windows-smoke still runs on every pull request. + max=40 + n=$(wc -l < "$RUNNER_TEMP/selected" | tr -d ' ') + if [ "$n" -gt "$max" ]; then + echo "$n changed Windows-safe test files exceed the scoped lane's $max-file cap, so no scoped Windows job runs; the nightly Windows Free Tests 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" diff --git a/test/windows-path-scope-workflow.test.ts b/test/windows-path-scope-workflow.test.ts index 810accb2540..242dbde2bde 100644 --- a/test/windows-path-scope-workflow.test.ts +++ b/test/windows-path-scope-workflow.test.ts @@ -256,6 +256,25 @@ describe('the path-scoped Windows shard on pull requests', () => { expect(select.outputs.files).toBe('test/hook-scripts.test.ts'); }, 60_000); + test.skipIf(!CAN_SELECT)('CHE-9815: more than 40 changed Windows-safe tests (an upstream sync) skip the scoped lane, which cannot finish them in 4 shards', () => { + const many = Array.from({ length: 41 }, (_, i) => `test/sync-${i}.test.ts`); + const select = (changed: string[]) => { + const temp = newTemp(); + const bin = path.join(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\n', { mode: 0o755 }); + fs.writeFileSync(path.join(temp, 'changed-files'), changed.join('\n') + '\n'); + const plan = JSON.stringify({ version: 1, revision: 'r', shards: [{ shard: 1, predictedMs: 1, files: many }], id: 'x' }); + const r = runStep(selectScript, ROOT, { PATH: `${toShell(bin)}:${process.env.PATH}`, PLAN_JSON: plan }, temp); + expect(r.status, r.stderr).toBe(0); + return r; + }; + const over = select(many); + expect(over.outputs.files).toBeUndefined(); + expect(over.summary).toContain('exceed the scoped lane'); + expect(select(many.slice(0, 40)).outputs.files?.split('\n')).toHaveLength(40); + }); + test.skipIf(!CAN_SELECT)('#3758: the hook paths put it in scope and the Windows job runs test/hook-scripts.test.ts', () => { const dir = prRepo(PR_3758); try { From 6fa961a516aabb5300e2bc652bdbb084f88ead26 Mon Sep 17 00:00:00 2001 From: "congvc-bot[bot]" <3634010+congvc-bot[bot]@users.noreply.github.com> Date: Thu, 26 Nov 2026 06:42:51 +0700 Subject: [PATCH 2/2] ci: deal a large scoped Windows selection into up to 10 jobs instead of skipping it (CHE-9815) --- .github/workflows/windows-scoped-tests.yml | 27 +++++++++++++--------- test/windows-path-scope-workflow.test.ts | 26 +++++++++++++-------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/.github/workflows/windows-scoped-tests.yml b/.github/workflows/windows-scoped-tests.yml index 28d8d5cceb2..b374185e75a 100644 --- a/.github/workflows/windows-scoped-tests.yml +++ b/.github/workflows/windows-scoped-tests.yml @@ -33,7 +33,8 @@ name: Windows Scoped Tests # red Windows job blocks the pull request it runs on: in a pull request that # touches path, file-name or process code, a changed curated test file has to # pass on Windows. A change to path or process code with no changed curated -# test selects nothing; the nightly suite covers it. +# test selects nothing; the nightly suite covers it. A large selection (an +# upstream sync, CHE-9815) is dealt into up to 10 Windows jobs; none is skipped. # gstack-pregate reads a job keyed on a dispatch input as manual, never a PR # obligation: this check runs on the pull request itself. A workflow_dispatch # run with the files input reruns chosen Windows-safe files on a branch. @@ -93,6 +94,7 @@ jobs: timeout-minutes: 5 outputs: files: ${{ steps.select.outputs.files }} + matrix: ${{ steps.select.outputs.matrix }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 if: github.event_name == 'pull_request' @@ -140,21 +142,24 @@ jobs: exit 0 fi # CHE-9815: one windows-latest job runs 4 shards with a 360s deadline each; 113 files (an upstream sync) timed out every shard. - # Past the cap the nightly Windows Free Tests (10 runner jobs) covers them; windows-smoke still runs on every pull request. - max=40 + # Every selected file still runs: they are dealt round-robin into ceil(n/20) Windows jobs, at most 10 (the nightly's job count). n=$(wc -l < "$RUNNER_TEMP/selected" | tr -d ' ') - if [ "$n" -gt "$max" ]; then - echo "$n changed Windows-safe test files exceed the scoped lane's $max-file cap, so no scoped Windows job runs; the nightly Windows Free Tests covers them." >> "$GITHUB_STEP_SUMMARY" - exit 0 - fi + jobs=$(( (n + 19) / 20 )) + [ "$jobs" -gt 10 ] && jobs=10 + matrix=$(jq -R -s -c --argjson k "$jobs" 'split("\n") | map(select(length > 0)) as $f | {include: [range(0; $k) as $g | {group: ($g + 1), files: ([$f | to_entries[] | select(.key % $k == $g) | .value] | join("\n"))}]}' "$RUNNER_TEMP/selected") + echo "matrix=$matrix" >> "$GITHUB_OUTPUT" { 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" + { echo "The Windows job runs $n changed Windows-safe test file(s) in $jobs job(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 != '' }} runs-on: windows-latest timeout-minutes: 20 + # CHE-9815: one job per group of selected files; a workflow_dispatch run has no matrix output and runs its input as one group. + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.windows-scope.outputs.matrix || '{"include":[{"group":1,"files":""}]}') }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: @@ -193,7 +198,7 @@ jobs: - name: Run the scoped Windows-safe test files env: - FILES: ${{ inputs.files || needs.windows-scope.outputs.files }} + FILES: ${{ inputs.files || matrix.files }} GSTACK_FREE_RETRY_FLAKY: '1' GSTACK_FLAKE_LEDGER: ${{ runner.temp }}/flake-ledger.jsonl TEMP: ${{ runner.temp }} @@ -208,7 +213,7 @@ jobs: if: always() uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7 with: - name: windows-scoped-test-logs + name: windows-scoped-test-logs-${{ matrix.group }} path: | .context/free-test-logs/gstack-free-test-*.log ${{ runner.temp }}/gstack-free-test-*.log @@ -219,7 +224,7 @@ jobs: if: always() uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7 with: - name: flake-ledger-windows-scoped + name: flake-ledger-windows-scoped-${{ matrix.group }} path: ${{ runner.temp }}/flake-ledger.jsonl if-no-files-found: ignore retention-days: 90 diff --git a/test/windows-path-scope-workflow.test.ts b/test/windows-path-scope-workflow.test.ts index 242dbde2bde..52b2ebd5ff7 100644 --- a/test/windows-path-scope-workflow.test.ts +++ b/test/windows-path-scope-workflow.test.ts @@ -214,7 +214,7 @@ describe('the path-scoped Windows shard on pull requests', () => { expect(shard.needs).toBe('windows-scope'); expect(shard.steps[0].with).toEqual({ 'persist-credentials': false }); const run = shard.steps.find((s: any) => s.name === 'Run the scoped Windows-safe test files'); - expect(run.env.FILES).toBe('${{ inputs.files || needs.windows-scope.outputs.files }}'); + expect(run.env.FILES).toBe('${{ inputs.files || matrix.files }}'); expect(run.env.GSTACK_FREE_RETRY_FLAKY).toBe('1'); expect(run.run).toContain('bun run scripts/test-free-shards.ts --files-from "$RUNNER_TEMP/windows-scoped-files.txt"'); expect(scoped.jobs['windows-scoped-tests'].needs).toEqual(['windows-scope', 'windows-scoped-shard']); @@ -256,23 +256,29 @@ describe('the path-scoped Windows shard on pull requests', () => { expect(select.outputs.files).toBe('test/hook-scripts.test.ts'); }, 60_000); - test.skipIf(!CAN_SELECT)('CHE-9815: more than 40 changed Windows-safe tests (an upstream sync) skip the scoped lane, which cannot finish them in 4 shards', () => { - const many = Array.from({ length: 41 }, (_, i) => `test/sync-${i}.test.ts`); - const select = (changed: string[]) => { + test.skipIf(!CAN_SELECT)('CHE-9815: a large change (an upstream sync) runs every selected test, dealt into at most 10 Windows jobs', () => { + const select = (count: number) => { + const many = Array.from({ length: count }, (_, i) => `test/sync-${i}.test.ts`); const temp = newTemp(); const bin = path.join(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\n', { mode: 0o755 }); - fs.writeFileSync(path.join(temp, 'changed-files'), changed.join('\n') + '\n'); + fs.writeFileSync(path.join(temp, 'changed-files'), many.join('\n') + '\n'); const plan = JSON.stringify({ version: 1, revision: 'r', shards: [{ shard: 1, predictedMs: 1, files: many }], id: 'x' }); const r = runStep(selectScript, ROOT, { PATH: `${toShell(bin)}:${process.env.PATH}`, PLAN_JSON: plan }, temp); expect(r.status, r.stderr).toBe(0); - return r; + const groups = (JSON.parse(r.outputs.matrix!) as { include: { group: number; files: string }[] }).include; + // Nothing is skipped: the groups together hold exactly the selected files, and each runs as its own job. + expect(groups.flatMap(g => g.files.split('\n')).sort()).toEqual([...many].sort()); + expect(r.outputs.files?.split('\n')).toHaveLength(count); + return groups; }; - const over = select(many); - expect(over.outputs.files).toBeUndefined(); - expect(over.summary).toContain('exceed the scoped lane'); - expect(select(many.slice(0, 40)).outputs.files?.split('\n')).toHaveLength(40); + expect(select(20)).toHaveLength(1); + expect(select(21)).toHaveLength(2); + const sync = select(113); + expect(sync).toHaveLength(6); + expect(Math.max(...sync.map(g => g.files.split('\n').length))).toBeLessThanOrEqual(19); + expect(select(500)).toHaveLength(10); }); test.skipIf(!CAN_SELECT)('#3758: the hook paths put it in scope and the Windows job runs test/hook-scripts.test.ts', () => {