Repository navigation
Conversation
A test that fails a few percent of the time usually passes the one CI run it gets before landing. Add a "Repeat changed tests" job that runs every Vitest file a PR adds or edits in five Vitest processes started together, with retries disabled, on Linux, macOS and Windows. It fails if any run fails, and the Tests gate requires it. tools/test/repeat-changed-tests.ts picks the test files from the PR's diff, groups them by the closest vitest.config.* in their workspace package, builds those packages, and keeps only the files each config really runs. The job summary lists how many runs each file passed and which tests failed; logs and JSON reports are uploaded as artifacts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/cli-shared-helpers
@cloudflare/codemods
@cloudflare/config
@cloudflare/containers-shared
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/runtime-types
@cloudflare/test-server
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-plugin
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
Contributor
|
I'm Bonk, and I've done a quick review of your PR. Adds a required cross-platform job that repeats changed Vitest files concurrently.
|
danlapid
force-pushed
the
dlapid/repeat-changed-tests
branch
from
November 25, 2026 22:54
b0e7976 to
8983dc8
Compare
Address review findings on the repeat job: - Start Vitest from the package root with the package's own config, so projects and their platform exclusions apply. Packages without one, such as workers-shared, use the subdirectory's config with --dir, as their scripts do. - Run each package's pretest:ci hook first, e.g. to install Playwright's Chromium, via a new test:ci:repeat-changed script. - Skip packages the test partitions leave out on the platform: Browser Run fixtures on Linux, vitest-plugin on Windows. - Run fixture repeats one after another. Concurrent copies of a `wrangler dev` fixture share its .wrangler/state (SQLITE_BUSY) and dev registry entries, which a single run never does. - Drop `vitest list`, which never exited in vitest-plugin-examples; runs pass --passWithNoTests and report unrun files as skipped. - Read `git diff -z` so non-ASCII paths are not quoted, and list end-to-end tests as skipped. Drop --out-dir, so the runner only ever clears its own .turbo/repeat-tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pnpm runs scripts through cmd.exe on Windows, which treats `^` as an escape character, so `--base=HEAD^1` reached git as `HEAD1`. Use `HEAD~1`, the same commit. Skip packages that have no default Vitest config for a file but do have a custom-named one, such as vitest.workers.config.ts: only their own scripts know how to run those files. This covers the two remote bindings fixtures and the Vite plugin playground's e2e config. A file that several projects run is reported once per project; merge the failures instead of keeping the last report. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
readWorkspace's directory scan decides which packages run Vitest, need a pretest:ci hook, or use custom-named configs. Check it on real packages, including the remote bindings fixture and a non-ASCII playground directory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous test read the real repository, which the tools suite's Turbo cache key does not cover, so a cached pass could hide a regression. Build a small workspace in a temporary directory instead. Its CRLF pnpm-workspace.yaml found a bug: `.` in a JavaScript regular expression does not match `\r`, so a CRLF checkout of the workspace manifest failed to parse. Match `[^\n]` instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mirror the real manifest's shapes: a nested playground glob, the playground directory itself, and a plain `tools` entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Nothing in CI runs a new or edited test more than once before it lands. The Miniflare and Wrangler suites run without retries, but each test still gets one attempt per OS. A test that fails only a few percent of the time passes that, and the flake shows up afterwards on other PRs. The local Artifacts port race fixed in #17182 is an example: it failed about 8% of runs on workerd's "Run workers-sdk tests" check, which runs five suites at once on one runner, but rarely here.
This adds a
Repeat changed testsjob totest-and-check.yml. On each PR it:*.test.*/*.spec.*files the PR adds or edits (git diff HEAD^1 HEADon the PR's merge commit). If none, it stops after checkout, before installing dependencies.test:cidoes, with the package's ownvitest.config.*, so its projects and their platform exclusions apply. A package without one, such asworkers-shared, uses the subdirectory's config with--dir, as its scripts do.test:cidoes, and runs theirpretest:cihooks once, for example to install Playwright's Chromium.--retry=0, so the tests also run under CPU and port contention, like workerd's check. Fixtures run their five runs one after another instead. They startwrangler devagainst their own directory, so concurrent copies share its.wrangler/state(one SPA fixture run failed withSQLITE_BUSYthis way) and its dev registry entries, which a single run never does. The job fails if any run fails.The job summary lists every skipped file and why:
@cloudflare/vitest-pluginon Windows);The job summary has a table of passing runs per file, with the names of the tests that failed, and each failing file gets an error annotation. Each run's log and Vitest JSON report are uploaded as the
repeat-changed-tests-<os>artifact. The script istools/test/repeat-changed-tests.ts. To run it locally:pnpm run test:ci:repeat-changed --base=origin/main.Choices for reviewers to weigh in on:
Testsgate requires it. Otherwise a red run is easy to ignore. If you'd rather start with it advisory, drop it from the gate'sneeds.toolstest file). With a Miniflare file it took 2m01s on Windows, 1m22s on Linux and 3m34s on macOS. That is well inside the 30-minute timeout and shorter than the test partitions, so I kept all three OSes. Restricting the matrix toubuntu-latestis a one-line change if it proves too slow.0. Retries a test sets on itself, such asit("…", { retry: 2 }), still apply..github/workflows/README.md, next to the retry diagnostics.Testing:
tools/test/__tests__/repeat-changed-tests.test.ts. Being a changed test file, it is what this PR's own job runs five times: 5/5 on Linux, macOS and Windows (run).workers-shared/asset-worker/tests/analytics.test.ts(subdirectory config),vitest-plugin-examples/durable-objects/test/sqlite-in-do.test.ts(root projects),workers-with-assets-spa/tests/index.test.ts(Chromiumpretest:ci, sequential runs) and the new tools test.playground/worker-♫/…/worker.spec.tsis reported by name as skipped.1/5with the failing test's name, and wrote the annotation.toolssuite (358 tests),tsc,oxfmt --check,oxlint --deny-warnings --type-aware, and the action-pinning check pass.🤖 Generated with Claude Code