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 check:
18 name: Check
19 runs-on: blacksmith-8vcpu-ubuntu-2404
20 timeout-minutes: 10
21 steps:
22 - name: Checkout
23 uses: actions/checkout@v6
24 with:
25 sparse-checkout: |
26 /*
27 !/.repos/
28 sparse-checkout-cone-mode: false
29
30 - name: Reject repository-owned PR assets
31 run: |
32 files="$(git ls-files .github/pr-assets)"
33 if test -n "$files"; then
34 printf 'PR evidence must be uploaded to GitHub, not committed:\n%s\n' "$files" >&2
35 exit 1
36 fi
37
38 - name: Setup Vite+
39 uses: voidzero-dev/setup-vp@v1
40 with:
41 node-version-file: package.json
42 cache: true
43 run-install: true
44
45 - name: Ensure Electron runtime is installed
46 run: vp run --filter @t3tools/desktop ensure:electron
47
48 # Files/dependencies are repo-wide; export checks cover clean workspaces only.
49 - name: Check unused code
50 run: vp run knip:check
51
52 - name: Check
53 run: vp check
54
55 - name: Typecheck
56 run: vpr typecheck
57
58 - uses: ./.github/actions/setup-apt-mirrors
59
60 - name: Install browser secret helper build libraries
61 run: |
62 sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
63 sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config
64
65 - name: Build desktop pipeline
66 run: vp run build:desktop
67
68 - name: Verify preload bundle output
69 run: node apps/desktop/scripts/verify-preload-bundle.mjs
70
71 - name: Setup Bun
72 uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
73 with:
74 bun-version: "1.4.0"
75
76 - name: Smoke the built server under Bun
77 timeout-minutes: 2
78 env:
79 # The standalone child must discard inherited launcher state.
80 T3_SERVICE_LAUNCHER_CONTEXT: '{"protocol":2,"childVersion":"0.0.0"}'
81 run: node scripts/server-runtime-smoke.ts
82
83 # Everything except `t3` (apps/server). `--parallel` drops the package
84 # dependency ordering that `vp run` applies by default: these `test` tasks
85 # declare no `dependsOn` and resolve workspace deps from source, so ordering
86 # only bought us idle runners between dependency layers. The concurrency
87 # limit stays at the default 4 so peak load per runner is unchanged.
88 test:
89 name: Test
90 runs-on: blacksmith-8vcpu-ubuntu-2404
91 timeout-minutes: 10
92 steps:
93 - name: Checkout
94 uses: actions/checkout@v6
95 with:
96 sparse-checkout: |
97 /*
98 !/.repos/
99 sparse-checkout-cone-mode: false
100
101 - name: Setup Vite+
102 uses: voidzero-dev/setup-vp@v1
103 with:
104 node-version-file: package.json
105 cache: true
106 run-install: true
107
108 - name: Ensure Electron runtime is installed
109 run: vp run --filter @t3tools/desktop ensure:electron
110
111 - uses: ./.github/actions/setup-apt-mirrors
112
113 - name: Install browser secret helper build libraries
114 run: |
115 sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
116 sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config
117
118 - name: Test nightly release checks
119 run: node --test .github/scripts/check-nightly-release.test.cjs
120
121 - name: Test
122 run: vp run --parallel --concurrency-limit 4 --filter '!t3' --filter '!@t3tools/monorepo' test
123
124 # apps/server sets `fileParallelism: false`, so its 239 files run strictly
125 # one at a time. Sharding spreads them over separate runners instead of
126 # separate workers, so no two server test files ever share a machine and the
127 # isolation that flag buys is preserved exactly.
128 test_server:
129 name: Test Server ${{ matrix.shard }}
130 runs-on: blacksmith-8vcpu-ubuntu-2404
131 timeout-minutes: 10
132 strategy:
133 fail-fast: false
134 matrix:
135 shard: [1, 2, 3]
136 steps:
137 - name: Checkout
138 uses: actions/checkout@v6
139 with:
140 sparse-checkout: |
141 /*
142 !/.repos/
143 sparse-checkout-cone-mode: false
144
145 - name: Setup Vite+
146 uses: voidzero-dev/setup-vp@v1
147 with:
148 node-version-file: package.json
149 cache: true
150 run-install: true
151
152 # No Electron setup here: `t3` (apps/server) has no Electron dependency
153 # and none of its tests touch the runtime. Only the non-server `test`
154 # job, which covers @t3tools/desktop, needs the download.
155 - name: Test
156 env:
157 T3CODE_TRANSFER_BUDGET_REPORT_PATH: ${{ runner.temp }}/t3code-transfer-budget.md
158 T3CODE_TRANSFER_BUDGET_RESULT_PATH: ${{ runner.temp }}/thread-transfer-result.json
159 run: vp run --filter t3 test --shard ${{ matrix.shard }}/${{ strategy.job-total }}
160
161 # src/server.test.ts writes the budget report, so exactly one shard
162 # produces these files. Gating the upload on their presence keeps a
163 # single `thread-transfer-results` artifact per run, which is the name
164 # thread-transfer-report.yml resolves.
165 - name: Detect transfer budget report
166 id: transfer_budget
167 if: always()
168 run: |
169 if test -f "${{ runner.temp }}/thread-transfer-result.json"; then
170 echo "present=true" >> "$GITHUB_OUTPUT"
171 else
172 echo "present=false" >> "$GITHUB_OUTPUT"
173 fi
174
175 - name: Publish transfer budget report
176 if: always() && steps.transfer_budget.outputs.present == 'true'
177 run: |
178 if test -f "${{ runner.temp }}/t3code-transfer-budget.md"; then
179 tee -a "$GITHUB_STEP_SUMMARY" < "${{ runner.temp }}/t3code-transfer-budget.md"
180 else
181 echo "Transfer budget report was not produced." >> "$GITHUB_STEP_SUMMARY"
182 fi
183
184 - name: Upload thread transfer result
185 if: always() && steps.transfer_budget.outputs.present == 'true'
186 uses: actions/upload-artifact@v7
187 with:
188 name: thread-transfer-results
189 path: ${{ runner.temp }}/thread-transfer-result.json
190 if-no-files-found: ignore
191 retention-days: 30
192
193 # Split out of Check and Test: both paid ~7-9s to install a Rust toolchain
194 # for checks that take under 3s, on the critical path of every PR.
195 rust:
196 name: Rust
197 runs-on: blacksmith-4vcpu-ubuntu-2404
198 timeout-minutes: 10
199 steps:
200 - name: Checkout
201 uses: actions/checkout@v6
202 with:
203 sparse-checkout: |
204 /*
205 !/.repos/
206 sparse-checkout-cone-mode: false
207
208 - name: Setup Rust
209 uses: dtolnay/rust-toolchain@stable
210 with:
211 components: rustfmt
212
213 - name: Check Rust formatting
214 run: |
215 for crate in resource-monitor kde-snap-shot hyprland-snap-shot; do
216 cargo fmt --manifest-path "native/$crate/Cargo.toml" -- --check
217 done
218
219 - name: Test Rust crates
220 run: |
221 for crate in resource-monitor kde-snap-shot hyprland-snap-shot; do
222 cargo test --locked --manifest-path "native/$crate/Cargo.toml"
223 done
224
225 # The static analysis below needs a macOS runner, which bills ~6.7x a Linux
226 # minute, so gate it on the native sources it actually lints instead of paying
227 # for it on every push. Detection is API-only (no checkout) and fails open: if
228 # the diff cannot be resolved, the lint runs.
229 mobile_native_changes:
230 name: Mobile Native Changes
231 runs-on: blacksmith-2vcpu-ubuntu-2404
232 timeout-minutes: 5
233 permissions:
234 contents: read
235 pull-requests: read
236 outputs:
237 changed: ${{ steps.detect.outputs.changed }}
238 steps:
239 - name: Detect mobile native changes
240 id: detect
241 env:
242 GH_TOKEN: ${{ github.token }}
243 PR_NUMBER: ${{ github.event.pull_request.number }}
244 BEFORE_SHA: ${{ github.event.before }}
245 run: |
246 set -uo pipefail
247
248 fail_open() {
249 echo "$* Running native static analysis."
250 echo "changed=true" >> "$GITHUB_OUTPUT"
251 exit 0
252 }
253
254 count_rows() {
255 printf '%s\n' "$1" | grep -c . || true
256 }
257
258 # One row per changed file, holding the new path and, for a rename,
259 # the path it replaced: renaming a matched file out of the matched
260 # paths removes a lint input just like editing it.
261 row='[.filename, (.previous_filename // empty)] | @tsv'
262
263 if [[ -n "${PR_NUMBER}" ]]; then
264 # The PR files endpoint stops at 3000 files and pagination cannot
265 # extend it, so cross-check against the count the PR itself reports.
266 expected=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" --jq '.changed_files') \
267 || fail_open "Could not read the pull request."
268 rows=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/files" --paginate --jq ".[] | ${row}") \
269 || fail_open "Could not resolve changed files."
270
271 listed=$(count_rows "$rows")
272 if [[ "$listed" -lt "$expected" ]]; then
273 fail_open "GitHub listed only ${listed} of ${expected} changed files."
274 fi
275 else
276 rows=$(gh api "repos/${GITHUB_REPOSITORY}/compare/${BEFORE_SHA}...${GITHUB_SHA}" --jq ".files[]? | ${row}") \
277 || fail_open "Could not resolve changed files."
278
279 # The compare endpoint reports at most 300 files and pagination does
280 # not extend that list, so a full list may be hiding native changes.
281 listed=$(count_rows "$rows")
282 if [[ "$listed" -ge 300 ]]; then
283 fail_open "GitHub listed ${listed} changed files, the compare endpoint maximum."
284 fi
285 fi
286
287 paths=$(tr '\t' '\n' <<< "$rows")
288
289 # Sources scripts/mobile-native-static-check.ts lints, plus the tool
290 # and rule configuration that decides how it lints them, plus the
291 # root package.json that defines the lint:mobile command.
292 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$'
293
294 if grep -qE "$pattern" <<< "$paths"; then
295 echo "Native sources or lint configuration changed:"
296 grep -E "$pattern" <<< "$paths"
297 echo "changed=true" >> "$GITHUB_OUTPUT"
298 else
299 echo "No mobile native sources or lint configuration changed."
300 echo "changed=false" >> "$GITHUB_OUTPUT"
301 fi
302
303 mobile_native_static_analysis:
304 name: Mobile Native Static Analysis
305 needs: mobile_native_changes
306 # Skip only on an explicit "no": a gate job that failed or errored leaves the
307 # output empty, and that must run the lint rather than silently skip it.
308 if: ${{ !cancelled() && needs.mobile_native_changes.outputs.changed != 'false' }}
309 runs-on: blacksmith-6vcpu-macos-26
310 timeout-minutes: 10
311 steps:
312 - name: Checkout
313 uses: actions/checkout@v6
314 with:
315 sparse-checkout: |
316 /*
317 !/.repos/
318 sparse-checkout-cone-mode: false
319
320 - name: Setup Vite+
321 uses: voidzero-dev/setup-vp@v1
322 with:
323 node-version-file: package.json
324 cache: true
325 run-install: |
326 args:
327 - --filter=@t3tools/scripts...
328
329 - name: Install mobile native static analysis tools
330 run: brew bundle install --file apps/mobile/Brewfile
331
332 - name: Lint mobile native sources
333 run: vp run lint:mobile
334
335 release_smoke:
336 name: Release Smoke
337 runs-on: blacksmith-8vcpu-ubuntu-2404
338 timeout-minutes: 10
339 steps:
340 - name: Checkout
341 uses: actions/checkout@v6
342 with:
343 sparse-checkout: |
344 /*
345 !/.repos/
346 sparse-checkout-cone-mode: false
347
348 - name: Setup Vite+
349 uses: voidzero-dev/setup-vp@v1
350 with:
351 node-version-file: package.json
352 cache: true
353 run-install: |
354 args:
355 - --filter=@t3tools/scripts...
356
357 - name: Exercise release-only workflow steps
358 run: node scripts/release-smoke.ts