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 # Blacksmith boots GitHub's Ubuntu runner image (gcc is usually present),
229 # but ACP process-tree live tests compile a small pthread fixture with `cc`
230 # and soft-skip when it is missing. Install build-essential so that path
231 # always runs in CI instead of silently no-oping.
232 - name: Install C toolchain for process-tree fixtures
233 run: |
234 sudo apt-get update
235 sudo apt-get install -y --no-install-recommends build-essential
236 command -v cc
237
238 - uses: ./.github/actions/setup-apt-mirrors
239
240 # The desktop tests compile the browser secret helper. The install runs in
241 # the background while Vite+ installs; the step before the tests waits for it.
242 - name: Start installing browser secret helper build libraries
243 run: |
244 sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
245 (
246 set +e
247 sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config
248 echo "$?" > "$RUNNER_TEMP/apt-status"
249 ) > "$RUNNER_TEMP/apt.log" 2>&1 < /dev/null &
250
251 - name: Setup Vite+
252 uses: ./.github/actions/setup-ci-deps
253 with:
254 task-cache-read-token: ${{ secrets.T3_TASK_CACHE_READ_TOKEN }}
255
256 # electron's install.js (run by ensure:electron) reads this cache before it
257 # downloads from GitHub. The key changes only with the Electron version.
258 - name: Cache Electron download
259 uses: actions/cache@v6
260 with:
261 path: ~/.cache/electron
262 key: electron-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('node_modules/.pnpm/electron@*/node_modules/electron/package.json') }}
263
264 - name: Ensure Electron runtime is installed
265 run: vp run --filter @t3tools/desktop ensure:electron
266
267 - name: Test preview artifact validation
268 run: python3 -B .github/scripts/stage-preview-bundle.test.py
269
270 - name: Test release checks
271 run: node --test .github/scripts/check-nightly-release.test.cjs .github/scripts/vercel-deployment-output.test.cjs
272
273 - name: Finish installing browser secret helper build libraries
274 timeout-minutes: 5
275 run: |
276 until test -s "$RUNNER_TEMP/apt-status"; do sleep 1; done
277 cat "$RUNNER_TEMP/apt.log"
278 exit "$(cat "$RUNNER_TEMP/apt-status")"
279
280 # `changes` lists the affected packages, or nothing when all of them are.
281 - name: Test
282 env:
283 TEST_PACKAGES: ${{ needs.changes.outputs.test_packages }}
284 run: |
285 filters=(--filter '!t3' --filter '!@t3tools/monorepo' --filter '!@t3tools/web')
286 if [[ -n "$TEST_PACKAGES" ]]; then
287 filters=()
288 for package in $TEST_PACKAGES; do filters+=(--filter "$package"); done
289 fi
290 vp run --parallel --concurrency-limit 4 "${filters[@]}" test
291
292 # The web suite is the largest outside the server. In the shared Test job it
293 # started last and ran alone for about 40s after everything else finished.
294 # release.yml mirrors this test, test_web, and test_server split.
295 test_web:
296 permissions:
297 contents: read
298 id-token: write
299 name: Test Web
300 needs: changes
301 if: ${{ !cancelled() && needs.changes.outputs.test_web != 'false' }}
302 runs-on: blacksmith-8vcpu-ubuntu-2404
303 timeout-minutes: 10
304 steps:
305 - name: Checkout
306 uses: actions/checkout@v6
307 with:
308 sparse-checkout: |
309 /*
310 !/.repos/
311 !/apps/mobile/modules/t3-terminal/Vendor/**/*.a
312 sparse-checkout-cone-mode: false
313
314 - name: Setup Vite+
315 uses: ./.github/actions/setup-ci-deps
316 with:
317 task-cache-read-token: ${{ secrets.T3_TASK_CACHE_READ_TOKEN }}
318
319 # The browser project runs React tests in headless Chromium. Same cache key as
320 # test_server, so both jobs share one downloaded browser.
321 - name: Resolve Playwright version
322 id: playwright_version
323 run: echo "version=$(node -p "require('./apps/web/node_modules/playwright/package.json').version")" >> "$GITHUB_OUTPUT"
324
325 - name: Cache Chromium
326 id: chromium_cache
327 uses: actions/cache@v6
328 with:
329 path: ~/.cache/ms-playwright
330 key: playwright-chromium-shell-${{ runner.os }}-${{ runner.arch }}-${{ steps.playwright_version.outputs.version }}
331
332 - name: Install Chromium for web browser tests
333 if: steps.chromium_cache.outputs.cache-hit != 'true'
334 run: node apps/web/node_modules/playwright/cli.js install --only-shell chromium
335
336 - name: Install missing Chromium system dependencies
337 run: |
338 browser=$(find "$HOME/.cache/ms-playwright" -name chrome-headless-shell -type f -print -quit)
339 test -n "$browser"
340 if ldd "$browser" | grep '=> not found'; then
341 node apps/web/node_modules/playwright/cli.js install-deps chromium
342 fi
343
344 - name: Test
345 run: vp run --filter @t3tools/web test
346
347 # Browser tests run source modules; this boots the production chunk graph.
348 - name: Boot the built web client
349 run: |
350 vp run --filter @t3tools/web build
351 node apps/web/scripts/verify-built-boot.ts
352
353 # apps/server sets `fileParallelism: false`, so its test files run strictly
354 # one at a time. Sharding spreads them over separate runners instead of
355 # separate workers, so no two server test files ever share a machine and the
356 # isolation that flag buys is preserved exactly. One file at a time keeps
357 # about 1.5 cores busy, so 4 vCPU runners lose nothing against 8. The shards
358 # split files by recorded duration (apps/server/src/testUtils/weightedShardSequencer.ts).
359 # The shards are the longest jobs, so they gate themselves instead of waiting
360 # ~15s for `changes`: a shard the change cannot affect stops after checkout.
361 test_server:
362 permissions:
363 contents: read
364 id-token: write
365 name: Test Server ${{ matrix.shard }}
366 runs-on: blacksmith-4vcpu-ubuntu-2404
367 timeout-minutes: 10
368 strategy:
369 fail-fast: false
370 matrix:
371 shard: [1, 2, 3, 4, 5, 6, 7, 8]
372 steps:
373 # Depth 2 brings the base commit the change is diffed against.
374 - name: Checkout
375 uses: actions/checkout@v6
376 with:
377 fetch-depth: 2
378 sparse-checkout: |
379 /*
380 !/.repos/
381 !/apps/mobile/modules/t3-terminal/Vendor/**/*.a
382 sparse-checkout-cone-mode: false
383
384 - name: Detect affected jobs
385 id: changes
386 uses: ./.github/actions/ci-changes
387
388 - name: Setup Vite+
389 if: steps.changes.outputs.test_server != 'false'
390 uses: ./.github/actions/setup-ci-deps
391 with:
392 task-cache-read-token: ${{ secrets.T3_TASK_CACHE_READ_TOKEN }}
393
394 # No Electron setup here: `t3` (apps/server) has no Electron dependency
395 # and none of its tests touch the runtime. Only the non-server `test`
396 # job, which covers @t3tools/desktop, needs the download.
397 # Cache the pinned browser and skip apt unless shared libraries are missing.
398 - name: Resolve Playwright version
399 id: playwright_version
400 if: steps.changes.outputs.test_server != 'false'
401 run: echo "version=$(node -p "require('./apps/server/node_modules/playwright-core/package.json').version")" >> "$GITHUB_OUTPUT"
402
403 - name: Cache Chromium
404 id: chromium_cache
405 if: steps.changes.outputs.test_server != 'false'
406 uses: actions/cache@v6
407 with:
408 path: ~/.cache/ms-playwright
409 key: playwright-chromium-shell-${{ runner.os }}-${{ runner.arch }}-${{ steps.playwright_version.outputs.version }}
410
411 - name: Install Chromium for server browser integration tests
412 if: steps.changes.outputs.test_server != 'false' && steps.chromium_cache.outputs.cache-hit != 'true'
413 run: node apps/server/node_modules/playwright-core/cli.js install --only-shell chromium
414
415 - name: Install missing Chromium system dependencies
416 if: steps.changes.outputs.test_server != 'false'
417 run: |
418 browser=$(find "$HOME/.cache/ms-playwright" -name chrome-headless-shell -type f -print -quit)
419 test -n "$browser"
420 if ldd "$browser" | grep '=> not found'; then
421 node apps/server/node_modules/playwright-core/cli.js install-deps chromium
422 fi
423
424 - name: Test
425 if: steps.changes.outputs.test_server != 'false'
426 env:
427 T3CODE_TRANSFER_BUDGET_REPORT_PATH: ${{ runner.temp }}/t3code-transfer-budget.md
428 T3CODE_TRANSFER_BUDGET_RESULT_PATH: ${{ runner.temp }}/thread-transfer-result.json
429 run: >-
430 vp run test:cached -- --shard ${{ matrix.shard }}/${{ strategy.job-total }}
431 --uncached apps/server/integration/transferBudgetV2.integration.test.ts
432 --verify-hits 1 --report "${{ runner.temp }}/test-cache-${{ matrix.shard }}.json" apps/server
433
434 - name: Upload test cache measurements
435 if: always() && steps.changes.outputs.test_server != 'false'
436 uses: actions/upload-artifact@v7
437 with:
438 name: test-cache-${{ matrix.shard }}
439 path: ${{ runner.temp }}/test-cache-${{ matrix.shard }}.json
440 if-no-files-found: error
441
442 # integration/transferBudgetV2.integration.test.ts writes the report; exactly one shard
443 # produces these files. Gating the upload on their presence keeps a
444 # single `thread-transfer-results` artifact per run, which is the name
445 # thread-transfer-report.yml resolves.
446 - name: Detect transfer budget report
447 id: transfer_budget
448 if: always()
449 run: |
450 if test -f "${{ runner.temp }}/thread-transfer-result.json"; then
451 echo "present=true" >> "$GITHUB_OUTPUT"
452 else
453 echo "present=false" >> "$GITHUB_OUTPUT"
454 fi
455
456 - name: Publish transfer budget report
457 if: always() && steps.transfer_budget.outputs.present == 'true'
458 run: |
459 if test -f "${{ runner.temp }}/t3code-transfer-budget.md"; then
460 tee -a "$GITHUB_STEP_SUMMARY" < "${{ runner.temp }}/t3code-transfer-budget.md"
461 else
462 echo "Transfer budget report was not produced." >> "$GITHUB_STEP_SUMMARY"
463 fi
464
465 - name: Upload thread transfer result
466 if: always() && steps.transfer_budget.outputs.present == 'true'
467 uses: actions/upload-artifact@v7
468 with:
469 name: thread-transfer-results
470 path: ${{ runner.temp }}/thread-transfer-result.json
471 if-no-files-found: ignore
472 retention-days: 30
473
474 # Split out of Check and Test: both paid ~7-9s to install a Rust toolchain
475 # for checks that take under 3s, on the critical path of every PR.
476 rust:
477 name: Rust
478 needs: changes
479 if: ${{ !cancelled() && needs.changes.outputs.rust != 'false' }}
480 runs-on: blacksmith-4vcpu-ubuntu-2404
481 timeout-minutes: 10
482 steps:
483 - name: Checkout
484 uses: actions/checkout@v6
485 with:
486 sparse-checkout: |
487 /*
488 !/.repos/
489 !/apps/mobile/modules/t3-terminal/Vendor/**/*.a
490 sparse-checkout-cone-mode: false
491
492 - name: Setup Rust
493 uses: dtolnay/rust-toolchain@stable
494 with:
495 components: rustfmt
496
497 - name: Check Rust formatting
498 run: |
499 for crate in resource-monitor kde-snap-shot hyprland-snap-shot; do
500 cargo fmt --manifest-path "native/$crate/Cargo.toml" -- --check
501 done
502
503 - name: Test Rust crates
504 run: |
505 for crate in resource-monitor kde-snap-shot hyprland-snap-shot; do
506 cargo test --locked --manifest-path "native/$crate/Cargo.toml"
507 done
508
509 mobile_native_static_analysis:
510 name: Mobile Native Static Analysis
511 needs: changes
512 if: ${{ !cancelled() && needs.changes.outputs.mobile_native != 'false' }}
513 runs-on: blacksmith-6vcpu-macos-26
514 timeout-minutes: 10
515 steps:
516 - name: Checkout
517 uses: actions/checkout@v6
518 with:
519 sparse-checkout: |
520 /*
521 !/.repos/
522 sparse-checkout-cone-mode: false
523
524 - name: Setup Vite+
525 uses: voidzero-dev/setup-vp@v1
526 with:
527 node-version-file: package.json
528 cache: true
529 run-install: |
530 args:
531 - --filter=@t3tools/scripts...
532
533 - name: Install mobile native static analysis tools
534 run: brew bundle install --file apps/mobile/Brewfile
535
536 - name: Lint mobile native sources
537 run: vp run lint:mobile
538
539 release_smoke:
540 permissions:
541 contents: read
542 id-token: write
543 name: Release Smoke
544 needs: changes
545 if: ${{ !cancelled() && needs.changes.outputs.release_smoke != 'false' }}
546 runs-on: blacksmith-8vcpu-ubuntu-2404
547 timeout-minutes: 10
548 steps:
549 - name: Checkout
550 uses: actions/checkout@v6
551 with:
552 sparse-checkout: |
553 /*
554 !/.repos/
555 !/apps/mobile/modules/t3-terminal/Vendor/**/*.a
556 sparse-checkout-cone-mode: false
557
558 - name: Setup Vite+
559 uses: ./.github/actions/setup-ci-deps
560 with:
561 task-cache-read-token: ${{ secrets.T3_TASK_CACHE_READ_TOKEN }}
562
563 - name: Exercise release-only workflow steps
564 run: node scripts/release-smoke.ts
565
566 # Branch protection requires this job by its name, `Check`. It fails when any
567 # other job fails, is cancelled, or is skipped without a reason, so splitting
568 # or resharding jobs needs no ruleset change. Add every new job to `needs`.
569 # `always()` rather than `!cancelled()`: a skipped job reports success to
570 # branch protection, so a cancelled run must still produce a failing check.
571 check:
572 name: Check
573 if: ${{ always() }}
574 needs:
575 [
576 changes,
577 lint,
578 build,
579 test,
580 test_web,
581 test_server,
582 rust,
583 mobile_native_static_analysis,
584 release_smoke,
585 ]
586 runs-on: blacksmith-2vcpu-ubuntu-2404
587 timeout-minutes: 5
588 steps:
589 - name: Require every job to pass
590 env:
591 RESULTS: ${{ toJSON(needs) }}
592 run: |
593 echo "$RESULTS" | jq -r 'to_entries[] | "\(.key): \(.value.result)"'
594 # A job may skip only when `changes` said every gate it represents was
595 # not needed. Gates are keyed by job name, except merged Build and the
596 # macOS lint.
597 echo "$RESULTS" | jq -e '.changes.outputs as $gates
598 | {build: ["build", "typecheck"], mobile_native_static_analysis: ["mobile_native"]} as $renamed
599 | all(to_entries[];
600 .value.result == "success"
601 or (.value.result == "skipped"
602 and (($renamed[.key] // [.key]) | all(.[]; $gates[.] == "false"))))' > /dev/null
603
604 # thread-transfer-report.yml reads this artifact after CI, so a run whose
605 # server tests ran must have produced it.
606 - name: Require transfer measurements
607 if: needs.test_server.result == 'success' && needs.changes.outputs.test_server != 'false'
608 uses: actions/download-artifact@v8
609 with:
610 name: thread-transfer-results
611 path: ${{ runner.temp }}/thread-transfer