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