Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ci.yml

538 lines20.3 KB

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