Repository navigation
perf(tests): stop re-importing the whole worker per test file; parallel pre-push gate - #99
Merged
Merged
Conversation
…el pre-push gate - 58 unit tests (+ 2 helpers) only used `env` from `cloudflare:test`, which makes every such file import src/index.ts (~5-10s each). `cloudflare:workers` gives the same bindings without loading the worker. Files that touch Durable Objects (MiniDB, knowledge store, runInDurableObject) keep `cloudflare:test`. Full suite: import 2344s -> ~885s, wall 375s -> ~186s on a loaded machine. - ci-check-fast.sh runs static checks, typecheck, tests, workspaces and the secret scan in parallel; check:bundles stays last (it rewrites _bundles/). - Secret scan in pre-push covers base..HEAD commits (0.1s) instead of the whole tree (16s). Full-tree scan unchanged in ci-check.sh. - typecheck is incremental (3.2s -> 1.1s warm). 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.
Gate was taking 2.5–7.5 min per PR. Measured where it went and cut it.
Root cause: 94% of unit-test wall time was module import, not tests. Every test file that did
import { env } from 'cloudflare:test'loads the whole worker (src/index.ts, 5–10s per file, re-done for each file in a fresh isolate). Most of them only wanted bindings.Changes
envnow comes fromcloudflare:workers(same bindings, no worker load). Files that touch Durable Objects (MiniDB, KnowledgeStore,runInDurableObject) keepcloudflare:test: withcloudflare:workersthey load the worker lazily inside the test and can hit the 10s hook timeout under load.ci-check-fast.sh(pre-push): static checks, typecheck, app tests, the 3 workspaces and the secret scan run in parallel. Output is printed only on failure.check:bundlesruns last and alone because it rewritespublic/_bundles/(the stage-skill-bundle test does too).merge-base..HEADcommits (0.1s) instead of the whole tree (16s).ci-check.shstill does the full-tree scan.typecheckis incremental (3.2s → 1.1s warm; cache innode_modules/.cache).Measured (same machine, other agents running, load 6–24)
SHAREOUT_FULL_TESTS=1 ci-check-fast.sh)test:criticalotp.test.tsaloneFull suite: 550 files / 5207 tests green.
🤖 Generated with Claude Code