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

ci.yml

517 lines17.9 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 # Lint, typecheck, and the desktop build each get a runner so they run side by
18 # side instead of one after another. The `Check` job at the end of this file
19 # passes only when every other job does.
20 lint:
21 name: Lint
22 runs-on: blacksmith-8vcpu-ubuntu-2404
23 timeout-minutes: 10
24 steps:
25 - name: Checkout
26 uses: actions/checkout@v6
27 with:
28 sparse-checkout: |
29 /*
30 !/.repos/
31 sparse-checkout-cone-mode: false
32​
33 - name: Reject repository-owned PR assets
34 run: |
35 files="$(git ls-files .github/pr-assets)"
36 if test -n "$files"; then
37 printf 'PR evidence must be uploaded to GitHub, not committed:\n%s\n' "$files" >&2
38 exit 1
39 fi
40​
41 - name: Setup Vite+
42 uses: voidzero-dev/setup-vp@v1
43 with:
44 node-version-file: package.json
45 cache: true
46 run-install: true
47​
48 - name: Ensure Electron runtime is installed
49 run: vp run --filter @t3tools/desktop ensure:electron
50​
51 # Files/dependencies are repo-wide; export checks cover clean workspaces only.
52 - name: Check unused code
53 run: vp run knip:check
54​
55 - name: Check generated GitHub GraphQL operations
56 run: vp run --filter @t3tools/source-control-github generate --check
57​
58 - name: Check
59 run: vp check
60​
61 typecheck:
62 name: Typecheck
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 sparse-checkout-cone-mode: false
73​
74 - name: Setup Vite+
75 uses: voidzero-dev/setup-vp@v1
76 with:
77 node-version-file: package.json
78 cache: true
79 run-install: true
80​
81 - name: Ensure Electron runtime is installed
82 run: vp run --filter @t3tools/desktop ensure:electron
83​
84 - name: Typecheck
85 run: vpr typecheck
86​
87 build:
88 name: Build
89 runs-on: blacksmith-8vcpu-ubuntu-2404
90 timeout-minutes: 10
91 steps:
92 - name: Checkout
93 uses: actions/checkout@v6
94 with:
95 sparse-checkout: |
96 /*
97 !/.repos/
98 sparse-checkout-cone-mode: false
99​
100 - uses: ./.github/actions/setup-apt-mirrors
101​
102 # Runs in the background while Vite+ installs; the step before the build waits for it.
103 - name: Start installing browser secret helper build libraries
104 run: |
105 sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
106 (
107 set +e
108 sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config
109 echo "$?" > "$RUNNER_TEMP/apt-status"
110 ) > "$RUNNER_TEMP/apt.log" 2>&1 < /dev/null &
111​
112 - name: Setup Vite+
113 uses: voidzero-dev/setup-vp@v1
114 with:
115 node-version-file: package.json
116 cache: true
117 run-install: true
118​
119 - name: Ensure Electron runtime is installed
120 run: vp run --filter @t3tools/desktop ensure:electron
121​
122 - name: Finish installing browser secret helper build libraries
123 timeout-minutes: 5
124 run: |
125 until test -s "$RUNNER_TEMP/apt-status"; do sleep 1; done
126 cat "$RUNNER_TEMP/apt.log"
127 exit "$(cat "$RUNNER_TEMP/apt-status")"
128​
129 - name: Build desktop pipeline
130 run: vp run build:desktop
131​
132 - name: Verify preload bundle output
133 run: node apps/desktop/scripts/verify-preload-bundle.mjs
134​
135 # Everything except `t3` (apps/server) and the web app, which has its own job
136 # below. `--parallel` drops the package dependency ordering that `vp run`
137 # applies by default: these `test` tasks declare no `dependsOn` and resolve
138 # workspace deps from source, so ordering only bought us idle runners between
139 # dependency layers. The concurrency limit stays at the default 4 so peak load
140 # per runner is unchanged.
141 test:
142 name: Test
143 runs-on: blacksmith-8vcpu-ubuntu-2404
144 timeout-minutes: 10
145 steps:
146 - name: Checkout
147 uses: actions/checkout@v6
148 with:
149 sparse-checkout: |
150 /*
151 !/.repos/
152 sparse-checkout-cone-mode: false
153​
154 # Blacksmith boots GitHub's Ubuntu runner image (gcc is usually present),
155 # but ACP process-tree live tests compile a small pthread fixture with `cc`
156 # and soft-skip when it is missing. Install build-essential so that path
157 # always runs in CI instead of silently no-oping.
158 - name: Install C toolchain for process-tree fixtures
159 run: |
160 sudo apt-get update
161 sudo apt-get install -y --no-install-recommends build-essential
162 command -v cc
163​
164 - uses: ./.github/actions/setup-apt-mirrors
165​
166 # The desktop tests compile the browser secret helper. The install runs in
167 # the background while Vite+ installs; the step before the tests waits for it.
168 - name: Start installing browser secret helper build libraries
169 run: |
170 sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
171 (
172 set +e
173 sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config
174 echo "$?" > "$RUNNER_TEMP/apt-status"
175 ) > "$RUNNER_TEMP/apt.log" 2>&1 < /dev/null &
176​
177 - name: Setup Vite+
178 uses: voidzero-dev/setup-vp@v1
179 with:
180 node-version-file: package.json
181 cache: true
182 run-install: true
183​
184 - name: Ensure Electron runtime is installed
185 run: vp run --filter @t3tools/desktop ensure:electron
186​
187 - name: Test preview artifact validation
188 run: python3 -B .github/scripts/stage-preview-bundle.test.py
189​
190 - name: Test nightly release checks
191 run: node --test .github/scripts/check-nightly-release.test.cjs
192​
193 - name: Finish installing browser secret helper build libraries
194 timeout-minutes: 5
195 run: |
196 until test -s "$RUNNER_TEMP/apt-status"; do sleep 1; done
197 cat "$RUNNER_TEMP/apt.log"
198 exit "$(cat "$RUNNER_TEMP/apt-status")"
199​
200 - name: Test
201 run: vp run --parallel --concurrency-limit 4 --filter '!t3' --filter '!@t3tools/monorepo' --filter '!@t3tools/web' test
202​
203 # The web suite is the largest outside the server. In the shared Test job it
204 # started last and ran alone for about 40s after everything else finished.
205 test_web:
206 name: Test Web
207 runs-on: blacksmith-8vcpu-ubuntu-2404
208 timeout-minutes: 10
209 steps:
210 - name: Checkout
211 uses: actions/checkout@v6
212 with:
213 sparse-checkout: |
214 /*
215 !/.repos/
216 sparse-checkout-cone-mode: false
217​
218 - name: Setup Vite+
219 uses: voidzero-dev/setup-vp@v1
220 with:
221 node-version-file: package.json
222 cache: true
223 run-install: true
224​
225 - name: Test
226 run: vp run --filter @t3tools/web test
227​
228 # apps/server sets `fileParallelism: false`, so its test files run strictly
229 # one at a time. Sharding spreads them over separate runners instead of
230 # separate workers, so no two server test files ever share a machine and the
231 # isolation that flag buys is preserved exactly. One file at a time keeps
232 # about 1.5 cores busy, so 4 vCPU runners lose nothing against 8. The shards
233 # split files by recorded duration (apps/server/src/testUtils/weightedShardSequencer.ts).
234 test_server:
235 name: Test Server ${{ matrix.shard }}
236 runs-on: blacksmith-4vcpu-ubuntu-2404
237 timeout-minutes: 10
238 strategy:
239 fail-fast: false
240 matrix:
241 shard: [1, 2, 3, 4, 5, 6]
242 steps:
243 - name: Checkout
244 uses: actions/checkout@v6
245 with:
246 sparse-checkout: |
247 /*
248 !/.repos/
249 sparse-checkout-cone-mode: false
250​
251 - name: Setup Vite+
252 uses: voidzero-dev/setup-vp@v1
253 with:
254 node-version-file: package.json
255 cache: true
256 run-install: true
257​
258 # No Electron setup here: `t3` (apps/server) has no Electron dependency
259 # and none of its tests touch the runtime. Only the non-server `test`
260 # job, which covers @t3tools/desktop, needs the download.
261 - name: Install Chromium for server browser integration tests
262 run: node apps/server/node_modules/playwright-core/cli.js install --with-deps --only-shell chromium
263​
264 - name: Test
265 env:
266 T3CODE_TRANSFER_BUDGET_REPORT_PATH: ${{ runner.temp }}/t3code-transfer-budget.md
267 T3CODE_TRANSFER_BUDGET_RESULT_PATH: ${{ runner.temp }}/thread-transfer-result.json
268 run: vp run --filter t3 test --shard ${{ matrix.shard }}/${{ strategy.job-total }}
269​
270 # integration/transferBudgetV2.integration.test.ts writes the report; exactly one shard
271 # produces these files. Gating the upload on their presence keeps a
272 # single `thread-transfer-results` artifact per run, which is the name
273 # thread-transfer-report.yml resolves.
274 - name: Detect transfer budget report
275 id: transfer_budget
276 if: always()
277 run: |
278 if test -f "${{ runner.temp }}/thread-transfer-result.json"; then
279 echo "present=true" >> "$GITHUB_OUTPUT"
280 else
281 echo "present=false" >> "$GITHUB_OUTPUT"
282 fi
283​
284 - name: Publish transfer budget report
285 if: always() && steps.transfer_budget.outputs.present == 'true'
286 run: |
287 if test -f "${{ runner.temp }}/t3code-transfer-budget.md"; then
288 tee -a "$GITHUB_STEP_SUMMARY" < "${{ runner.temp }}/t3code-transfer-budget.md"
289 else
290 echo "Transfer budget report was not produced." >> "$GITHUB_STEP_SUMMARY"
291 fi
292​
293 - name: Upload thread transfer result
294 if: always() && steps.transfer_budget.outputs.present == 'true'
295 uses: actions/upload-artifact@v7
296 with:
297 name: thread-transfer-results
298 path: ${{ runner.temp }}/thread-transfer-result.json
299 if-no-files-found: ignore
300 retention-days: 30
301​
302 transfer-report:
303 name: Transfer report artifact
304 needs: test_server
305 # On Blacksmith like every other job here: the GitHub-hosted queue is shared
306 # with the PR bots and can leave this job waiting until it is abandoned,
307 # which fails `Check` on an otherwise green run.
308 runs-on: blacksmith-2vcpu-ubuntu-2404
309 timeout-minutes: 5
310 steps:
311 - name: Require transfer measurements
312 uses: actions/download-artifact@v8
313 with:
314 name: thread-transfer-results
315 path: ${{ runner.temp }}/thread-transfer
316​
317 # Split out of Check and Test: both paid ~7-9s to install a Rust toolchain
318 # for checks that take under 3s, on the critical path of every PR.
319 rust:
320 name: Rust
321 runs-on: blacksmith-4vcpu-ubuntu-2404
322 timeout-minutes: 10
323 steps:
324 - name: Checkout
325 uses: actions/checkout@v6
326 with:
327 sparse-checkout: |
328 /*
329 !/.repos/
330 sparse-checkout-cone-mode: false
331​
332 - name: Setup Rust
333 uses: dtolnay/rust-toolchain@stable
334 with:
335 components: rustfmt
336​
337 - name: Check Rust formatting
338 run: |
339 for crate in resource-monitor kde-snap-shot hyprland-snap-shot; do
340 cargo fmt --manifest-path "native/$crate/Cargo.toml" -- --check
341 done
342​
343 - name: Test Rust crates
344 run: |
345 for crate in resource-monitor kde-snap-shot hyprland-snap-shot; do
346 cargo test --locked --manifest-path "native/$crate/Cargo.toml"
347 done
348​
349 # The static analysis below needs a macOS runner, which bills ~6.7x a Linux
350 # minute, so gate it on the native sources it actually lints instead of paying
351 # for it on every push. Detection is API-only (no checkout) and fails open: if
352 # the diff cannot be resolved, the lint runs.
353 mobile_native_changes:
354 name: Mobile Native Changes
355 runs-on: blacksmith-2vcpu-ubuntu-2404
356 timeout-minutes: 5
357 permissions:
358 contents: read
359 pull-requests: read
360 outputs:
361 changed: ${{ steps.detect.outputs.changed }}
362 steps:
363 - name: Detect mobile native changes
364 id: detect
365 env:
366 GH_TOKEN: ${{ github.token }}
367 PR_NUMBER: ${{ github.event.pull_request.number }}
368 BEFORE_SHA: ${{ github.event.before }}
369 run: |
370 set -uo pipefail
371​
372 fail_open() {
373 echo "$* Running native static analysis."
374 echo "changed=true" >> "$GITHUB_OUTPUT"
375 exit 0
376 }
377​
378 count_rows() {
379 printf '%s\n' "$1" | grep -c . || true
380 }
381​
382 # One row per changed file, holding the new path and, for a rename,
383 # the path it replaced: renaming a matched file out of the matched
384 # paths removes a lint input just like editing it.
385 row='[.filename, (.previous_filename // empty)] | @tsv'
386​
387 if [[ -n "${PR_NUMBER}" ]]; then
388 # The PR files endpoint stops at 3000 files and pagination cannot
389 # extend it, so cross-check against the count the PR itself reports.
390 expected=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" --jq '.changed_files') \
391 || fail_open "Could not read the pull request."
392 rows=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/files" --paginate --jq ".[] | ${row}") \
393 || fail_open "Could not resolve changed files."
394​
395 listed=$(count_rows "$rows")
396 if [[ "$listed" -lt "$expected" ]]; then
397 fail_open "GitHub listed only ${listed} of ${expected} changed files."
398 fi
399 else
400 rows=$(gh api "repos/${GITHUB_REPOSITORY}/compare/${BEFORE_SHA}...${GITHUB_SHA}" --jq ".files[]? | ${row}") \
401 || fail_open "Could not resolve changed files."
402​
403 # The compare endpoint reports at most 300 files and pagination does
404 # not extend that list, so a full list may be hiding native changes.
405 listed=$(count_rows "$rows")
406 if [[ "$listed" -ge 300 ]]; then
407 fail_open "GitHub listed ${listed} changed files, the compare endpoint maximum."
408 fi
409 fi
410​
411 paths=$(tr '\t' '\n' <<< "$rows")
412​
413 # Sources scripts/mobile-native-static-check.ts lints, plus the tool
414 # and rule configuration that decides how it lints them, plus the
415 # root package.json that defines the lint:mobile command.
416 pattern='^apps/mobile/.*\.(swift|kt|kts)$|^apps/mobile/(\.swiftlint\.yml|detekt\.yml|\.editorconfig|Brewfile)$|^scripts/mobile-native-static-check\.ts$|^package\.json$|^\.github/workflows/ci\.yml$'
417​
418 if grep -qE "$pattern" <<< "$paths"; then
419 echo "Native sources or lint configuration changed:"
420 grep -E "$pattern" <<< "$paths"
421 echo "changed=true" >> "$GITHUB_OUTPUT"
422 else
423 echo "No mobile native sources or lint configuration changed."
424 echo "changed=false" >> "$GITHUB_OUTPUT"
425 fi
426​
427 mobile_native_static_analysis:
428 name: Mobile Native Static Analysis
429 needs: mobile_native_changes
430 # Skip only on an explicit "no": a gate job that failed or errored leaves the
431 # output empty, and that must run the lint rather than silently skip it.
432 if: ${{ !cancelled() && needs.mobile_native_changes.outputs.changed != 'false' }}
433 runs-on: blacksmith-6vcpu-macos-26
434 timeout-minutes: 10
435 steps:
436 - name: Checkout
437 uses: actions/checkout@v6
438 with:
439 sparse-checkout: |
440 /*
441 !/.repos/
442 sparse-checkout-cone-mode: false
443​
444 - name: Setup Vite+
445 uses: voidzero-dev/setup-vp@v1
446 with:
447 node-version-file: package.json
448 cache: true
449 run-install: |
450 args:
451 - --filter=@t3tools/scripts...
452​
453 - name: Install mobile native static analysis tools
454 run: brew bundle install --file apps/mobile/Brewfile
455​
456 - name: Lint mobile native sources
457 run: vp run lint:mobile
458​
459 release_smoke:
460 name: Release Smoke
461 runs-on: blacksmith-8vcpu-ubuntu-2404
462 timeout-minutes: 10
463 steps:
464 - name: Checkout
465 uses: actions/checkout@v6
466 with:
467 sparse-checkout: |
468 /*
469 !/.repos/
470 sparse-checkout-cone-mode: false
471​
472 - name: Setup Vite+
473 uses: voidzero-dev/setup-vp@v1
474 with:
475 node-version-file: package.json
476 cache: true
477 run-install: |
478 args:
479 - --filter=@t3tools/scripts...
480​
481 - name: Exercise release-only workflow steps
482 run: node scripts/release-smoke.ts
483​
484 # Branch protection requires this job by its name, `Check`. It fails when any
485 # other job fails, is cancelled, or is skipped without a reason, so splitting
486 # or resharding jobs needs no ruleset change. Add every new job to `needs`.
487 # `always()` rather than `!cancelled()`: a skipped job reports success to
488 # branch protection, so a cancelled run must still produce a failing check.
489 check:
490 name: Check
491 if: ${{ always() }}
492 needs:
493 [
494 lint,
495 typecheck,
496 build,
497 test,
498 test_web,
499 test_server,
500 transfer-report,
501 rust,
502 mobile_native_changes,
503 mobile_native_static_analysis,
504 release_smoke,
505 ]
506 runs-on: blacksmith-2vcpu-ubuntu-2404
507 timeout-minutes: 5
508 steps:
509 - name: Require every job to pass
510 env:
511 RESULTS: ${{ toJSON(needs) }}
512 run: |
513 echo "$RESULTS" | jq -r 'to_entries[] | "\(.key): \(.value.result)"'
514 # Only the macOS lint skips on purpose, when no native mobile code changed.
515 echo "$RESULTS" | jq -e 'all(to_entries[];
516 .value.result == "success"
517 or (.key == "mobile_native_static_analysis" and .value.result == "skipped"))' > /dev/null