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

ci.yml

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