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

ci.yml

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