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

ci.yml

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