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

ci.yml

345 lines12.1 KB

1name: CI
2​
3on:
4 pull_request:
5 push:
6 branches:
7 - main
8 # Keep v2 checked while its pull request has conflicts with main.
9 - t3code/codex-turn-mapping
10​
11permissions:
12 contents: read
13​
14concurrency:
15 group: ci-${{ github.event.pull_request.number || github.sha }}
16 cancel-in-progress: ${{ github.event_name == 'pull_request' }}
17​
18jobs:
19 check:
20 name: Check
21 runs-on: blacksmith-8vcpu-ubuntu-2404
22 timeout-minutes: 10
23 steps:
24 - name: Checkout
25 uses: actions/checkout@v6
26 with:
27 sparse-checkout: |
28 /*
29 !/.repos/
30 sparse-checkout-cone-mode: false
31​
32 - name: Reject repository-owned PR assets
33 run: |
34 files="$(git ls-files .github/pr-assets)"
35 if test -n "$files"; then
36 printf 'PR evidence must be uploaded to GitHub, not committed:\n%s\n' "$files" >&2
37 exit 1
38 fi
39​
40 - name: Setup Vite+
41 uses: voidzero-dev/setup-vp@v1
42 with:
43 node-version-file: package.json
44 cache: true
45 run-install: true
46​
47 - name: Ensure Electron runtime is installed
48 run: vp run --filter @t3tools/desktop ensure:electron
49​
50 - name: Check
51 run: vp check
52​
53 - name: Typecheck
54 run: vpr typecheck
55​
56 - uses: ./.github/actions/setup-apt-mirrors
57​
58 - name: Install browser secret helper build libraries
59 run: |
60 sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
61 sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config
62​
63 - name: Build desktop pipeline
64 run: vp run build:desktop
65​
66 - name: Verify preload bundle output
67 run: node apps/desktop/scripts/verify-preload-bundle.mjs
68​
69 # Everything except `t3` (apps/server). `--parallel` drops the package
70 # dependency ordering that `vp run` applies by default: these `test` tasks
71 # declare no `dependsOn` and resolve workspace deps from source, so ordering
72 # only bought us idle runners between dependency layers. The concurrency
73 # limit stays at the default 4 so peak load per runner is unchanged.
74 test:
75 name: Test
76 runs-on: blacksmith-8vcpu-ubuntu-2404
77 timeout-minutes: 10
78 steps:
79 - name: Checkout
80 uses: actions/checkout@v6
81 with:
82 sparse-checkout: |
83 /*
84 !/.repos/
85 sparse-checkout-cone-mode: false
86​
87 # Blacksmith boots GitHub's Ubuntu runner image (gcc is usually present),
88 # but ACP process-tree live tests compile a small pthread fixture with `cc`
89 # and soft-skip when it is missing. Install build-essential so that path
90 # always runs in CI instead of silently no-oping.
91 - name: Install C toolchain for process-tree fixtures
92 run: |
93 sudo apt-get update
94 sudo apt-get install -y --no-install-recommends build-essential
95 command -v cc
96​
97 - name: Setup Vite+
98 uses: voidzero-dev/setup-vp@v1
99 with:
100 node-version-file: package.json
101 cache: true
102 run-install: true
103​
104 - name: Ensure Electron runtime is installed
105 run: vp run --filter @t3tools/desktop ensure:electron
106​
107 - uses: ./.github/actions/setup-apt-mirrors
108​
109 - name: Install browser secret helper build libraries
110 run: |
111 sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
112 sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config
113​
114 - name: Test
115 run: vp run --parallel --concurrency-limit 4 --filter '!t3' --filter '!@t3tools/monorepo' test
116​
117 # apps/server sets `fileParallelism: false`, so its 239 files run strictly
118 # one at a time. Sharding spreads them over separate runners instead of
119 # separate workers, so no two server test files ever share a machine and the
120 # isolation that flag buys is preserved exactly.
121 test_server:
122 name: Test Server ${{ matrix.shard }}
123 runs-on: blacksmith-8vcpu-ubuntu-2404
124 timeout-minutes: 10
125 strategy:
126 fail-fast: false
127 matrix:
128 shard: [1, 2, 3]
129 steps:
130 - name: Checkout
131 uses: actions/checkout@v6
132 with:
133 sparse-checkout: |
134 /*
135 !/.repos/
136 sparse-checkout-cone-mode: false
137​
138 - name: Setup Vite+
139 uses: voidzero-dev/setup-vp@v1
140 with:
141 node-version-file: package.json
142 cache: true
143 run-install: true
144​
145 # No Electron setup here: `t3` (apps/server) has no Electron dependency
146 # and none of its tests touch the runtime. Only the non-server `test`
147 # job, which covers @t3tools/desktop, needs the download.
148 - name: Test
149 env:
150 T3CODE_TRANSFER_BUDGET_REPORT_PATH: ${{ runner.temp }}/t3code-transfer-budget.md
151 T3CODE_TRANSFER_BUDGET_RESULT_PATH: ${{ runner.temp }}/thread-transfer-result.json
152 run: vp run --filter t3 test --shard ${{ matrix.shard }}/${{ strategy.job-total }}
153​
154 # src/server.test.ts writes the budget report, so exactly one shard
155 # produces these files. Gating the upload on their presence keeps a
156 # single `thread-transfer-results` artifact per run, which is the name
157 # thread-transfer-report.yml resolves.
158 - name: Detect transfer budget report
159 id: transfer_budget
160 if: always()
161 run: |
162 if test -f "${{ runner.temp }}/thread-transfer-result.json"; then
163 echo "present=true" >> "$GITHUB_OUTPUT"
164 else
165 echo "present=false" >> "$GITHUB_OUTPUT"
166 fi
167​
168 - name: Publish transfer budget report
169 if: always() && steps.transfer_budget.outputs.present == 'true'
170 run: |
171 if test -f "${{ runner.temp }}/t3code-transfer-budget.md"; then
172 tee -a "$GITHUB_STEP_SUMMARY" < "${{ runner.temp }}/t3code-transfer-budget.md"
173 else
174 echo "Transfer budget report was not produced." >> "$GITHUB_STEP_SUMMARY"
175 fi
176​
177 - name: Upload thread transfer result
178 if: always() && steps.transfer_budget.outputs.present == 'true'
179 uses: actions/upload-artifact@v7
180 with:
181 name: thread-transfer-results
182 path: ${{ runner.temp }}/thread-transfer-result.json
183 if-no-files-found: ignore
184 retention-days: 30
185​
186 # Split out of Check and Test: both paid ~7-9s to install a Rust toolchain
187 # for checks that take under 3s, on the critical path of every PR.
188 rust:
189 name: Rust
190 runs-on: blacksmith-4vcpu-ubuntu-2404
191 timeout-minutes: 10
192 steps:
193 - name: Checkout
194 uses: actions/checkout@v6
195 with:
196 sparse-checkout: |
197 /*
198 !/.repos/
199 sparse-checkout-cone-mode: false
200​
201 - name: Setup Rust
202 uses: dtolnay/rust-toolchain@stable
203 with:
204 components: rustfmt
205​
206 - name: Check resource monitor formatting
207 run: cargo fmt --manifest-path native/resource-monitor/Cargo.toml -- --check
208​
209 - name: Test resource monitor
210 run: cargo test --locked --manifest-path native/resource-monitor/Cargo.toml
211​
212 # The static analysis below needs a macOS runner, which bills ~6.7x a Linux
213 # minute, so gate it on the native sources it actually lints instead of paying
214 # for it on every push. Detection is API-only (no checkout) and fails open: if
215 # the diff cannot be resolved, the lint runs.
216 mobile_native_changes:
217 name: Mobile Native Changes
218 runs-on: blacksmith-2vcpu-ubuntu-2404
219 timeout-minutes: 5
220 permissions:
221 contents: read
222 pull-requests: read
223 outputs:
224 changed: ${{ steps.detect.outputs.changed }}
225 steps:
226 - name: Detect mobile native changes
227 id: detect
228 env:
229 GH_TOKEN: ${{ github.token }}
230 PR_NUMBER: ${{ github.event.pull_request.number }}
231 BEFORE_SHA: ${{ github.event.before }}
232 run: |
233 set -uo pipefail
234​
235 fail_open() {
236 echo "$* Running native static analysis."
237 echo "changed=true" >> "$GITHUB_OUTPUT"
238 exit 0
239 }
240​
241 count_rows() {
242 printf '%s\n' "$1" | grep -c . || true
243 }
244​
245 # One row per changed file, holding the new path and, for a rename,
246 # the path it replaced: renaming a matched file out of the matched
247 # paths removes a lint input just like editing it.
248 row='[.filename, (.previous_filename // empty)] | @tsv'
249​
250 if [[ -n "${PR_NUMBER}" ]]; then
251 # The PR files endpoint stops at 3000 files and pagination cannot
252 # extend it, so cross-check against the count the PR itself reports.
253 expected=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" --jq '.changed_files') \
254 || fail_open "Could not read the pull request."
255 rows=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/files" --paginate --jq ".[] | ${row}") \
256 || fail_open "Could not resolve changed files."
257​
258 listed=$(count_rows "$rows")
259 if [[ "$listed" -lt "$expected" ]]; then
260 fail_open "GitHub listed only ${listed} of ${expected} changed files."
261 fi
262 else
263 rows=$(gh api "repos/${GITHUB_REPOSITORY}/compare/${BEFORE_SHA}...${GITHUB_SHA}" --jq ".files[]? | ${row}") \
264 || fail_open "Could not resolve changed files."
265​
266 # The compare endpoint reports at most 300 files and pagination does
267 # not extend that list, so a full list may be hiding native changes.
268 listed=$(count_rows "$rows")
269 if [[ "$listed" -ge 300 ]]; then
270 fail_open "GitHub listed ${listed} changed files, the compare endpoint maximum."
271 fi
272 fi
273​
274 paths=$(tr '\t' '\n' <<< "$rows")
275​
276 # Sources scripts/mobile-native-static-check.ts lints, plus the tool
277 # and rule configuration that decides how it lints them, plus the
278 # root package.json that defines the lint:mobile command.
279 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$'
280​
281 if grep -qE "$pattern" <<< "$paths"; then
282 echo "Native sources or lint configuration changed:"
283 grep -E "$pattern" <<< "$paths"
284 echo "changed=true" >> "$GITHUB_OUTPUT"
285 else
286 echo "No mobile native sources or lint configuration changed."
287 echo "changed=false" >> "$GITHUB_OUTPUT"
288 fi
289​
290 mobile_native_static_analysis:
291 name: Mobile Native Static Analysis
292 needs: mobile_native_changes
293 # Skip only on an explicit "no": a gate job that failed or errored leaves the
294 # output empty, and that must run the lint rather than silently skip it.
295 if: ${{ !cancelled() && needs.mobile_native_changes.outputs.changed != 'false' }}
296 runs-on: blacksmith-6vcpu-macos-26
297 timeout-minutes: 10
298 steps:
299 - name: Checkout
300 uses: actions/checkout@v6
301 with:
302 sparse-checkout: |
303 /*
304 !/.repos/
305 sparse-checkout-cone-mode: false
306​
307 - name: Setup Vite+
308 uses: voidzero-dev/setup-vp@v1
309 with:
310 node-version-file: package.json
311 cache: true
312 run-install: |
313 args:
314 - --filter=@t3tools/scripts...
315​
316 - name: Install mobile native static analysis tools
317 run: brew bundle install --file apps/mobile/Brewfile
318​
319 - name: Lint mobile native sources
320 run: vp run lint:mobile
321​
322 release_smoke:
323 name: Release Smoke
324 runs-on: blacksmith-8vcpu-ubuntu-2404
325 timeout-minutes: 10
326 steps:
327 - name: Checkout
328 uses: actions/checkout@v6
329 with:
330 sparse-checkout: |
331 /*
332 !/.repos/
333 sparse-checkout-cone-mode: false
334​
335 - name: Setup Vite+
336 uses: voidzero-dev/setup-vp@v1
337 with:
338 node-version-file: package.json
339 cache: true
340 run-install: |
341 args:
342 - --filter=@t3tools/scripts...
343​
344 - name: Exercise release-only workflow steps
345 run: node scripts/release-smoke.ts