Open History to see the last commit
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 Rust formatting
202 run: |
203 for crate in resource-monitor kde-snap-shot hyprland-snap-shot; do
204 cargo fmt --manifest-path "native/$crate/Cargo.toml" -- --check
205 done
206
207 - name: Test Rust crates
208 run: |
209 for crate in resource-monitor kde-snap-shot hyprland-snap-shot; do
210 cargo test --locked --manifest-path "native/$crate/Cargo.toml"
211 done
212
213 # The static analysis below needs a macOS runner, which bills ~6.7x a Linux
214 # minute, so gate it on the native sources it actually lints instead of paying
215 # for it on every push. Detection is API-only (no checkout) and fails open: if
216 # the diff cannot be resolved, the lint runs.
217 mobile_native_changes:
218 name: Mobile Native Changes
219 runs-on: blacksmith-2vcpu-ubuntu-2404
220 timeout-minutes: 5
221 permissions:
222 contents: read
223 pull-requests: read
224 outputs:
225 changed: ${{ steps.detect.outputs.changed }}
226 steps:
227 - name: Detect mobile native changes
228 id: detect
229 env:
230 GH_TOKEN: ${{ github.token }}
231 PR_NUMBER: ${{ github.event.pull_request.number }}
232 BEFORE_SHA: ${{ github.event.before }}
233 run: |
234 set -uo pipefail
235
236 fail_open() {
237 echo "$* Running native static analysis."
238 echo "changed=true" >> "$GITHUB_OUTPUT"
239 exit 0
240 }
241
242 count_rows() {
243 printf '%s\n' "$1" | grep -c . || true
244 }
245
246 # One row per changed file, holding the new path and, for a rename,
247 # the path it replaced: renaming a matched file out of the matched
248 # paths removes a lint input just like editing it.
249 row='[.filename, (.previous_filename // empty)] | @tsv'
250
251 if [[ -n "${PR_NUMBER}" ]]; then
252 # The PR files endpoint stops at 3000 files and pagination cannot
253 # extend it, so cross-check against the count the PR itself reports.
254 expected=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" --jq '.changed_files') \
255 || fail_open "Could not read the pull request."
256 rows=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/files" --paginate --jq ".[] | ${row}") \
257 || fail_open "Could not resolve changed files."
258
259 listed=$(count_rows "$rows")
260 if [[ "$listed" -lt "$expected" ]]; then
261 fail_open "GitHub listed only ${listed} of ${expected} changed files."
262 fi
263 else
264 rows=$(gh api "repos/${GITHUB_REPOSITORY}/compare/${BEFORE_SHA}...${GITHUB_SHA}" --jq ".files[]? | ${row}") \
265 || fail_open "Could not resolve changed files."
266
267 # The compare endpoint reports at most 300 files and pagination does
268 # not extend that list, so a full list may be hiding native changes.
269 listed=$(count_rows "$rows")
270 if [[ "$listed" -ge 300 ]]; then
271 fail_open "GitHub listed ${listed} changed files, the compare endpoint maximum."
272 fi
273 fi
274
275 paths=$(tr '\t' '\n' <<< "$rows")
276
277 # Sources scripts/mobile-native-static-check.ts lints, plus the tool
278 # and rule configuration that decides how it lints them, plus the
279 # root package.json that defines the lint:mobile command.
280 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$'
281
282 if grep -qE "$pattern" <<< "$paths"; then
283 echo "Native sources or lint configuration changed:"
284 grep -E "$pattern" <<< "$paths"
285 echo "changed=true" >> "$GITHUB_OUTPUT"
286 else
287 echo "No mobile native sources or lint configuration changed."
288 echo "changed=false" >> "$GITHUB_OUTPUT"
289 fi
290
291 mobile_native_static_analysis:
292 name: Mobile Native Static Analysis
293 needs: mobile_native_changes
294 # Skip only on an explicit "no": a gate job that failed or errored leaves the
295 # output empty, and that must run the lint rather than silently skip it.
296 if: ${{ !cancelled() && needs.mobile_native_changes.outputs.changed != 'false' }}
297 runs-on: blacksmith-6vcpu-macos-26
298 timeout-minutes: 10
299 steps:
300 - name: Checkout
301 uses: actions/checkout@v6
302 with:
303 sparse-checkout: |
304 /*
305 !/.repos/
306 sparse-checkout-cone-mode: false
307
308 - name: Setup Vite+
309 uses: voidzero-dev/setup-vp@v1
310 with:
311 node-version-file: package.json
312 cache: true
313 run-install: |
314 args:
315 - --filter=@t3tools/scripts...
316
317 - name: Install mobile native static analysis tools
318 run: brew bundle install --file apps/mobile/Brewfile
319
320 - name: Lint mobile native sources
321 run: vp run lint:mobile
322
323 release_smoke:
324 name: Release Smoke
325 runs-on: blacksmith-8vcpu-ubuntu-2404
326 timeout-minutes: 10
327 steps:
328 - name: Checkout
329 uses: actions/checkout@v6
330 with:
331 sparse-checkout: |
332 /*
333 !/.repos/
334 sparse-checkout-cone-mode: false
335
336 - name: Setup Vite+
337 uses: voidzero-dev/setup-vp@v1
338 with:
339 node-version-file: package.json
340 cache: true
341 run-install: |
342 args:
343 - --filter=@t3tools/scripts...
344
345 - name: Exercise release-only workflow steps
346 run: node scripts/release-smoke.ts