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

ci.yml

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