feat(FN-4043): implement weighted CI shard balancing

Implements weighted shard planning for the CI test sharding script, with deterministic test coverage and documentation updates to `contributing.md`.

Fusion-Task-Id: FN-4043
This commit is contained in:
Fusion
2026-05-11 18:18:58 -07:00
committed by gsxdsm
parent 6acc51cf02
commit 52f62f1494
3 changed files with 83 additions and 9 deletions

View File

@@ -76,7 +76,7 @@ GitHub Actions now runs deterministic test sharding via `pnpm test:ci:shard --sh
- `pnpm test:full` remains the canonical workspace quality gate; dashboard exhaustive coverage is explicit via `pnpm --filter @fusion/dashboard test:deep`.
- `pnpm verify:workspace` remains the canonical local lint -> test -> build gate.
`test:ci:shard` is a CI-focused entrypoint (`scripts/ci-test-shard.mjs`) that partitions workspace packages with `test` scripts by shard index modulo total shard count so coverage is deterministic and reproducible.
`test:ci:shard` is a CI-focused entrypoint (`scripts/ci-test-shard.mjs`) that deterministically balances workspace packages with `test` scripts by counting package-local `**/__tests__/**/*.test.{ts,tsx,mjs}` files, then assigning packages to shards with a largest-fit-decreasing planner (heaviest first, lexical package-name tie-break, then lowest-current-weight shard with lower-index tie-break) so coverage stays reproducible while spreading shard load more evenly.
`pnpm test` now uses a changed-only entrypoint (`scripts/test-changed.mjs`) for faster local iteration. It resolves the comparison base from `.changeset/config.json` (`baseBranch`) and runs only affected workspaces from `pnpm-workspace.yaml` (both `packages/*` and `plugins/**`) using safe package-first filtering (`pnpm --filter <pkg> test`). It automatically falls back to the full suite when the run is forced (CI / `--full`), the git comparison base or diff cannot be resolved, no changes are detected, shared/root test infrastructure changes, or changed workspace paths cannot be resolved to a workspace package (fail-safe coverage behavior).