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 # 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 # On Blacksmith like every other job here: the GitHub-hosted queue is shared
300 # with the PR bots and can leave this job waiting until it is abandoned,
301 # which fails `Check` on an otherwise green run.
302 runs-on: blacksmith-2vcpu-ubuntu-2404
303 timeout-minutes: 5
304 steps:
305 - name: Require transfer measurements
306 uses: actions/download-artifact@v8
307 with:
308 name: thread-transfer-results
309 path: ${{ runner.temp }}/thread-transfer
310
311 # Split out of Check and Test: both paid ~7-9s to install a Rust toolchain
312 # for checks that take under 3s, on the critical path of every PR.
313 rust:
314 name: Rust
315 runs-on: blacksmith-4vcpu-ubuntu-2404
316 timeout-minutes: 10
317 steps:
318 - name: Checkout
319 uses: actions/checkout@v6
320 with:
321 sparse-checkout: |
322 /*
323 !/.repos/
324 sparse-checkout-cone-mode: false
325
326 - name: Setup Rust
327 uses: dtolnay/rust-toolchain@stable
328 with:
329 components: rustfmt
330
331 - name: Check Rust formatting
332 run: |
333 for crate in resource-monitor kde-snap-shot hyprland-snap-shot; do
334 cargo fmt --manifest-path "native/$crate/Cargo.toml" -- --check
335 done
336
337 - name: Test Rust crates
338 run: |
339 for crate in resource-monitor kde-snap-shot hyprland-snap-shot; do
340 cargo test --locked --manifest-path "native/$crate/Cargo.toml"
341 done
342
343 # The static analysis below needs a macOS runner, which bills ~6.7x a Linux
344 # minute, so gate it on the native sources it actually lints instead of paying
345 # for it on every push. Detection is API-only (no checkout) and fails open: if
346 # the diff cannot be resolved, the lint runs.
347 mobile_native_changes:
348 name: Mobile Native Changes
349 runs-on: blacksmith-2vcpu-ubuntu-2404
350 timeout-minutes: 5
351 permissions:
352 contents: read
353 pull-requests: read
354 outputs:
355 changed: ${{ steps.detect.outputs.changed }}
356 steps:
357 - name: Detect mobile native changes
358 id: detect
359 env:
360 GH_TOKEN: ${{ github.token }}
361 PR_NUMBER: ${{ github.event.pull_request.number }}
362 BEFORE_SHA: ${{ github.event.before }}
363 run: |
364 set -uo pipefail
365
366 fail_open() {
367 echo "$* Running native static analysis."
368 echo "changed=true" >> "$GITHUB_OUTPUT"
369 exit 0
370 }
371
372 count_rows() {
373 printf '%s\n' "$1" | grep -c . || true
374 }
375
376 # One row per changed file, holding the new path and, for a rename,
377 # the path it replaced: renaming a matched file out of the matched
378 # paths removes a lint input just like editing it.
379 row='[.filename, (.previous_filename // empty)] | @tsv'
380
381 if [[ -n "${PR_NUMBER}" ]]; then
382 # The PR files endpoint stops at 3000 files and pagination cannot
383 # extend it, so cross-check against the count the PR itself reports.
384 expected=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" --jq '.changed_files') \
385 || fail_open "Could not read the pull request."
386 rows=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/files" --paginate --jq ".[] | ${row}") \
387 || fail_open "Could not resolve changed files."
388
389 listed=$(count_rows "$rows")
390 if [[ "$listed" -lt "$expected" ]]; then
391 fail_open "GitHub listed only ${listed} of ${expected} changed files."
392 fi
393 else
394 rows=$(gh api "repos/${GITHUB_REPOSITORY}/compare/${BEFORE_SHA}...${GITHUB_SHA}" --jq ".files[]? | ${row}") \
395 || fail_open "Could not resolve changed files."
396
397 # The compare endpoint reports at most 300 files and pagination does
398 # not extend that list, so a full list may be hiding native changes.
399 listed=$(count_rows "$rows")
400 if [[ "$listed" -ge 300 ]]; then
401 fail_open "GitHub listed ${listed} changed files, the compare endpoint maximum."
402 fi
403 fi
404
405 paths=$(tr '\t' '\n' <<< "$rows")
406
407 # Sources scripts/mobile-native-static-check.ts lints, plus the tool
408 # and rule configuration that decides how it lints them, plus the
409 # root package.json that defines the lint:mobile command.
410 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$'
411
412 if grep -qE "$pattern" <<< "$paths"; then
413 echo "Native sources or lint configuration changed:"
414 grep -E "$pattern" <<< "$paths"
415 echo "changed=true" >> "$GITHUB_OUTPUT"
416 else
417 echo "No mobile native sources or lint configuration changed."
418 echo "changed=false" >> "$GITHUB_OUTPUT"
419 fi
420
421 mobile_native_static_analysis:
422 name: Mobile Native Static Analysis
423 needs: mobile_native_changes
424 # Skip only on an explicit "no": a gate job that failed or errored leaves the
425 # output empty, and that must run the lint rather than silently skip it.
426 if: ${{ !cancelled() && needs.mobile_native_changes.outputs.changed != 'false' }}
427 runs-on: blacksmith-6vcpu-macos-26
428 timeout-minutes: 10
429 steps:
430 - name: Checkout
431 uses: actions/checkout@v6
432 with:
433 sparse-checkout: |
434 /*
435 !/.repos/
436 sparse-checkout-cone-mode: false
437
438 - name: Setup Vite+
439 uses: voidzero-dev/setup-vp@v1
440 with:
441 node-version-file: package.json
442 cache: true
443 run-install: |
444 args:
445 - --filter=@t3tools/scripts...
446
447 - name: Install mobile native static analysis tools
448 run: brew bundle install --file apps/mobile/Brewfile
449
450 - name: Lint mobile native sources
451 run: vp run lint:mobile
452
453 release_smoke:
454 name: Release Smoke
455 runs-on: blacksmith-8vcpu-ubuntu-2404
456 timeout-minutes: 10
457 steps:
458 - name: Checkout
459 uses: actions/checkout@v6
460 with:
461 sparse-checkout: |
462 /*
463 !/.repos/
464 sparse-checkout-cone-mode: false
465
466 - name: Setup Vite+
467 uses: voidzero-dev/setup-vp@v1
468 with:
469 node-version-file: package.json
470 cache: true
471 run-install: |
472 args:
473 - --filter=@t3tools/scripts...
474
475 - name: Exercise release-only workflow steps
476 run: node scripts/release-smoke.ts
477
478 # Branch protection requires this job by its name, `Check`. It fails when any
479 # other job fails, is cancelled, or is skipped without a reason, so splitting
480 # or resharding jobs needs no ruleset change. Add every new job to `needs`.
481 # `always()` rather than `!cancelled()`: a skipped job reports success to
482 # branch protection, so a cancelled run must still produce a failing check.
483 check:
484 name: Check
485 if: ${{ always() }}
486 needs:
487 [
488 lint,
489 typecheck,
490 build,
491 test,
492 test_web,
493 test_server,
494 transfer-report,
495 rust,
496 mobile_native_changes,
497 mobile_native_static_analysis,
498 release_smoke,
499 ]
500 runs-on: blacksmith-2vcpu-ubuntu-2404
501 timeout-minutes: 5
502 steps:
503 - name: Require every job to pass
504 env:
505 RESULTS: ${{ toJSON(needs) }}
506 run: |
507 echo "$RESULTS" | jq -r 'to_entries[] | "\(.key): \(.value.result)"'
508 # Only the macOS lint skips on purpose, when no native mobile code changed.
509 echo "$RESULTS" | jq -e 'all(to_entries[];
510 .value.result == "success"
511 or (.key == "mobile_native_static_analysis" and .value.result == "skipped"))' > /dev/null