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