feat(ci): assign coverage partitions by recorded file duration

Replace Vitest's hash-based --shard with a coordinator-side
longest-processing-time assignment. The coordinator collects the
instrumented inventory from a vitest list run (dropping the exempt
heavy suites that list does not exclude), reads per-file durations from
the Vitest results cache, and seeds heavy subprocess-bound suites into
different partitions. A weight-aware test fails when assignment ignores
recorded weights, verified by injecting a file-count-only rule.

Windows coverage measured partition spread of 442s (275-717s) under
hash sharding; a simulation with the same file durations and the new
assignment balances partitions to within 21s, cutting the critical
partition to roughly half.
This commit is contained in:
Chinesezjc
2026-08-27 21:04:15 +08:00
parent 21a2a38a2f
commit 10b31043ab
7 changed files with 684 additions and 17 deletions
+22
View File
@@ -459,6 +459,19 @@ jobs:
- uses: actions/checkout@v6
with:
persist-credentials: false
# Checkout removes the gitignored duration history, so restore it from
# the GitHub cache before coverage and save the updated one afterwards.
# The coordinator then weights partitions by measured durations on the
# second run instead of degrading to a file-count split. GitHub cache
# entries are immutable, so the save key is unique per run and the
# restore matches the newest entry through the stable prefix.
- name: Restore coverage duration history
uses: actions/cache/restore@v4
with:
path: .coverage-times.json
key: coverage-times-${{ github.run_id }}
restore-keys: |
coverage-times-
- name: Enable Developer Mode (symlink support)
shell: pwsh
run: >-
@@ -483,6 +496,15 @@ jobs:
- name: Run Windows coverage
shell: pwsh
run: pnpm run check:ci:coverage
- name: Save coverage duration history
# Coverage flakes must not prevent the cache from building; the
# measured durations remain useful even when a partition failed. The
# per-run key keeps every save a fresh immutable cache entry.
if: always()
uses: actions/cache/save@v4
with:
path: .coverage-times.json
key: coverage-times-${{ github.run_id }}
windows-native-tests:
if: github.event_name == 'pull_request'