Skip to content

Commit fd9b01e

Browse files
ci(release): shard test gate into 5 isolated parallel processes to eliminate cross-file DB contamination
1 parent 9526ba0 commit fd9b01e

1 file changed

Lines changed: 60 additions & 5 deletions

File tree

.github/workflows/release.yml

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,36 @@ permissions:
1010

1111
jobs:
1212
test:
13-
name: Test
13+
# Sharded test matrix. The full 840-file suite is split across disjoint
14+
# path subsets so each shard is a FRESH `bun test` process over far fewer
15+
# files. This eliminates the cross-file contamination that flaked the
16+
# money-path DB tests (global sqlite singleton via setDatabasePathForTesting)
17+
# when the whole suite ran in one process, and it runs faster in parallel.
18+
# Each shard picks up bunfig [test].preload (the global reset) automatically.
19+
#
20+
# COVERAGE INVARIANT: the union of every shard's `paths` MUST cover every
21+
# *.test.ts file under src/ (plus the 2 script tests) with NO file matched
22+
# by zero shards and NONE matched by two. `infra-rest` in particular must
23+
# list EVERY src/infra subdir that is NOT already claimed by `agents` or
24+
# `money-path` — bun test path args cannot express "src/infra MINUS those",
25+
# so new src/infra subdirs must be added here by hand. A missed subdir =
26+
# untested code shipping. Verified by enumerating find src -name '*.test.ts'.
27+
name: Test (${{ matrix.shard-name }})
1428
runs-on: ubuntu-latest
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
include:
33+
- shard-name: core
34+
paths: src/core
35+
- shard-name: agents
36+
paths: src/infra/agents
37+
- shard-name: money-path
38+
paths: src/infra/trading src/infra/safety src/infra/storage src/infra/exchange src/infra/broker
39+
- shard-name: infra-rest
40+
paths: src/infra/acp src/infra/action-log src/infra/ai src/infra/auth src/infra/calibration src/infra/cli src/infra/config src/infra/context src/infra/data src/infra/diagnostics src/infra/domain src/infra/execution src/infra/hooks src/infra/logger src/infra/memory src/infra/news src/infra/observability src/infra/permissions src/infra/platform src/infra/proactive src/infra/protocols src/infra/runtime src/infra/scheduler src/infra/security src/infra/skills src/infra/testing src/infra/tools src/infra/venues
41+
- shard-name: app-ui
42+
paths: src/tui src/app src/runtime src/backtest src/services src/gateway src/utils src/events src/types src/cli.test.ts scripts/dev/harness scripts/research/scans
1543
steps:
1644
- name: Checkout
1745
uses: actions/checkout@v4
@@ -36,8 +64,34 @@ jobs:
3664
- name: Patch Bun-incompatible dependencies
3765
run: node scripts/patches/patch-mastra.cjs
3866

39-
- name: Run tests
40-
run: bun test
67+
- name: Run tests (shard ${{ matrix.shard-name }})
68+
run: bun test ${{ matrix.paths }}
69+
70+
# Single-shard gates: broker conformance, latency, and typecheck are
71+
# suite-wide and must run exactly ONCE, not redundantly per test shard.
72+
test-gates:
73+
name: Test Gates (conformance + typecheck)
74+
runs-on: ubuntu-latest
75+
steps:
76+
- name: Checkout
77+
uses: actions/checkout@v4
78+
79+
- name: Setup Bun
80+
uses: oven-sh/setup-bun@v2
81+
82+
- name: Cache bun install
83+
uses: actions/cache@v4
84+
with:
85+
path: ~/.bun/install/cache
86+
key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }}
87+
restore-keys: |
88+
bun-${{ runner.os }}-
89+
90+
- name: Install dependencies (frozen lockfile)
91+
run: bun install --frozen-lockfile
92+
93+
- name: Patch Bun-incompatible dependencies
94+
run: node scripts/patches/patch-mastra.cjs
4195

4296
- name: Run broker conformance matrix
4397
run: bun run test:broker-conformance
@@ -50,7 +104,7 @@ jobs:
50104

51105
verify-npm-wrapper:
52106
name: Verify npm Wrapper (${{ matrix.os }})
53-
needs: test
107+
needs: [test, test-gates]
54108
runs-on: ${{ matrix.os }}
55109
env:
56110
GORDON_NPM_VERSION: ${{ github.ref_name }}
@@ -91,7 +145,7 @@ jobs:
91145

92146
verify-public-dist:
93147
name: Verify Public Dist Bundle
94-
needs: test
148+
needs: [test, test-gates]
95149
runs-on: ubuntu-latest
96150
steps:
97151
- name: Checkout
@@ -112,6 +166,7 @@ jobs:
112166
name: Create Source Release
113167
needs:
114168
- test
169+
- test-gates
115170
- verify-npm-wrapper
116171
- verify-public-dist
117172
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)