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