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