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