Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ci.yml

333 lines11.5 KB

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