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