Skip to content

ci: shard the full-suite coverage run across a matrix - #4815

Merged
JSONbored merged 3 commits into
mainfrom
perf/ci-shard-coverage
Jul 11, 2026
Merged

ci: shard the full-suite coverage run across a matrix#4815
JSONbored merged 3 commits into
mainfrom
perf/ci-shard-coverage

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • validate-code's "Test with coverage" step was ~9-10 of the ~11 minutes a typical backend PR spent in CI (confirmed via real timing pulled from ~15 recent CI runs): vitest schedules whole test files atomically to workers, so a single job with --maxWorkers=4 (a standard GitHub-hosted runner's real CPU budget) is capped at 4-way parallelism no matter how many test files exist.
  • Adds a new validate-tests job, matrixed 4 ways over vitest's own --shard=<i>/<n> flag, giving N*4-way parallelism instead of 4-way.
  • Each shard uploads its own lcov.info + junit report to Codecov; multiple uploads for the same commit/PR are additive there (standard pattern for matrix-split suites).
  • Sets COVERAGE_NO_THRESHOLDS=true per shard, wiring up vitest.config.ts's existing (previously dormant/unused) support for it -- a shard only exercises part of the tree, so the global 90% backstop threshold would otherwise always false-fail per shard.
  • validate-code keeps everything else (drift checks, typecheck, build engine, worker runtime tests, MCP/miner build+pack, REES, UI toolchain) as a single job, since those are fast (~1 min total) and don't benefit from a matrix.
  • This is a public repo, so standard GitHub-hosted runners are free regardless of job count -- this costs nothing extra, only wall-clock time drops.
  • Updates the two workflow-introspection tests (codecov-policy.test.ts, workflow-runner-labels.test.ts) that asserted the old single-job shape.

Why

Investigated at the user's request: CI validate was taking 10+ minutes per PR. Real timing data from recent runs showed ~85-95% of that was the single unsharded coverage step; everything else (path-filtered drift checks, typecheck, UI toolchain) was already fast thanks to the existing changes/paths-filter job.

Best paired with #4814 (splitting the two oversized test files) for balanced shards, but works standalone too.

Test plan

  • npx tsc --noEmit clean
  • npm run actionlint clean
  • YAML parses (python3 -c "import yaml; yaml.safe_load(...)")
  • Verified --shard=<i>/<n> + COVERAGE_NO_THRESHOLDS=true locally: threshold failure reproduces without the flag, disappears with it, and still produces a valid coverage report
  • Updated codecov-policy.test.ts / workflow-runner-labels.test.ts assertions now pass against the new job shape

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.23%. Comparing base (fe592b8) to head (0194dce).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4815   +/-   ##
=======================================
  Coverage   94.23%   94.23%           
=======================================
  Files         442      442           
  Lines       38845    38845           
  Branches    14150    14150           
=======================================
  Hits        36607    36607           
  Misses       1577     1577           
  Partials      661      661           
Flag Coverage Δ
shard-1 51.48% <ø> (?)
shard-2 45.40% <ø> (?)
shard-3 41.95% <ø> (?)
shard-4 52.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 11, 2026
@loopover-orb

loopover-orb Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-11 00:38:03 UTC

3 files · 1 AI reviewer · 2 blockers · readiness 93/100 · CI green · unstable

⏸️ Suggested Action - Manual Review

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.

Review summary
This PR splits the dominant ~9-10min unsharded coverage step out of validate-code into a new 4-way matrixed validate-tests job using vitest's native --shard flag, moving Codecov uploads to per-shard flags and updating the two workflow-introspection tests to match the new job shape. The mechanical restructuring (job split, needs/if wiring, test assertions) is internally consistent and well-traced against the visible diff. The one real concern is that COVERAGE_NO_THRESHOLDS=true is now set unconditionally on every shard invocation (push and PR alike), which per the PR's own description disables vitest.config.ts's global coverage threshold check entirely — no job in this workflow ever runs with that backstop enabled anymore.

Blockers

  • ci.yml (validate-tests 'Test with coverage' step): COVERAGE_NO_THRESHOLDS is now hardcoded to "true" for every shard on every trigger (push included), so the global vitest coverage-threshold backstop that previously ran in the single unsharded job is now never enforced anywhere in CI — only Codecov's patch-coverage gate remains, which is a narrower check (changed-lines only, not whole-repo floor); confirm an equivalent whole-repo floor is enforced elsewhere (Codecov project-level target, a merge-then-check step) or explain why dropping it is acceptable.
Nits — 6 non-blocking
  • Each of the 4 validate-tests shards independently rebuilds the engine package and reinstalls node_modules on a cache miss, so cache-miss PRs pay ~4x the install/build cost that a single job did before — acceptable on free runners but worth a comment if wall-clock during cache misses becomes noticeable.
  • No concurrency/cancel-in-progress group is visible for the new validate-tests matrix in the diff — confirm superseded runs on force-pushes actually get cancelled rather than piling up 4 extra jobs per push.
  • PR description frames this as CI-only investigation 'at the user's request' but doesn't link a tracked issue — worth confirming this counts as maintainer-authorized operator work under the issue-linking policy, since it's otherwise unsolicited infra churn.
  • Consider gating COVERAGE_NO_THRESHOLDS so at least the `push` trigger (or a periodic scheduled run) still executes an unsharded, threshold-enforced full suite, preserving the whole-repo floor separately from per-shard patch coverage.
  • codecov-policy.test.ts and workflow-runner-labels.test.ts updates look correctly re-pointed at validate-tests — no fabricated assertions spotted, but worth adding one test asserting COVERAGE_NO_THRESHOLDS is actually read somewhere (vitest.config.ts) to close the loop this PR claims to wire up.
  • Diff looks like trivial or whitespace-only churn — Reduce whitespace-only or formatting-only churn and keep the diff focused on substantive changes.

Concerns raised — review before merging

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.
Signal Result Evidence
Code review ❌ 2 blockers 1 reviewer
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 48 registered-repo PR(s), 40 merged, 275 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 48 PR(s), 275 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 48 PR(s), 275 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

validate-code's "Test with coverage" step was ~9-10 of the ~11 minutes a
typical backend PR spent in CI: vitest schedules whole test files
atomically to workers, so a single job with --maxWorkers=4 (a standard
runner's real CPU budget) is capped at 4-way parallelism no matter how
many test files exist.

Split it into a new validate-tests job, matrixed 4 ways over vitest's
own --shard=<i>/<n> flag, giving N*4-way parallelism instead. Each shard
uploads its own lcov.info + junit report to Codecov; multiple uploads
for the same commit/PR are additive there, which is the standard pattern
for matrix-split suites. Sets COVERAGE_NO_THRESHOLDS=true per shard,
finally wiring up vitest.config.ts's existing (previously dormant)
support for it -- a shard only exercises part of the tree, so the global
90% backstop threshold would otherwise always false-fail per shard.

validate-code keeps everything else (drift checks, typecheck, build
engine, worker runtime tests, MCP/miner build+pack, REES, UI toolchain)
as a single job, since those are fast and don't benefit from sharing a
matrix. The public repo's standard runners are free regardless of job
count, so this costs nothing extra -- only wall-clock time drops.

Updates the two workflow-introspection tests (codecov-policy,
workflow-runner-labels) that asserted the old single-job shape.
…erage

The AI review agent correctly flagged that sharding disabled
vitest.config.ts's global 90% coverage-threshold check everywhere in CI
(COVERAGE_NO_THRESHOLDS=true on every shard, unconditionally), leaving
only Codecov's patch gate -- which only covers changed lines, not a
whole-repo regression outside the diff (e.g. a deleted test file).

Add a validate-tests-merge job: each shard now also writes a vitest
blob report (--reporter=blob) and uploads it as a build artifact;
validate-tests-merge downloads all 4, merges them via vitest's own
--mergeReports, and re-runs the global threshold check (without
COVERAGE_NO_THRESHOLDS) against the combined whole-suite result --
restoring the exact backstop the old single unsharded job had.
@JSONbored
JSONbored force-pushed the perf/ci-shard-coverage branch from 71646d3 to fde6376 Compare July 11, 2026 00:54
merge-multiple download-artifact flattens all 4 shards into one
directory; every shard wrote to blob-report/report.blob, so they
collided/corrupted on download (vitest's readBlobs failed with a JSON
syntax error mid-file). Suffix each shard's blob filename with its
shard index so they land in all-blob-reports/ without colliding.
@JSONbored
JSONbored merged commit 20c412b into main Jul 11, 2026
15 checks passed
@JSONbored
JSONbored deleted the perf/ci-shard-coverage branch July 11, 2026 01:04
JSONbored added a commit that referenced this pull request Jul 11, 2026
…nner CPU count (#4951)

validate-code's Codecov upload steps moved to validate-tests when
coverage was split out (#4815) -- it no longer needs fetch-depth: 0
(measured: shallow checkout is ~3s faster than full-history on this
repo). Also adds a temporary nproc diagnostic to validate-tests to
check whether --maxWorkers=4 (pinned to the assumed standard-runner
vCPU count) actually matches the real runner spec, or whether there's
free parallelism available without adding more shards.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. manual-review Gittensor contributor context

Development

Successfully merging this pull request may close these issues.

1 participant