Open History to see the last commit
1name: CI
2
3on:
4 pull_request:
5 push:
6 branches:
7 - main
8
9permissions:
10 contents: read
11
12concurrency:
13 group: ci-${{ github.event.pull_request.number || github.sha }}
14 cancel-in-progress: ${{ github.event_name == 'pull_request' }}
15
16jobs:
17 # Skips jobs a pull request cannot affect: a web change does not run the
18 # server shards, a server change does not run the mobile tests, and the macOS
19 # lint (~6.7x a Linux minute) runs only for native mobile sources.
20 # .github/scripts/ci-changes.cjs maps changed files to workspace packages and
21 # their dependents. Pushes to main still run every Linux job. Detection fails
22 # open: if the diff cannot be resolved, everything runs.
23 changes:
24 name: Changes
25 runs-on: blacksmith-2vcpu-ubuntu-2404
26 timeout-minutes: 5
27 outputs:
28 typecheck: ${{ steps.detect.outputs.typecheck }}
29 build: ${{ steps.detect.outputs.build }}
30 test: ${{ steps.detect.outputs.test }}
31 test_packages: ${{ steps.detect.outputs.test_packages }}
32 test_web: ${{ steps.detect.outputs.test_web }}
33 test_server: ${{ steps.detect.outputs.test_server }}
34 rust: ${{ steps.detect.outputs.rust }}
35 release_smoke: ${{ steps.detect.outputs.release_smoke }}
36 mobile_native: ${{ steps.detect.outputs.mobile_native }}
37 steps:
38 # Only the package manifests the script reads to build the dependency graph.
39 # Depth 2 brings the base commit the change is diffed against.
40 - name: Checkout
41 uses: actions/checkout@v6
42 with:
43 fetch-depth: 2
44 sparse-checkout: |
45 /pnpm-workspace.yaml
46 /.github/scripts/ci-changes.cjs
47 /.github/actions/ci-changes/
48 /*/package.json
49 /*/*/package.json
50 !/.repos/
51 sparse-checkout-cone-mode: false
52
53 - name: Detect affected jobs
54 id: detect
55 uses: ./.github/actions/ci-changes
56
57 # Lint and the desktop build each get a runner so they run side by side.
58 # Typecheck shares the build's install. Lint always runs: it formats every
59 # file, docs included. The `Check` job at the end of this file passes only
60 # when every other job passes or was skipped by `changes`.
61 lint:
62 name: Lint
63 runs-on: blacksmith-8vcpu-ubuntu-2404
64 timeout-minutes: 10
65 steps:
66 - name: Checkout
67 uses: actions/checkout@v6
68 with:
69 sparse-checkout: |
70 /*
71 !/.repos/
72 !/apps/mobile/modules/t3-terminal/Vendor/**/*.a
73 sparse-checkout-cone-mode: false
74
75 - name: Reject repository-owned PR assets
76 run: |
77 files="$(git ls-files .github/pr-assets)"
78 if test -n "$files"; then
79 printf 'PR evidence must be uploaded to GitHub, not committed:\n%s\n' "$files" >&2
80 exit 1
81 fi
82
83 - name: Setup Vite+
84 uses: ./.github/actions/setup-ci-deps
85
86 - name: Ensure Electron runtime is installed
87 run: vp run --filter @t3tools/desktop ensure:electron
88
89 # Files/dependencies are repo-wide; export checks cover clean workspaces only.
90 - name: Check unused code
91 run: vp run knip:check
92
93 - name: Check generated GitHub GraphQL operations
94 run: vp run --filter @t3tools/source-control-github generate --check
95
96 - name: Check generated Expo GraphQL operations
97 run: vp run --filter t3 generate --check
98
99 - name: Check
100 run: vp check
101
102 build:
103 name: Build and Typecheck
104 needs: changes
105 if: ${{ !cancelled() && (needs.changes.outputs.build != 'false' || needs.changes.outputs.typecheck != 'false') }}
106 runs-on: blacksmith-8vcpu-ubuntu-2404
107 timeout-minutes: 10
108 steps:
109 - name: Checkout
110 uses: actions/checkout@v6
111 with:
112 sparse-checkout: |
113 /*
114 !/.repos/
115 !/apps/mobile/modules/t3-terminal/Vendor/**/*.a
116 sparse-checkout-cone-mode: false
117
118 - uses: ./.github/actions/setup-apt-mirrors
119 if: needs.changes.outputs.build != 'false'
120
121 # Runs in the background while Vite+ installs; the step before the build waits for it.
122 - name: Start installing browser secret helper build libraries
123 if: needs.changes.outputs.build != 'false'
124 run: |
125 sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
126 (
127 set +e
128 sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config
129 echo "$?" > "$RUNNER_TEMP/apt-status"
130 ) > "$RUNNER_TEMP/apt.log" 2>&1 < /dev/null &
131
132 - name: Setup Vite+
133 uses: ./.github/actions/setup-ci-deps
134
135 - name: Ensure Electron runtime is installed
136 id: electron
137 run: vp run --filter @t3tools/desktop ensure:electron
138
139 # Runs in the background while the build runs, and reports in the last
140 # step: neither result hides the other.
141 - name: Start typecheck
142 id: typecheck
143 if: ${{ !cancelled() && steps.electron.outcome == 'success' && needs.changes.outputs.typecheck != 'false' }}
144 run: |
145 (
146 set +e
147 vpr typecheck
148 echo "$?" > "$RUNNER_TEMP/typecheck-status"
149 ) > "$RUNNER_TEMP/typecheck.log" 2>&1 < /dev/null &
150
151 - name: Finish installing browser secret helper build libraries
152 id: apt
153 if: ${{ !cancelled() && needs.changes.outputs.build != 'false' }}
154 timeout-minutes: 5
155 run: |
156 until test -s "$RUNNER_TEMP/apt-status"; do sleep 1; done
157 cat "$RUNNER_TEMP/apt.log"
158 exit "$(cat "$RUNNER_TEMP/apt-status")"
159
160 - name: Build desktop pipeline
161 id: build
162 if: ${{ !cancelled() && steps.electron.outcome == 'success' && steps.apt.outcome == 'success' && needs.changes.outputs.build != 'false' }}
163 run: vp run build:desktop
164
165 - name: Verify preload bundle output
166 if: ${{ !cancelled() && steps.build.outcome == 'success' }}
167 run: node apps/desktop/scripts/verify-preload-bundle.mjs
168
169 - name: Typecheck
170 if: ${{ !cancelled() && steps.typecheck.outcome == 'success' }}
171 timeout-minutes: 5
172 run: |
173 until test -s "$RUNNER_TEMP/typecheck-status"; do sleep 1; done
174 cat "$RUNNER_TEMP/typecheck.log"
175 exit "$(cat "$RUNNER_TEMP/typecheck-status")"
176
177 # Everything except `t3` (apps/server) and the web app, which has its own job
178 # below. `--parallel` drops the package dependency ordering that `vp run`
179 # applies by default: these `test` tasks declare no `dependsOn` and resolve
180 # workspace deps from source, so ordering only bought us idle runners between
181 # dependency layers. The concurrency limit stays at the default 4 so peak load
182 # per runner is unchanged.
183 test:
184 name: Test
185 needs: changes
186 if: ${{ !cancelled() && needs.changes.outputs.test != 'false' }}
187 runs-on: blacksmith-8vcpu-ubuntu-2404
188 timeout-minutes: 10
189 steps:
190 - name: Checkout
191 uses: actions/checkout@v6
192 with:
193 sparse-checkout: |
194 /*
195 !/.repos/
196 !/apps/mobile/modules/t3-terminal/Vendor/**/*.a
197 sparse-checkout-cone-mode: false
198
199 # Blacksmith boots GitHub's Ubuntu runner image (gcc is usually present),
200 # but ACP process-tree live tests compile a small pthread fixture with `cc`
201 # and soft-skip when it is missing. Install build-essential so that path
202 # always runs in CI instead of silently no-oping.
203 - name: Install C toolchain for process-tree fixtures
204 run: |
205 sudo apt-get update
206 sudo apt-get install -y --no-install-recommends build-essential
207 command -v cc
208
209 - uses: ./.github/actions/setup-apt-mirrors
210
211 # The desktop tests compile the browser secret helper. The install runs in
212 # the background while Vite+ installs; the step before the tests waits for it.
213 - name: Start installing browser secret helper build libraries
214 run: |
215 sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
216 (
217 set +e
218 sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config
219 echo "$?" > "$RUNNER_TEMP/apt-status"
220 ) > "$RUNNER_TEMP/apt.log" 2>&1 < /dev/null &
221
222 - name: Setup Vite+
223 uses: ./.github/actions/setup-ci-deps
224
225 - name: Ensure Electron runtime is installed
226 run: vp run --filter @t3tools/desktop ensure:electron
227
228 - name: Test preview artifact validation
229 run: python3 -B .github/scripts/stage-preview-bundle.test.py
230
231 - name: Test release checks
232 run: node --test .github/scripts/check-nightly-release.test.cjs
233
234 - name: Finish installing browser secret helper build libraries
235 timeout-minutes: 5
236 run: |
237 until test -s "$RUNNER_TEMP/apt-status"; do sleep 1; done
238 cat "$RUNNER_TEMP/apt.log"
239 exit "$(cat "$RUNNER_TEMP/apt-status")"
240
241 # `changes` lists the affected packages, or nothing when all of them are.
242 - name: Test
243 env:
244 TEST_PACKAGES: ${{ needs.changes.outputs.test_packages }}
245 run: |
246 filters=(--filter '!t3' --filter '!@t3tools/monorepo' --filter '!@t3tools/web')
247 if [[ -n "$TEST_PACKAGES" ]]; then
248 filters=()
249 for package in $TEST_PACKAGES; do filters+=(--filter "$package"); done
250 fi
251 vp run --parallel --concurrency-limit 4 "${filters[@]}" test
252
253 # The web suite is the largest outside the server. In the shared Test job it
254 # started last and ran alone for about 40s after everything else finished.
255 test_web:
256 name: Test Web
257 needs: changes
258 if: ${{ !cancelled() && needs.changes.outputs.test_web != 'false' }}
259 runs-on: blacksmith-8vcpu-ubuntu-2404
260 timeout-minutes: 10
261 steps:
262 - name: Checkout
263 uses: actions/checkout@v6
264 with:
265 sparse-checkout: |
266 /*
267 !/.repos/
268 !/apps/mobile/modules/t3-terminal/Vendor/**/*.a
269 sparse-checkout-cone-mode: false
270
271 - name: Setup Vite+
272 uses: ./.github/actions/setup-ci-deps
273
274 # The browser project runs React tests in headless Chromium. Same cache key as
275 # test_server, so both jobs share one downloaded browser.
276 - name: Resolve Playwright version
277 id: playwright_version
278 run: echo "version=$(node -p "require('./apps/web/node_modules/playwright/package.json').version")" >> "$GITHUB_OUTPUT"
279
280 - name: Cache Chromium
281 id: chromium_cache
282 uses: actions/cache@v6
283 with:
284 path: ~/.cache/ms-playwright
285 key: playwright-chromium-shell-${{ runner.os }}-${{ runner.arch }}-${{ steps.playwright_version.outputs.version }}
286
287 - name: Install Chromium for web browser tests
288 if: steps.chromium_cache.outputs.cache-hit != 'true'
289 run: node apps/web/node_modules/playwright/cli.js install --only-shell chromium
290
291 - name: Install missing Chromium system dependencies
292 run: |
293 browser=$(find "$HOME/.cache/ms-playwright" -name chrome-headless-shell -type f -print -quit)
294 test -n "$browser"
295 if ldd "$browser" | grep '=> not found'; then
296 node apps/web/node_modules/playwright/cli.js install-deps chromium
297 fi
298
299 - name: Test
300 run: vp run --filter @t3tools/web test
301
302 # apps/server sets `fileParallelism: false`, so its test files run strictly
303 # one at a time. Sharding spreads them over separate runners instead of
304 # separate workers, so no two server test files ever share a machine and the
305 # isolation that flag buys is preserved exactly. One file at a time keeps
306 # about 1.5 cores busy, so 4 vCPU runners lose nothing against 8. The shards
307 # split files by recorded duration (apps/server/src/testUtils/weightedShardSequencer.ts).
308 # The shards are the longest jobs, so they gate themselves instead of waiting
309 # ~15s for `changes`: a shard the change cannot affect stops after checkout.
310 test_server:
311 name: Test Server ${{ matrix.shard }}
312 runs-on: blacksmith-4vcpu-ubuntu-2404
313 timeout-minutes: 10
314 strategy:
315 fail-fast: false
316 matrix:
317 shard: [1, 2, 3, 4, 5, 6, 7, 8]
318 steps:
319 # Depth 2 brings the base commit the change is diffed against.
320 - name: Checkout
321 uses: actions/checkout@v6
322 with:
323 fetch-depth: 2
324 sparse-checkout: |
325 /*
326 !/.repos/
327 !/apps/mobile/modules/t3-terminal/Vendor/**/*.a
328 sparse-checkout-cone-mode: false
329
330 - name: Detect affected jobs
331 id: changes
332 uses: ./.github/actions/ci-changes
333
334 - name: Setup Vite+
335 if: steps.changes.outputs.test_server != 'false'
336 uses: ./.github/actions/setup-ci-deps
337
338 # No Electron setup here: `t3` (apps/server) has no Electron dependency
339 # and none of its tests touch the runtime. Only the non-server `test`
340 # job, which covers @t3tools/desktop, needs the download.
341 # Cache the pinned browser and skip apt unless shared libraries are missing.
342 - name: Resolve Playwright version
343 id: playwright_version
344 if: steps.changes.outputs.test_server != 'false'
345 run: echo "version=$(node -p "require('./apps/server/node_modules/playwright-core/package.json').version")" >> "$GITHUB_OUTPUT"
346
347 - name: Cache Chromium
348 id: chromium_cache
349 if: steps.changes.outputs.test_server != 'false'
350 uses: actions/cache@v6
351 with:
352 path: ~/.cache/ms-playwright
353 key: playwright-chromium-shell-${{ runner.os }}-${{ runner.arch }}-${{ steps.playwright_version.outputs.version }}
354
355 - name: Install Chromium for server browser integration tests
356 if: steps.changes.outputs.test_server != 'false' && steps.chromium_cache.outputs.cache-hit != 'true'
357 run: node apps/server/node_modules/playwright-core/cli.js install --only-shell chromium
358
359 - name: Install missing Chromium system dependencies
360 if: steps.changes.outputs.test_server != 'false'
361 run: |
362 browser=$(find "$HOME/.cache/ms-playwright" -name chrome-headless-shell -type f -print -quit)
363 test -n "$browser"
364 if ldd "$browser" | grep '=> not found'; then
365 node apps/server/node_modules/playwright-core/cli.js install-deps chromium
366 fi
367
368 - name: Test
369 if: steps.changes.outputs.test_server != 'false'
370 env:
371 T3CODE_TRANSFER_BUDGET_REPORT_PATH: ${{ runner.temp }}/t3code-transfer-budget.md
372 T3CODE_TRANSFER_BUDGET_RESULT_PATH: ${{ runner.temp }}/thread-transfer-result.json
373 run: vp run --filter t3 test --shard ${{ matrix.shard }}/${{ strategy.job-total }}
374
375 # integration/transferBudgetV2.integration.test.ts writes the report; exactly one shard
376 # produces these files. Gating the upload on their presence keeps a
377 # single `thread-transfer-results` artifact per run, which is the name
378 # thread-transfer-report.yml resolves.
379 - name: Detect transfer budget report
380 id: transfer_budget
381 if: always()
382 run: |
383 if test -f "${{ runner.temp }}/thread-transfer-result.json"; then
384 echo "present=true" >> "$GITHUB_OUTPUT"
385 else
386 echo "present=false" >> "$GITHUB_OUTPUT"
387 fi
388
389 - name: Publish transfer budget report
390 if: always() && steps.transfer_budget.outputs.present == 'true'
391 run: |
392 if test -f "${{ runner.temp }}/t3code-transfer-budget.md"; then
393 tee -a "$GITHUB_STEP_SUMMARY" < "${{ runner.temp }}/t3code-transfer-budget.md"
394 else
395 echo "Transfer budget report was not produced." >> "$GITHUB_STEP_SUMMARY"
396 fi
397
398 - name: Upload thread transfer result
399 if: always() && steps.transfer_budget.outputs.present == 'true'
400 uses: actions/upload-artifact@v7
401 with:
402 name: thread-transfer-results
403 path: ${{ runner.temp }}/thread-transfer-result.json
404 if-no-files-found: ignore
405 retention-days: 30
406
407 # Split out of Check and Test: both paid ~7-9s to install a Rust toolchain
408 # for checks that take under 3s, on the critical path of every PR.
409 rust:
410 name: Rust
411 needs: changes
412 if: ${{ !cancelled() && needs.changes.outputs.rust != 'false' }}
413 runs-on: blacksmith-4vcpu-ubuntu-2404
414 timeout-minutes: 10
415 steps:
416 - name: Checkout
417 uses: actions/checkout@v6
418 with:
419 sparse-checkout: |
420 /*
421 !/.repos/
422 !/apps/mobile/modules/t3-terminal/Vendor/**/*.a
423 sparse-checkout-cone-mode: false
424
425 - name: Setup Rust
426 uses: dtolnay/rust-toolchain@stable
427 with:
428 components: rustfmt
429
430 - name: Check Rust formatting
431 run: |
432 for crate in resource-monitor kde-snap-shot hyprland-snap-shot; do
433 cargo fmt --manifest-path "native/$crate/Cargo.toml" -- --check
434 done
435
436 - name: Test Rust crates
437 run: |
438 for crate in resource-monitor kde-snap-shot hyprland-snap-shot; do
439 cargo test --locked --manifest-path "native/$crate/Cargo.toml"
440 done
441
442 mobile_native_static_analysis:
443 name: Mobile Native Static Analysis
444 needs: changes
445 if: ${{ !cancelled() && needs.changes.outputs.mobile_native != 'false' }}
446 runs-on: blacksmith-6vcpu-macos-26
447 timeout-minutes: 10
448 steps:
449 - name: Checkout
450 uses: actions/checkout@v6
451 with:
452 sparse-checkout: |
453 /*
454 !/.repos/
455 sparse-checkout-cone-mode: false
456
457 - name: Setup Vite+
458 uses: voidzero-dev/setup-vp@v1
459 with:
460 node-version-file: package.json
461 cache: true
462 run-install: |
463 args:
464 - --filter=@t3tools/scripts...
465
466 - name: Install mobile native static analysis tools
467 run: brew bundle install --file apps/mobile/Brewfile
468
469 - name: Lint mobile native sources
470 run: vp run lint:mobile
471
472 release_smoke:
473 name: Release Smoke
474 needs: changes
475 if: ${{ !cancelled() && needs.changes.outputs.release_smoke != 'false' }}
476 runs-on: blacksmith-8vcpu-ubuntu-2404
477 timeout-minutes: 10
478 steps:
479 - name: Checkout
480 uses: actions/checkout@v6
481 with:
482 sparse-checkout: |
483 /*
484 !/.repos/
485 !/apps/mobile/modules/t3-terminal/Vendor/**/*.a
486 sparse-checkout-cone-mode: false
487
488 - name: Setup Vite+
489 uses: ./.github/actions/setup-ci-deps
490
491 - name: Exercise release-only workflow steps
492 run: node scripts/release-smoke.ts
493
494 # Branch protection requires this job by its name, `Check`. It fails when any
495 # other job fails, is cancelled, or is skipped without a reason, so splitting
496 # or resharding jobs needs no ruleset change. Add every new job to `needs`.
497 # `always()` rather than `!cancelled()`: a skipped job reports success to
498 # branch protection, so a cancelled run must still produce a failing check.
499 check:
500 name: Check
501 if: ${{ always() }}
502 needs:
503 [
504 changes,
505 lint,
506 build,
507 test,
508 test_web,
509 test_server,
510 rust,
511 mobile_native_static_analysis,
512 release_smoke,
513 ]
514 runs-on: blacksmith-2vcpu-ubuntu-2404
515 timeout-minutes: 5
516 steps:
517 - name: Require every job to pass
518 env:
519 RESULTS: ${{ toJSON(needs) }}
520 run: |
521 echo "$RESULTS" | jq -r 'to_entries[] | "\(.key): \(.value.result)"'
522 # A job may skip only when `changes` said every gate it represents was
523 # not needed. Gates are keyed by job name, except merged Build and the
524 # macOS lint.
525 echo "$RESULTS" | jq -e '.changes.outputs as $gates
526 | {build: ["build", "typecheck"], mobile_native_static_analysis: ["mobile_native"]} as $renamed
527 | all(to_entries[];
528 .value.result == "success"
529 or (.value.result == "skipped"
530 and (($renamed[.key] // [.key]) | all(.[]; $gates[.] == "false"))))' > /dev/null
531
532 # thread-transfer-report.yml reads this artifact after CI, so a run whose
533 # server tests ran must have produced it.
534 - name: Require transfer measurements
535 if: needs.test_server.result == 'success' && needs.changes.outputs.test_server != 'false'
536 uses: actions/download-artifact@v8
537 with:
538 name: thread-transfer-results
539 path: ${{ runner.temp }}/thread-transfer