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