test: reduce suite latency with safe sharding - #832
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThe PR replaces the serial default Bun test command with a supervisor that runs the suite in independent file shards while avoiding Bun’s isolated parallel-worker mode.
Confidence Score: 4/5The PR appears safe to merge, with one non-blocking repository-convention issue around direct environment-variable access. The shard orchestration has no established blocking failure, but the new supervisor bypasses the prescribed validated environment interface when reading the shard override and forwarding child environments. Files Needing Attention: scripts/run-test-suite.ts Important Files Changed
Sequence DiagramsequenceDiagram
participant U as Caller / CI
participant R as run-test-suite.ts
participant S1 as Bun shard 1
participant S2 as Bun shard 2
U->>R: bun run test [args]
R->>R: Resolve shard count
par Launch file shards
R->>S1: "bun test --shard=1/2 patterns"
R->>S2: "bun test --shard=2/2 patterns"
end
alt Interrupt or partial launch
U-->>R: SIGINT / SIGTERM
R-->>S1: Forward signal, then SIGKILL
R-->>S2: Forward signal, then SIGKILL
else Normal completion
S1-->>R: Exit code
S2-->>R: Exit code
R-->>U: Combined success/failure status
end
Prompt To Fix All With AI### Issue 1
scripts/run-test-suite.ts:76
**Direct environment access bypasses validation**
The new supervisor reads `HUNK_TEST_SHARDS` directly from `process.env` and also spreads `process.env` into each child at line 87, bypassing the repository-prescribed type-safe environment interface and establishing an inconsistent configuration-access pattern.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "test: reduce suite latency with safe sha..." | Re-trigger Greptile |
|
|
||
| /** Run the default suite in independent Bun processes without enabling Bun's isolate mode. */ | ||
| export async function main(args = Bun.argv.slice(2)) { | ||
| const shardCount = resolveTestShardCount(availableParallelism(), process.env.HUNK_TEST_SHARDS); |
There was a problem hiding this comment.
Direct environment access bypasses validation
The new supervisor reads HUNK_TEST_SHARDS directly from process.env and also spreads process.env into each child at line 87, bypassing the repository-prescribed type-safe environment interface and establishing an inconsistent configuration-access pattern.
Context Used: guidelines.mdc Cursor rule (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/run-test-suite.ts
Line: 76
Comment:
**Direct environment access bypasses validation**
The new supervisor reads `HUNK_TEST_SHARDS` directly from `process.env` and also spreads `process.env` into each child at line 87, bypassing the repository-prescribed type-safe environment interface and establishing an inconsistent configuration-access pattern.
**Context Used:** guidelines.mdc Cursor rule ([source](https://github.com/modem-dev/modem/blob/main/.cursor/rules/guidelines.mdc))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Summary
--parallelisolation path, which breaks OpenTUI native FFI initializationBenchmark
Bun 1.3.14 on Linux with the full 3,027-test suite:
This reduces local wall time by about 42%. Under a simulated two-vCPU affinity, two shards reduced wall time from 46.4s to 29.3s. On Linux, higher shard counts remain available through
HUNK_TEST_SHARDS, while the automatic default stays capped at two.Validation
bun run testbun test scripts/run-test-suite.test.tsbun run typecheckbun run lint--no-orphansmust be omitted and daemon assertions must follow the serving child PIDThis PR description was generated by Pi using gpt-5.6-sol