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