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