Skip to content

Commit a3bf7b0

Browse files
zoomote[bot]roomoteedelauna
authored
[Chore] Add memory-safe Vitest settings for local Docker runs (#2757)
* [Chore] Add memory-safe Vitest settings for local Docker runs Local Vitest runs start one fork worker per CPU and turbo runs ten package tasks at once. Small development containers run out of memory under that load. The new test:local command bundles first, then runs the workspace tests with four Vitest workers and two concurrent Turbo tasks. Both limits are overridable. Local worker caps ride on VITEST_MAX_WORKERS, so CI worker limits, lanes, coverage, and cache contracts stay unchanged. Fixes #2720 * perf: cache staged src lint and keep CI checks fresh * test: model local test runner and replace standalone guide * fix: forward local worker limits through Turbo and strengthen runner checks * fix: honor local test overrides and support standalone pnpm on Windows * Fix local runner review gaps and Windows CI entry point * chore: organize workflow tests and record TLA review results --------- Co-authored-by: Roomote <roomote@roomote.dev> Co-authored-by: Elliott de Launay <edelauna@gmail.com>
1 parent 6df2566 commit a3bf7b0

33 files changed

Lines changed: 1085 additions & 71 deletions

‎.github/workflows/code-qa.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ jobs:
111111
- name: Check formatting
112112
run: pnpm format:check
113113
- name: Lint
114-
run: pnpm lint
114+
run: pnpm lint:ci
115115
- name: Check types
116116
run: pnpm check-types
117117
- name: Test mock authentication
@@ -187,6 +187,8 @@ jobs:
187187
uses: ./.github/actions/setup-node-pnpm
188188
with:
189189
install-args: "--frozen-lockfile"
190+
- name: Validate local test runner
191+
run: pnpm test:local-runner
190192
- name: Restore Turbo cache
191193
id: turbo-cache
192194
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0

‎CONTRIBUTING.md‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,21 @@ This installs the shared templates from `contrib/roo/` into `.roomodes` and `.ro
127127
- One focused PR per feature or fix.
128128
- Follow the ESLint and TypeScript best practices.
129129
- Write clear, descriptive commits that reference issues (for example, `Fixes #123`). Follow the [Writing Style](#writing-style).
130-
- Test your change fully (`npm test`).
130+
- Run focused tests from the package directory, for example `pnpm --dir src exec vitest run __tests__/extension.spec.ts`.
131+
- Use `pnpm test:local` for full local and Docker test runs.
131132
- Run both dead-code checks: `pnpm knip` and `pnpm knip:production`. See [Dead-code checks before review](docs/development-quality-checks.md) for findings, exceptions, and verification.
132133
- Rebase onto the latest `main` branch before you submit.
133134

135+
`pnpm test:local` bundles assets first, then uses four workers per package and two concurrent test tasks.
136+
`--vitest-workers` and `--turbo-concurrency` are optional. Invalid values use the defaults and print a warning.
137+
The test step replaces a shell `VITEST_MAX_WORKERS` value with the selected worker limit.
138+
Extra arguments go only to the test step. A forwarded `--concurrency` sets its Turbo task limit.
139+
For smaller limits, use:
140+
141+
```sh
142+
pnpm test:local -- --vitest-workers=2 --turbo-concurrency=1
143+
```
144+
134145
### Submitting a Pull Request
135146

136147
- Start as a **Draft PR** if you want early feedback.

‎docs/architecture/tla/LintCache.FileReuse.cfg‎

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎docs/architecture/tla/LintCache.NoLocalCache.cfg‎

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎docs/architecture/tla/LintCache.cfg‎

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---------------------------- MODULE LintCache ----------------------------
2+
(* Sources: package.json lint-staged and lint:ci commands. Sink: the extension check in the Code QA Lint step.
3+
Failure: extension CI reuses a passing result after an imported type changes. *)
4+
(* Expectation: extension CI must bypass the ESLint file cache. Removing this bypass must fail ExtensionCiChecksCurrent.
5+
Local cached results provide feedback only. The model does not claim that they check imported type changes. *)
6+
(* File validity, prior results, and current lint results are input oracles. No linter or dependency parser is copied.
7+
The configuration tests check command wiring. The CI extension command runs ESLint directly, outside Turbo. *)
8+
(* Results use 0 for failure, 1 for success, and 2 for a pending check. *)
9+
(* Results: the fixed model passes both invariants over 32 states. Both sabotage configs fail their named policy.
10+
Replay: removing staged caching or the fresh extension command makes the configuration tests fail. *)
11+
(* Validation: workflow tests, the full lint:ci command, formatting, and both Knip checks pass. No suppression counts change.
12+
The configured staged command took 9.47 seconds cold and 0.92 seconds warm during the full lint run. *)
13+
(* A mixed boolean/string result first caused a TLC type error. The corrected result domain uses numeric status values.
14+
ESLint also rejected appending --no-cache to a script with --cache-strategy. The dedicated extension command passes. *)
15+
(* Cost: one agent, about seven minutes including checks. No delegates. No unexpected runtime defect was found.
16+
The model checks cache policy. It does not prove ESLint or Turbo behavior. *)
17+
(* PR #2757 review item 8: this model covers the extension only. Other workspaces keep their existing ESLint cache policy.
18+
The policy is unchanged. Mode and invariant names now state extension scope. Historical totals appear in LocalTestRunner. *)
19+
(* PR #2757 incremental review finding 10: extension lint runs outside Turbo. Remove the unused Turbo cache state.
20+
No claim is made about other workspace caches. Historical totals appear in LocalTestRunner. *)
21+
(* Local Search review, scope finding 1: gap. PR boundaries are outside this command-policy model. No PR thread exists.
22+
The lint source is package.json; its sink is the Code QA Lint step. Both changes stay in this PR at the user's request. *)
23+
(* Review follow-up expectation: no new model failure. Preserve both lint invariants and both sabotage failures.
24+
Failures to prevent: CI reads a stale cache; staged checks lose their separate content cache. *)
25+
(* Review follow-up result: 32 states pass both invariants; both sabotage configs fail. Nine workflow tests pass.
26+
No new model defect was found. Separate branch contents were checked before the user chose to keep one PR. *)
27+
(* Review follow-up cost: one agent, two model gates per subsystem, focused tests, and one branch ownership check. No delegates.
28+
The initial sandbox run failed because TLC could not open a local socket. The permitted run passed. *)
29+
EXTENDS Naturals
30+
CONSTANTS FreshCI, CacheLocal
31+
VARIABLES mode, current, previous, entryValid, outcome
32+
vars == <<mode, current, previous, entryValid, outcome>>
33+
Init == /\ mode \in {"local-extension", "extension-ci"} /\ current \in 0..1 /\ previous \in 0..1
34+
/\ entryValid \in BOOLEAN /\ outcome = 2
35+
Lint == /\ outcome = 2
36+
/\ outcome' = IF mode = "local-extension" THEN
37+
IF CacheLocal /\ entryValid THEN previous ELSE current
38+
ELSE IF ~FreshCI /\ entryValid THEN previous ELSE current
39+
/\ UNCHANGED <<mode, current, previous, entryValid>>
40+
Spec == Init /\ [][Lint]_vars
41+
ExtensionCiChecksCurrent == mode = "extension-ci" /\ outcome # 2 => outcome = current
42+
LocalExtensionCacheIsUsed == mode = "local-extension" /\ entryValid /\ outcome # 2 => outcome = previous
43+
=============================================================================

‎docs/architecture/tla/LocalTestRunner.DropArguments.cfg‎

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎docs/architecture/tla/LocalTestRunner.DropConcurrency.cfg‎

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎docs/architecture/tla/LocalTestRunner.DropWorkers.cfg‎

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎docs/architecture/tla/LocalTestRunner.DuplicateOptions.cfg‎

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)