Skip to content

[ci] Speed up package tests by enabling parallel execution#13601

Merged
petebacondarwin merged 1 commit into
mainfrom
pbacondarwin/speed-up-packages-ci
Apr 20, 2026
Merged

[ci] Speed up package tests by enabling parallel execution#13601
petebacondarwin merged 1 commit into
mainfrom
pbacondarwin/speed-up-packages-ci

Conversation

@petebacondarwin

@petebacondarwin petebacondarwin commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

Fixes no specific issue — CI performance improvement. Companion to #13596 (which does the same for fixture tests).

The packages-and-tools CI job runs all package test suites serially (--concurrency=1), taking ~9.5 min on Linux and ~20 min on Windows. The three heaviest packages dominate:

Package Linux Windows
wrangler 282s 489s
miniflare 108s 434s
vitest-pool-workers 73s (skipped)
everything else ~30s ~50s

Since these run sequentially today, the total is the sum. With parallel execution, the total is bounded by the slowest package (wrangler).

Why Parallel Execution Is Safe

All packages are well-isolated:

  • Wrangler: purely in-process tests — runWrangler(cmd) calls main() directly with MSW for API mocking, runInTempDir() for filesystem isolation, mocked get-port (no real ports). Pool: forks (each test file is its own process).
  • Miniflare: pool: "forks", maxWorkers: 1 (sequential internally), server.listen(0) for random ports, .tmp/ local to package root.
  • vitest-pool-workers: private Verdaccio npm registry on random port via getPort(), workerd on random ports, temp dirs in os.tmpdir() with unique prefixes.
  • All other packages: lightweight unit tests with no shared resources (vite-plugin, create-cloudflare, workers-shared, etc.)

No shared ports, sockets, temp directories, dev registry usage, or environment variables between packages.

Change

Remove --concurrency=1 from the packages test Turbo command, letting Turbo parallelize based on the dependency graph and available CPU cores.

Validation

Ran package tests locally 4 times with unlimited concurrency. All runs passed with zero retries:

Run Tasks Result Time
1 34/34 Pass 2m14s
2 34/34 Pass 2m08s
3 34/34 Pass 2m07s
4 34/34 Pass 2m04s

Expected CI improvement:

  • Linux: ~9.5min → ~5min (wrangler at 282s is the critical path)
  • Windows: ~20min → ~9-10min (wrangler at 489s is the critical path)

Risks & Fallback

The main risk is resource pressure on CI runners (4 vCPUs, 16GB RAM) when wrangler (forks pool, 233 test files) runs alongside miniflare (workerd processes). If this causes OOM or increased flakiness, we can set --concurrency=3 as a middle ground.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: CI-only change, no user-facing impact

Open in Devin Review

Remove --concurrency=1 from the packages test CI command, letting Turbo
parallelize package test suites across available cores.

Package tests are well-isolated and safe to run in parallel:
- Wrangler: in-process tests with MSW mocks, runInTempDir(), mocked ports
- Miniflare: forks pool with maxWorkers=1, port 0, package-local .tmp/
- vitest-pool-workers: private Verdaccio on random port, isolated temp dirs
- All other packages: lightweight unit tests with no shared resources

Validated locally: 4 consecutive runs with unlimited concurrency, all 34/34
tasks passing with zero retries. Execution time drops from ~9.5min (serial)
to ~2min (parallel).
@petebacondarwin petebacondarwin added the ci:no-changeset-required Skip pull request checks for a valid changeset label Apr 19, 2026
@changeset-bot

changeset-bot Bot commented Apr 19, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 26062d0

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.

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

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Apr 19, 2026
@workers-devprod workers-devprod requested review from a team and emily-shen and removed request for a team April 19, 2026 21:15
@workers-devprod

workers-devprod commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@ask-bonk

ask-bonk Bot commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

UnknownError: ProviderInitError

github run

@ask-bonk

ask-bonk Bot commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

@petebacondarwin Bonk workflow failed. Check the logs for details.

View workflow run · To retry, trigger Bonk again.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@petebacondarwin petebacondarwin added the ci-flake Applied to PRs addressing CI flakiness label Apr 19, 2026
@pkg-pr-new

pkg-pr-new Bot commented Apr 19, 2026

Copy link
Copy Markdown
create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@13601

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@13601

miniflare

npm i https://pkg.pr.new/miniflare@13601

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@13601

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@13601

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@13601

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@13601

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@13601

wrangler

npm i https://pkg.pr.new/wrangler@13601

commit: 26062d0

@dario-piotrowicz dario-piotrowicz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@workers-devprod workers-devprod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Apr 19, 2026
@petebacondarwin petebacondarwin merged commit 5535ffc into main Apr 20, 2026
69 of 78 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Apr 20, 2026
@petebacondarwin petebacondarwin deleted the pbacondarwin/speed-up-packages-ci branch April 20, 2026 05:32
petebacondarwin added a commit that referenced this pull request Apr 20, 2026
Follow-up to #13596 and #13601 which removed --concurrency=1 entirely.
Unlimited concurrency caused CPU starvation on 4-vCPU CI runners when
20+ workerd-spawning fixtures or 3+ heavyweight package suites ran
simultaneously, leading to test timeouts.

Changes:
- Cap fixture concurrency at 4 (was unlimited, previously 1)
- Cap package concurrency at 3 (was unlimited, previously 1)
- Add testTimeout: 50_000 to 6 vitest configs that were using Vitest's
  default 5000ms instead of the repo standard 50s from vitest.shared.ts:
  workers-shared/asset-worker, workers-shared/router-worker,
  vite-plugin-cloudflare, edge-preview-authenticated-proxy,
  kv-asset-handler, pages-shared
- Increase start-worker-node-test timeout from 15s to 50s

The timeout fixes address pre-existing fragility - these configs never
extended vitest.shared.ts and relied on Vitest's 5s default, which is
insufficient under any CPU load.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:no-changeset-required Skip pull request checks for a valid changeset ci-flake Applied to PRs addressing CI flakiness

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants