Skip to content

perf(ci): speed up unit tests with sharding + container scoping#3855

Open
nicktrn wants to merge 24 commits into
mainfrom
perf/speed-up-unit-tests-tri-10484
Open

perf(ci): speed up unit tests with sharding + container scoping#3855
nicktrn wants to merge 24 commits into
mainfrom
perf/speed-up-unit-tests-tri-10484

Conversation

@nicktrn
Copy link
Copy Markdown
Collaborator

@nicktrn nicktrn commented Jun 6, 2026

Speeds up and de-flakes the unit-test suite: testcontainers booted once per vitest worker (per-test isolation kept only where a test runs background redis work that outlives it), a duration-weighted shard sequencer so each shard does roughly equal work, the slowest suites split, two genuine flakes fixed (streamBatchItems shared-redis leak; run-engine waits that relied on fixed sleeps), and transient DockerHub pulls retried.

Timings (CI, per-shard wall): worst unit-test shard ~771s → ~294s; packages/webapp shards ~250-270s, most internal ~190-240s. All 25 shards green.

A shard breaks down as ~70s fixed setup (install / image-pull / generate) + ~70s cold ^build + the actual container tests. So the remaining cost is mostly the tests themselves plus that fixed setup.

Next (separate, timings):

  • typecheck (~6m24s) — the slowest check overall; bound by full-graph tsc, not the TS version (a TS6 branch is still ~6m17s). The real lever is tsgo (the Go compiler).
  • Possible later: turbo CI caching could trim the ~70s cold build on warm runs, but it's conditional (cold runs rebuild anyway) and doesn't touch setup or test time — secondary.

cli-v3 e2e and sdk-compat are path-gated (don't run on test-infra changes) and already comfortably fast.

nicktrn added 18 commits June 6, 2026 18:51
@nicktrn nicktrn self-assigned this Jun 6, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 6, 2026

⚠️ No Changeset found

Latest commit: 8ac6ad4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 6, 2026

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

This PR adds duration-weighted test sharding (DurationShardingSequencer + test-timings.json), updates Vitest configs to use the sequencer, expands CI test shard matrices and adds Docker pull retry wrappers, refactors testcontainers to worker-scoped containers with per-test reset fixtures (Postgres template/clone, worker Redis/ClickHouse/MinIO), adds ClickHouse/MinIO reset helpers and timing tooling, and migrates/introduces many replication and repository integration tests to the new harnesses.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.93% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'perf(ci): speed up unit tests with sharding + container scoping' clearly and specifically summarizes the main performance improvement across the entire changeset—optimizing CI test execution through sharding and container reuse.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description adequately covers the major changes: testcontainers scoping, duration-weighted sharding, suite splitting, flake fixes, and retry logic for Docker pulls.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/speed-up-unit-tests-tri-10484

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 0 potential issues.

View 6 additional findings in Devin Review.

Open in Devin Review

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 0 new potential issues.

View 10 additional findings in Devin Review.

Open in Devin Review

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 0 new potential issues.

View 14 additional findings in Devin Review.

Open in Devin Review

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 0 new potential issues.

View 15 additional findings in Devin Review.

Open in Devin Review

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 0 new potential issues.

View 17 additional findings in Devin Review.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant