Skip to content

Commit d7b9a68

Browse files
perf(ci): parallelize the test suite and split out Rust checks (#7286)
Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>
1 parent e2697d6 commit d7b9a68

1 file changed

Lines changed: 79 additions & 14 deletions

File tree

.github/workflows/ci.yml

Lines changed: 79 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ jobs:
3131
cache: true
3232
run-install: true
3333

34-
- name: Setup Rust
35-
uses: dtolnay/rust-toolchain@stable
36-
with:
37-
components: rustfmt
38-
3934
- name: Ensure Electron runtime is installed
4035
run: vp run --filter @t3tools/desktop ensure:electron
4136

@@ -45,9 +40,6 @@ jobs:
4540
- name: Typecheck
4641
run: vpr typecheck
4742

48-
- name: Check resource monitor formatting
49-
run: cargo fmt --manifest-path native/resource-monitor/Cargo.toml -- --check
50-
5143
- name: Build desktop pipeline
5244
run: vp run build:desktop
5345

@@ -57,6 +49,11 @@ jobs:
5749
grep -nE "desktopBridge|getLocalEnvironmentBootstrap|PICK_FOLDER_CHANNEL|wsUrl" apps/desktop/dist-electron/preload.cjs
5850
grep -n "__clerk_internal_electron_passkeys" apps/desktop/dist-electron/preload.cjs
5951
52+
# Everything except `t3` (apps/server). `--parallel` drops the package
53+
# dependency ordering that `vp run` applies by default: these `test` tasks
54+
# declare no `dependsOn` and resolve workspace deps from source, so ordering
55+
# only bought us idle runners between dependency layers. The concurrency
56+
# limit stays at the default 4 so peak load per runner is unchanged.
6057
test:
6158
name: Test
6259
runs-on: blacksmith-8vcpu-ubuntu-2404
@@ -77,20 +74,65 @@ jobs:
7774
cache: true
7875
run-install: true
7976

80-
- name: Setup Rust
81-
uses: dtolnay/rust-toolchain@stable
82-
8377
- name: Ensure Electron runtime is installed
8478
run: vp run --filter @t3tools/desktop ensure:electron
8579

80+
- name: Test
81+
run: vp run --parallel --concurrency-limit 4 --filter '!t3' --filter '!@t3tools/monorepo' test
82+
83+
# apps/server sets `fileParallelism: false`, so its 239 files run strictly
84+
# one at a time. Sharding spreads them over separate runners instead of
85+
# separate workers, so no two server test files ever share a machine and the
86+
# isolation that flag buys is preserved exactly.
87+
test_server:
88+
name: Test Server ${{ matrix.shard }}
89+
runs-on: blacksmith-8vcpu-ubuntu-2404
90+
timeout-minutes: 10
91+
strategy:
92+
fail-fast: false
93+
matrix:
94+
shard: [1, 2, 3]
95+
steps:
96+
- name: Checkout
97+
uses: actions/checkout@v6
98+
with:
99+
sparse-checkout: |
100+
/*
101+
!/.repos/
102+
sparse-checkout-cone-mode: false
103+
104+
- name: Setup Vite+
105+
uses: voidzero-dev/setup-vp@v1
106+
with:
107+
node-version-file: package.json
108+
cache: true
109+
run-install: true
110+
111+
# No Electron setup here: `t3` (apps/server) has no Electron dependency
112+
# and none of its tests touch the runtime. Only the non-server `test`
113+
# job, which covers @t3tools/desktop, needs the download.
86114
- name: Test
87115
env:
88116
T3CODE_TRANSFER_BUDGET_REPORT_PATH: ${{ runner.temp }}/t3code-transfer-budget.md
89117
T3CODE_TRANSFER_BUDGET_RESULT_PATH: ${{ runner.temp }}/thread-transfer-result.json
90-
run: vp run test
118+
run: vp run --filter t3 test --shard ${{ matrix.shard }}/${{ strategy.job-total }}
119+
120+
# src/server.test.ts writes the budget report, so exactly one shard
121+
# produces these files. Gating the upload on their presence keeps a
122+
# single `thread-transfer-results` artifact per run, which is the name
123+
# thread-transfer-report.yml resolves.
124+
- name: Detect transfer budget report
125+
id: transfer_budget
126+
if: always()
127+
run: |
128+
if test -f "${{ runner.temp }}/thread-transfer-result.json"; then
129+
echo "present=true" >> "$GITHUB_OUTPUT"
130+
else
131+
echo "present=false" >> "$GITHUB_OUTPUT"
132+
fi
91133
92134
- name: Publish transfer budget report
93-
if: always()
135+
if: always() && steps.transfer_budget.outputs.present == 'true'
94136
run: |
95137
if test -f "${{ runner.temp }}/t3code-transfer-budget.md"; then
96138
tee -a "$GITHUB_STEP_SUMMARY" < "${{ runner.temp }}/t3code-transfer-budget.md"
@@ -99,14 +141,37 @@ jobs:
99141
fi
100142
101143
- name: Upload thread transfer result
102-
if: always()
144+
if: always() && steps.transfer_budget.outputs.present == 'true'
103145
uses: actions/upload-artifact@v7
104146
with:
105147
name: thread-transfer-results
106148
path: ${{ runner.temp }}/thread-transfer-result.json
107149
if-no-files-found: ignore
108150
retention-days: 30
109151

152+
# Split out of Check and Test: both paid ~7-9s to install a Rust toolchain
153+
# for checks that take under 3s, on the critical path of every PR.
154+
rust:
155+
name: Rust
156+
runs-on: blacksmith-4vcpu-ubuntu-2404
157+
timeout-minutes: 10
158+
steps:
159+
- name: Checkout
160+
uses: actions/checkout@v6
161+
with:
162+
sparse-checkout: |
163+
/*
164+
!/.repos/
165+
sparse-checkout-cone-mode: false
166+
167+
- name: Setup Rust
168+
uses: dtolnay/rust-toolchain@stable
169+
with:
170+
components: rustfmt
171+
172+
- name: Check resource monitor formatting
173+
run: cargo fmt --manifest-path native/resource-monitor/Cargo.toml -- --check
174+
110175
- name: Test resource monitor
111176
run: cargo test --locked --manifest-path native/resource-monitor/Cargo.toml
112177

0 commit comments

Comments
 (0)