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