@@ -24,18 +24,21 @@ jobs:
2424 !/.repos/
2525 sparse-checkout-cone-mode : false
2626
27+ - name : Reject repository-owned PR assets
28+ run : |
29+ files="$(git ls-files .github/pr-assets)"
30+ if test -n "$files"; then
31+ printf 'PR evidence must be uploaded to GitHub, not committed:\n%s\n' "$files" >&2
32+ exit 1
33+ fi
34+
2735 - name : Setup Vite+
2836 uses : voidzero-dev/setup-vp@v1
2937 with :
3038 node-version-file : package.json
3139 cache : true
3240 run-install : true
3341
34- - name : Setup Rust
35- uses : dtolnay/rust-toolchain@stable
36- with :
37- components : rustfmt
38-
3942 - name : Ensure Electron runtime is installed
4043 run : vp run --filter @t3tools/desktop ensure:electron
4144
4548 - name : Typecheck
4649 run : vpr typecheck
4750
48- - name : Check resource monitor formatting
49- run : cargo fmt --manifest-path native/resource-monitor/Cargo.toml -- --check
50-
5151 - name : Build desktop pipeline
5252 run : vp run build:desktop
5353
5757 grep -nE "desktopBridge|getLocalEnvironmentBootstrap|PICK_FOLDER_CHANNEL|wsUrl" apps/desktop/dist-electron/preload.cjs
5858 grep -n "__clerk_internal_electron_passkeys" apps/desktop/dist-electron/preload.cjs
5959
60+ # Everything except `t3` (apps/server). `--parallel` drops the package
61+ # dependency ordering that `vp run` applies by default: these `test` tasks
62+ # declare no `dependsOn` and resolve workspace deps from source, so ordering
63+ # only bought us idle runners between dependency layers. The concurrency
64+ # limit stays at the default 4 so peak load per runner is unchanged.
6065 test :
6166 name : Test
6267 runs-on : blacksmith-8vcpu-ubuntu-2404
@@ -77,20 +82,65 @@ jobs:
7782 cache : true
7883 run-install : true
7984
80- - name : Setup Rust
81- uses : dtolnay/rust-toolchain@stable
82-
8385 - name : Ensure Electron runtime is installed
8486 run : vp run --filter @t3tools/desktop ensure:electron
8587
88+ - name : Test
89+ run : vp run --parallel --concurrency-limit 4 --filter '!t3' --filter '!@t3tools/monorepo' test
90+
91+ # apps/server sets `fileParallelism: false`, so its 239 files run strictly
92+ # one at a time. Sharding spreads them over separate runners instead of
93+ # separate workers, so no two server test files ever share a machine and the
94+ # isolation that flag buys is preserved exactly.
95+ test_server :
96+ name : Test Server ${{ matrix.shard }}
97+ runs-on : blacksmith-8vcpu-ubuntu-2404
98+ timeout-minutes : 10
99+ strategy :
100+ fail-fast : false
101+ matrix :
102+ shard : [1, 2, 3]
103+ steps :
104+ - name : Checkout
105+ uses : actions/checkout@v6
106+ with :
107+ sparse-checkout : |
108+ /*
109+ !/.repos/
110+ sparse-checkout-cone-mode : false
111+
112+ - name : Setup Vite+
113+ uses : voidzero-dev/setup-vp@v1
114+ with :
115+ node-version-file : package.json
116+ cache : true
117+ run-install : true
118+
119+ # No Electron setup here: `t3` (apps/server) has no Electron dependency
120+ # and none of its tests touch the runtime. Only the non-server `test`
121+ # job, which covers @t3tools/desktop, needs the download.
86122 - name : Test
87123 env :
88124 T3CODE_TRANSFER_BUDGET_REPORT_PATH : ${{ runner.temp }}/t3code-transfer-budget.md
89125 T3CODE_TRANSFER_BUDGET_RESULT_PATH : ${{ runner.temp }}/thread-transfer-result.json
90- run : vp run test
126+ run : vp run --filter t3 test --shard ${{ matrix.shard }}/${{ strategy.job-total }}
91127
92- - name : Publish transfer budget report
128+ # src/server.test.ts writes the budget report, so exactly one shard
129+ # produces these files. Gating the upload on their presence keeps a
130+ # single `thread-transfer-results` artifact per run, which is the name
131+ # thread-transfer-report.yml resolves.
132+ - name : Detect transfer budget report
133+ id : transfer_budget
93134 if : always()
135+ run : |
136+ if test -f "${{ runner.temp }}/thread-transfer-result.json"; then
137+ echo "present=true" >> "$GITHUB_OUTPUT"
138+ else
139+ echo "present=false" >> "$GITHUB_OUTPUT"
140+ fi
141+
142+ - name : Publish transfer budget report
143+ if : always() && steps.transfer_budget.outputs.present == 'true'
94144 run : |
95145 if test -f "${{ runner.temp }}/t3code-transfer-budget.md"; then
96146 tee -a "$GITHUB_STEP_SUMMARY" < "${{ runner.temp }}/t3code-transfer-budget.md"
@@ -99,19 +149,124 @@ jobs:
99149 fi
100150
101151 - name : Upload thread transfer result
102- if : always()
152+ if : always() && steps.transfer_budget.outputs.present == 'true'
103153 uses : actions/upload-artifact@v7
104154 with :
105155 name : thread-transfer-results
106156 path : ${{ runner.temp }}/thread-transfer-result.json
107157 if-no-files-found : ignore
108158 retention-days : 30
109159
160+ # Split out of Check and Test: both paid ~7-9s to install a Rust toolchain
161+ # for checks that take under 3s, on the critical path of every PR.
162+ rust :
163+ name : Rust
164+ runs-on : blacksmith-4vcpu-ubuntu-2404
165+ timeout-minutes : 10
166+ steps :
167+ - name : Checkout
168+ uses : actions/checkout@v6
169+ with :
170+ sparse-checkout : |
171+ /*
172+ !/.repos/
173+ sparse-checkout-cone-mode : false
174+
175+ - name : Setup Rust
176+ uses : dtolnay/rust-toolchain@stable
177+ with :
178+ components : rustfmt
179+
180+ - name : Check resource monitor formatting
181+ run : cargo fmt --manifest-path native/resource-monitor/Cargo.toml -- --check
182+
110183 - name : Test resource monitor
111184 run : cargo test --locked --manifest-path native/resource-monitor/Cargo.toml
112185
186+ # The static analysis below needs a macOS runner, which bills ~6.7x a Linux
187+ # minute, so gate it on the native sources it actually lints instead of paying
188+ # for it on every push. Detection is API-only (no checkout) and fails open: if
189+ # the diff cannot be resolved, the lint runs.
190+ mobile_native_changes :
191+ name : Mobile Native Changes
192+ runs-on : blacksmith-2vcpu-ubuntu-2404
193+ timeout-minutes : 5
194+ permissions :
195+ contents : read
196+ pull-requests : read
197+ outputs :
198+ changed : ${{ steps.detect.outputs.changed }}
199+ steps :
200+ - name : Detect mobile native changes
201+ id : detect
202+ env :
203+ GH_TOKEN : ${{ github.token }}
204+ PR_NUMBER : ${{ github.event.pull_request.number }}
205+ BEFORE_SHA : ${{ github.event.before }}
206+ run : |
207+ set -uo pipefail
208+
209+ fail_open() {
210+ echo "$* Running native static analysis."
211+ echo "changed=true" >> "$GITHUB_OUTPUT"
212+ exit 0
213+ }
214+
215+ count_rows() {
216+ printf '%s\n' "$1" | grep -c . || true
217+ }
218+
219+ # One row per changed file, holding the new path and, for a rename,
220+ # the path it replaced: renaming a matched file out of the matched
221+ # paths removes a lint input just like editing it.
222+ row='[.filename, (.previous_filename // empty)] | @tsv'
223+
224+ if [[ -n "${PR_NUMBER}" ]]; then
225+ # The PR files endpoint stops at 3000 files and pagination cannot
226+ # extend it, so cross-check against the count the PR itself reports.
227+ expected=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" --jq '.changed_files') \
228+ || fail_open "Could not read the pull request."
229+ rows=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/files" --paginate --jq ".[] | ${row}") \
230+ || fail_open "Could not resolve changed files."
231+
232+ listed=$(count_rows "$rows")
233+ if [[ "$listed" -lt "$expected" ]]; then
234+ fail_open "GitHub listed only ${listed} of ${expected} changed files."
235+ fi
236+ else
237+ rows=$(gh api "repos/${GITHUB_REPOSITORY}/compare/${BEFORE_SHA}...${GITHUB_SHA}" --jq ".files[]? | ${row}") \
238+ || fail_open "Could not resolve changed files."
239+
240+ # The compare endpoint reports at most 300 files and pagination does
241+ # not extend that list, so a full list may be hiding native changes.
242+ listed=$(count_rows "$rows")
243+ if [[ "$listed" -ge 300 ]]; then
244+ fail_open "GitHub listed ${listed} changed files, the compare endpoint maximum."
245+ fi
246+ fi
247+
248+ paths=$(tr '\t' '\n' <<< "$rows")
249+
250+ # Sources scripts/mobile-native-static-check.ts lints, plus the tool
251+ # and rule configuration that decides how it lints them, plus the
252+ # root package.json that defines the lint:mobile command.
253+ 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$'
254+
255+ if grep -qE "$pattern" <<< "$paths"; then
256+ echo "Native sources or lint configuration changed:"
257+ grep -E "$pattern" <<< "$paths"
258+ echo "changed=true" >> "$GITHUB_OUTPUT"
259+ else
260+ echo "No mobile native sources or lint configuration changed."
261+ echo "changed=false" >> "$GITHUB_OUTPUT"
262+ fi
263+
113264 mobile_native_static_analysis :
114265 name : Mobile Native Static Analysis
266+ needs : mobile_native_changes
267+ # Skip only on an explicit "no": a gate job that failed or errored leaves the
268+ # output empty, and that must run the lint rather than silently skip it.
269+ if : ${{ !cancelled() && needs.mobile_native_changes.outputs.changed != 'false' }}
115270 runs-on : blacksmith-6vcpu-macos-26
116271 timeout-minutes : 10
117272 steps :
0 commit comments