chore(tests-only): migrate to auto-sharding/balancing Vitest CI workflow#9565
Conversation
|
There was a problem hiding this comment.
Pull request overview
This PR transforms the test infrastructure from a static, manually-maintained test matrix to a dynamic auto-sharding system with intelligent test distribution based on historical performance data.
Changes:
- Introduced smart cache system that tracks test execution metrics (duration, failures) per platform
- Implemented dynamic shard planning with bin-packing algorithm for balanced test distribution across CI runners
- Added custom Vitest infrastructure including sequencer, reporter, and heavy test mutex for resource management
Reviewed changes
Copilot reviewed 74 out of 78 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
vite.config.ts |
Updated Vitest configuration to use custom sequencer and reporters, removed HTTPS cert setup |
test/vitest-scripts/* |
New smart test infrastructure for sharding, caching, and platform-specific test discovery |
.github/workflows/test.yaml |
Restructured workflow with unified shard planning job and platform-specific test matrices |
.github/actions/pretest/action.yml |
Consolidated setup using reusable pnpm action, added smart cache restoration |
test/src/**/*Test.ts |
Updated tests to use new conditional APIs (ifMac, ifWindows, ifLinux, heavy) |
package.json |
Updated CI test commands to use new shard scripts |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
📣 Context/Reasoning for this (large) change
TEST_FILESenv var.Notes/Disclaimer:
🎯 Summary
This PR fundamentally transforms the test infrastructure from a static, manually-maintained system to a dynamic, self-optimizing system using dynamic shard planning based on historical test execution data, replacing static test matrices with an intelligent test file distribution across platforms.
🔍 Key Objectives:
Eliminated Manual Test Distribution
testFilesarrays from GitHub workflowsIntelligent Sharding
Performance Optimization
CI/CD Simplification
Cache Management
Infrastructure Cleanup
describe.ifMacifWindowsandifLinuxoperators so that sharding works correctly across each OS)🔧 GitHub Actions & Workflows Changes
.github/actions/pretest/action.yml(Major refactor)Added (new approach):
uses: ./.github/actions/pnpmto reduce duplicated GH Action logic.github/workflows/test.yaml(Complete restructure)New Workflow Structure:
1. Shard Planning Job (
shard-plan):pnpm --silent ci:test:countto get JSON output with shard counts per platformjq:LINUX_SHARDS=$(echo "$SHARD_JSON" | jq -c '.linux')WINDOWS_SHARDS=$(echo "$SHARD_JSON" | jq -c '.win32')MACOS_SHARDS=$(echo "$SHARD_JSON" | jq -c '.darwin')2. Unified Test Jobs:
Key Changes:
TEST_FILESenvironment variable entirelyVITEST_SHARD_INDEXfor dynamic shard assignmentbrew install powershell/tap/powershellandwine-stable(only keepsrpm)3. Special Jobs (Modified):
test-updater:ADDITIONAL_DOCKER_ARGSto pass tokenstest-e2e:test-linux-native:if: falsedue to unstable tests [upcoming fix PR])4. Cache Merging Job (
merge-smart-cache):vitest-smart-cache-*artifacts📁 vitest-scripts Folder (New CI infrastructure)
test/vitest-scripts/_vitest-smart-cache.jsonstoring test execution metadatatest/vitest-scripts/cache.tstest/vitest-scripts/file-discovery.ts(63 lines)heavy/platform/etc.) via Vitestmetatask metadata propertytest/vitest-scripts/shard-builder.tstest/vitest-scripts/smart-config.tstest/vitest-scripts/smart-shard-count.ts{"linux": [1,2,3], "win32": [1,2], "darwin": [1,2,3,4]}VITEST_SHARD_INDEXenv vartest/vitest-scripts/smart-shard.tsVITEST_SHARD_INDEXenv vartest/vitest-scripts/vitest-heavy-mutex.tstest/vitest-scripts/vitest-setup.tstest/vitest-scripts/vitest-smart-reporter.tstest/vitest-scripts/vitest-smart-sequencer.ts