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

ci.yml

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