The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 23, 09:15 UTC
ci: skip jobs a pull request cannot affect (#19587)
maria committed
Oct 15, 2026 at 23:39 UTC
2d743c2f168fd818dd0e14fc13f39203220423ad
5 files changed
+403
-91
.github/actions/ci-changes/action.yml
new
+63
@@ -0,0 +1,63 @@
1
+name: CI changes
2
+description: Decide which CI jobs a change needs. See .github/scripts/ci-changes.cjs.
3
+outputs:
4
+ typecheck:
5
+ value: ${{ steps.detect.outputs.typecheck }}
6
+ build:
7
+ value: ${{ steps.detect.outputs.build }}
8
+ test:
9
+ value: ${{ steps.detect.outputs.test }}
10
+ test_packages:
11
+ value: ${{ steps.detect.outputs.test_packages }}
12
+ test_web:
13
+ value: ${{ steps.detect.outputs.test_web }}
14
+ test_server:
15
+ value: ${{ steps.detect.outputs.test_server }}
16
+ rust:
17
+ value: ${{ steps.detect.outputs.rust }}
18
+ release_smoke:
19
+ value: ${{ steps.detect.outputs.release_smoke }}
20
+ mobile_native:
21
+ value: ${{ steps.detect.outputs.mobile_native }}
22
+runs:
23
+ using: composite
24
+ steps:
25
+ - id: detect
26
+ shell: bash
27
+ env:
28
+ EVENT_NAME: ${{ github.event_name }}
29
+ BEFORE_SHA: ${{ github.event.before }}
30
+ run: |
31
+ set -uo pipefail
32
+
33
+ decide() {
34
+ node .github/scripts/ci-changes.cjs "$@" | tee -a "$GITHUB_OUTPUT"
35
+ exit "${PIPESTATUS[0]}"
36
+ }
37
+
38
+ fail_open() {
39
+ echo "$* Running every job."
40
+ decide
41
+ }
42
+
43
+ # Reads the change from git rather than the REST API: every job that
44
+ # runs this shares the repository's 1,000 requests/hour GITHUB_TOKEN quota.
45
+ if [[ "$EVENT_NAME" == pull_request ]]; then
46
+ # A pull request checks out GitHub's merge commit with fetch-depth: 2,
47
+ # so its first parent is the base branch and the diff is the PR's change.
48
+ base=HEAD^1
49
+ mode=()
50
+ else
51
+ base=$BEFORE_SHA
52
+ git fetch --quiet --no-tags --depth=1 --filter=blob:none origin "$base" \
53
+ || fail_open "Could not fetch ${base}."
54
+ # main keeps a full run as the backstop for anything the gate misses.
55
+ mode=(--full)
56
+ fi
57
+
58
+ # --no-renames lists a rename as its old and new path: renaming a file out
59
+ # of a package changes that package just like editing it. It also keeps
60
+ # git from fetching file contents to score renames.
61
+ git diff --name-only --no-renames "$base" HEAD > "$RUNNER_TEMP/changed-paths" \
62
+ || fail_open "Could not diff against ${base}."
63
+ decide --paths "$RUNNER_TEMP/changed-paths" "${mode[@]}"
.github/scripts/ci-changes.cjs
new
+203
@@ -0,0 +1,203 @@
1
+// Decides which CI jobs a change needs. Prints `key=value` lines for
2
+// $GITHUB_OUTPUT; a job runs unless its key is "false".
3
+//
4
+// node ci-changes.cjs --paths <file> gate by the listed paths
5
+// node ci-changes.cjs --paths <file> --full run every Linux job, gate only the macOS lint
6
+// node ci-changes.cjs changed paths unknown: run everything
7
+//
8
+// Every changed path maps to workspace packages, which then pull in their
9
+// dependents from package.json. A path this file does not recognize runs
10
+// everything, so a new root file or directory can only cost minutes.
11
+const fs = require("node:fs");
12
+const path = require("node:path");
13
+
14
+const root = path.resolve(__dirname, "../..");
15
+
16
+// Never read by a build, typecheck, or test. Lint still formats them.
17
+const INERT = [
18
+ /^docs\//,
19
+ /^\.(agents|cursor|vscode|devcontainer|macroscope|repos)\//,
20
+ /^[^/]+\.md$/,
21
+ /^LICENSE$/,
22
+];
23
+
24
+// Run everything: the root vite.config.ts loads the first as setup for every
25
+// package's tests, and the vendored mobile tarballs are installed dependencies.
26
+const RUNS_EVERYTHING = [
27
+ /^packages\/shared\/src\/(HostProcess|testing\/longTempDir)\.ts$/,
28
+ /^apps\/mobile\/deps\//,
29
+];
30
+
31
+// Paths outside a package, or files inside one that other packages read
32
+// through relative imports rather than a package.json dependency.
33
+const EXTRA_OWNERS = [
34
+ // Vite configs and tsconfigs of these apps import scripts/lib directly.
35
+ [/^scripts\/lib\//, ["@t3tools/desktop", "@t3tools/mobile", "@t3tools/web", "t3"]],
36
+ // scripts/build-desktop-artifact.ts reads the GNOME extension manifest.
37
+ [/^apps\/desktop\/gnome-extension\//, ["@t3tools/scripts"]],
38
+ [/^native\/browser-secret\//, ["@t3tools/desktop"]],
39
+ [/^native\/libghostty-vt\//, ["@t3tools/web"]],
40
+];
41
+const RUST = /^native\/(resource-monitor|kde-snap-shot|hyprland-snap-shot)\//;
42
+
43
+// Tests that read another package's files without declaring it. The scripts
44
+// tests read app manifests, assets, and sources (cursor-sdk-packaging,
45
+// third-party-licenses, brand-assets, build-desktop-artifact).
46
+const TEST_ONLY_DEPS = {
47
+ "@t3tools/provider-pi": ["@t3tools/client-runtime"],
48
+ "@t3tools/scripts": [
49
+ "@t3tools/desktop",
50
+ "@t3tools/mobile",
51
+ "@t3tools/web",
52
+ "t3",
53
+ "@t3tools/provider-cursor",
54
+ ],
55
+};
56
+// Declared dependencies that only feed a build step: the server bundles the
57
+// built web app (apps/server/vite.config.ts) but never imports it.
58
+const BUILD_ONLY_DEPS = { t3: ["@t3tools/web"] };
59
+
60
+// Sources scripts/mobile-native-static-check.ts lints, plus the tool and rule
61
+// configuration that decides how it lints them, plus the root package.json
62
+// that defines the lint:mobile command.
63
+const MOBILE_NATIVE =
64
+ /^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$|^\.github\/scripts\/ci-changes\.cjs$|^\.github\/actions\/ci-changes\//;
65
+
66
+// Jobs that test every package except these, which have jobs of their own.
67
+const OWN_TEST_JOB = new Set(["t3", "@t3tools/web", "@t3tools/monorepo"]);
68
+
69
+function readWorkspace() {
70
+ const patterns = [];
71
+ let inPackages = false;
72
+ for (const line of fs.readFileSync(path.join(root, "pnpm-workspace.yaml"), "utf8").split("\n")) {
73
+ if (/^\S/.test(line)) inPackages = line.startsWith("packages:");
74
+ const entry = inPackages && line.match(/^\s+-\s+["']?([^"'\s]+)/);
75
+ if (entry) patterns.push(entry[1]);
76
+ }
77
+
78
+ const dirs = patterns.flatMap((pattern) => {
79
+ if (!pattern.endsWith("/*")) return [pattern];
80
+ const parent = pattern.slice(0, -2);
81
+ return fs.readdirSync(path.join(root, parent)).map((name) => `${parent}/${name}`);
82
+ });
83
+
84
+ const packages = [];
85
+ for (const dir of dirs) {
86
+ const manifestPath = path.join(root, dir, "package.json");
87
+ if (!fs.existsSync(manifestPath)) continue;
88
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
89
+ const deps = {
90
+ ...manifest.dependencies,
91
+ ...manifest.devDependencies,
92
+ ...manifest.peerDependencies,
93
+ };
94
+ packages.push({
95
+ name: manifest.name,
96
+ dir,
97
+ hasTest: Boolean(manifest.scripts?.test),
98
+ deps: Object.keys(deps).filter(
99
+ (dep) =>
100
+ String(deps[dep]).startsWith("workspace:") &&
101
+ !BUILD_ONLY_DEPS[manifest.name]?.includes(dep),
102
+ ),
103
+ });
104
+ }
105
+ return packages;
106
+}
107
+
108
+// Returns the packages a path touches, [] for an inert path, or null when the
109
+// path is not understood and everything must run.
110
+function ownersOf(file, packages) {
111
+ if (INERT.some((pattern) => pattern.test(file))) return [];
112
+ // A manifest can change dependencies or versions other packages read.
113
+ if (path.posix.basename(file) === "package.json") return null;
114
+ if (RUNS_EVERYTHING.some((pattern) => pattern.test(file))) return null;
115
+ // scripts/build-desktop-artifact.test.ts reads the crates' sources.
116
+ if (RUST.test(file)) return ["@t3tools/scripts"];
117
+
118
+ const extra = EXTRA_OWNERS.flatMap(([pattern, names]) => (pattern.test(file) ? names : []));
119
+ const owner = packages
120
+ .filter((pkg) => file.startsWith(`${pkg.dir}/`))
121
+ .sort((a, b) => b.dir.length - a.dir.length)[0];
122
+ if (owner) return [owner.name, ...extra];
123
+ return extra.length > 0 ? extra : null;
124
+}
125
+
126
+function decide(files, packages, full) {
127
+ const all = new Set(packages.map((pkg) => pkg.name));
128
+ let affected = new Set();
129
+ let everything = full || files === null;
130
+ let rust = false;
131
+
132
+ for (const file of files ?? []) {
133
+ if (RUST.test(file)) rust = true;
134
+ const owners = ownersOf(file, packages);
135
+ if (owners === null) {
136
+ everything = true;
137
+ console.error(`Runs everything: ${file}`);
138
+ } else {
139
+ for (const owner of owners) affected.add(owner);
140
+ }
141
+ }
142
+
143
+ // Release smoke reads scripts/ itself, not what the scripts tests read.
144
+ let scriptsChanged = everything;
145
+ if (everything) {
146
+ affected = all;
147
+ } else {
148
+ // Add dependents until nothing changes.
149
+ let grew = true;
150
+ while (grew) {
151
+ grew = false;
152
+ for (const pkg of packages) {
153
+ if (!affected.has(pkg.name) && pkg.deps.some((dep) => affected.has(dep))) {
154
+ affected.add(pkg.name);
155
+ grew = true;
156
+ }
157
+ }
158
+ }
159
+ scriptsChanged = affected.has("@t3tools/scripts");
160
+ for (const [name, deps] of Object.entries(TEST_ONLY_DEPS)) {
161
+ if (deps.some((dep) => affected.has(dep))) affected.add(name);
162
+ }
163
+ }
164
+
165
+ const tested = packages.filter(
166
+ (pkg) => pkg.hasTest && !OWN_TEST_JOB.has(pkg.name) && affected.has(pkg.name),
167
+ );
168
+ const has = (name) => affected.has(name);
169
+
170
+ return {
171
+ affected: [...affected].sort(),
172
+ outputs: {
173
+ typecheck: affected.size > 0,
174
+ build: has("@t3tools/desktop") || has("t3") || has("@t3tools/web"),
175
+ test: tested.length > 0,
176
+ // Empty means every package the Test job covers.
177
+ test_packages: everything ? "" : tested.map((pkg) => pkg.name).join(" "),
178
+ test_web: has("@t3tools/web"),
179
+ test_server: has("t3"),
180
+ rust: everything || rust,
181
+ release_smoke: scriptsChanged,
182
+ mobile_native: files === null || files.some((file) => MOBILE_NATIVE.test(file)),
183
+ },
184
+ };
185
+}
186
+
187
+function main() {
188
+ const args = process.argv.slice(2);
189
+ const pathsIndex = args.indexOf("--paths");
190
+ const files =
191
+ pathsIndex === -1
192
+ ? null
193
+ : fs
194
+ .readFileSync(args[pathsIndex + 1], "utf8")
195
+ .split("\n")
196
+ .filter(Boolean);
197
+ const { affected, outputs } = decide(files, readWorkspace(), args.includes("--full"));
198
+
199
+ console.error(`Affected packages: ${affected.join(", ") || "none"}`);
200
+ for (const [key, value] of Object.entries(outputs)) console.log(`${key}=${value}`);
201
+}
202
+
203
+main();
.github/scripts/thread-transfer-report.cjs
+7
@@ -278,6 +278,13 @@ async function resolve({ github, context, core }) {
278
279
const sourceArtifacts = await artifactsForRun(github, owner, repo, source.id);
280
const sourceArtifact = findResultArtifact(sourceArtifacts);
281
+ // CI requires the artifact whenever the server tests run, so a passing run
282
+ // without one skipped them because the PR cannot affect the server.
283
+ if (!sourceArtifact && source.conclusion === "success") {
284
+ core.info("CI skipped the server tests for this change; nothing to report.");
285
+ core.setOutput("publish", "false");
286
+ return;
287
+ }
288
const workflowRuns = await github.paginate(github.rest.actions.listWorkflowRuns, {
289
owner,
290
repo,
.github/scripts/thread-transfer-report.test.cjs
+42
@@ -216,6 +216,48 @@ test("does not guess when a fallback commit belongs to multiple PRs", async () =
216
assert.equal(fetchedPull, false);
217
});
218
219
+test("does not report a passing run that skipped the server tests", async () => {
220
+ const outputs = {};
221
+ const listWorkflowRunArtifacts = () => {};
222
+ await resolve({
223
+ github: {
224
+ paginate: async (method) => {
225
+ assert.equal(method, listWorkflowRunArtifacts);
226
+ return [];
227
+ },
228
+ rest: {
229
+ actions: { listWorkflowRunArtifacts },
230
+ pulls: {
231
+ get: async () => ({
232
+ data: { head: { sha: "head-sha" }, base: { sha: "base-sha", ref: "main" } },
233
+ }),
234
+ },
235
+ },
236
+ },
237
+ context: {
238
+ repo: { owner: "pingdotgg", repo: "t3code" },
239
+ payload: {
240
+ workflow_run: {
241
+ id: 2,
242
+ event: "pull_request",
243
+ workflow_id: 3,
244
+ head_sha: "head-sha",
245
+ conclusion: "success",
246
+ pull_requests: [{ number: 5350 }],
247
+ },
248
+ },
249
+ },
250
+ core: {
251
+ info: () => {},
252
+ setOutput: (key, value) => {
253
+ outputs[key] = value;
254
+ },
255
+ },
256
+ });
257
+
258
+ assert.equal(outputs.publish, "false");
259
+});
260
+
261
test("does not publish a stale result after the PR head advances", async () => {
262
let listedComments = false;
263
const info = [];
.github/workflows/ci.yml
+88
-91
@@ -14,9 +14,50 @@ concurrency:
14
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
15
16
jobs:
17
+ # Skips jobs a pull request cannot affect: a web change does not run the
18
+ # server shards, a server change does not run the mobile tests, and the macOS
19
+ # lint (~6.7x a Linux minute) runs only for native mobile sources.
20
+ # .github/scripts/ci-changes.cjs maps changed files to workspace packages and
21
+ # their dependents. Pushes to main still run every Linux job. Detection fails
22
+ # open: if the diff cannot be resolved, everything runs.
23
+ changes:
24
+ name: Changes
25
+ runs-on: blacksmith-2vcpu-ubuntu-2404
26
+ timeout-minutes: 5
27
+ outputs:
28
+ typecheck: ${{ steps.detect.outputs.typecheck }}
29
+ build: ${{ steps.detect.outputs.build }}
30
+ test: ${{ steps.detect.outputs.test }}
31
+ test_packages: ${{ steps.detect.outputs.test_packages }}
32
+ test_web: ${{ steps.detect.outputs.test_web }}
33
+ test_server: ${{ steps.detect.outputs.test_server }}
34
+ rust: ${{ steps.detect.outputs.rust }}
35
+ release_smoke: ${{ steps.detect.outputs.release_smoke }}
36
+ mobile_native: ${{ steps.detect.outputs.mobile_native }}
37
+ steps:
38
+ # Only the package manifests the script reads to build the dependency graph.
39
+ # Depth 2 brings the base commit the change is diffed against.
40
+ - name: Checkout
41
+ uses: actions/checkout@v6
42
+ with:
43
+ fetch-depth: 2
44
+ sparse-checkout: |
45
+ /pnpm-workspace.yaml
46
+ /.github/scripts/ci-changes.cjs
47
+ /.github/actions/ci-changes/
48
+ /*/package.json
49
+ /*/*/package.json
50
+ !/.repos/
51
+ sparse-checkout-cone-mode: false
52
+
53
+ - name: Detect affected jobs
54
+ id: detect
55
+ uses: ./.github/actions/ci-changes
56
+
57
# Lint, typecheck, and the desktop build each get a runner so they run side by
18
- # side instead of one after another. The `Check` job at the end of this file
19
- # passes only when every other job does.
58
+ # side instead of one after another. Lint always runs: it formats every file,
59
+ # docs included. The `Check` job at the end of this file passes only when
60
+ # every other job passes or was skipped by `changes`.
61
lint:
62
name: Lint
63
runs-on: blacksmith-8vcpu-ubuntu-2404
@@ -60,6 +101,8 @@ jobs:
101
102
typecheck:
103
name: Typecheck
104
+ needs: changes
105
+ if: ${{ !cancelled() && needs.changes.outputs.typecheck != 'false' }}
106
runs-on: blacksmith-8vcpu-ubuntu-2404
107
timeout-minutes: 10
108
steps:
@@ -86,6 +129,8 @@ jobs:
129
130
build:
131
name: Build
132
+ needs: changes
133
+ if: ${{ !cancelled() && needs.changes.outputs.build != 'false' }}
134
runs-on: blacksmith-8vcpu-ubuntu-2404
135
timeout-minutes: 10
136
steps:
@@ -140,6 +185,8 @@ jobs:
185
# per runner is unchanged.
186
test:
187
name: Test
188
+ needs: changes
189
+ if: ${{ !cancelled() && needs.changes.outputs.test != 'false' }}
190
runs-on: blacksmith-8vcpu-ubuntu-2404
191
timeout-minutes: 10
192
steps:
@@ -197,13 +244,24 @@ jobs:
244
cat "$RUNNER_TEMP/apt.log"
245
exit "$(cat "$RUNNER_TEMP/apt-status")"
246
247
+ # `changes` lists the affected packages, or nothing when all of them are.
248
- name: Test
201
- run: vp run --parallel --concurrency-limit 4 --filter '!t3' --filter '!@t3tools/monorepo' --filter '!@t3tools/web' test
249
+ env:
250
+ TEST_PACKAGES: ${{ needs.changes.outputs.test_packages }}
251
+ run: |
252
+ filters=(--filter '!t3' --filter '!@t3tools/monorepo' --filter '!@t3tools/web')
253
+ if [[ -n "$TEST_PACKAGES" ]]; then
254
+ filters=()
255
+ for package in $TEST_PACKAGES; do filters+=(--filter "$package"); done
256
+ fi
257
+ vp run --parallel --concurrency-limit 4 "${filters[@]}" test
258
259
# The web suite is the largest outside the server. In the shared Test job it
260
# started last and ran alone for about 40s after everything else finished.
261
test_web:
262
name: Test Web
263
+ needs: changes
264
+ if: ${{ !cancelled() && needs.changes.outputs.test_web != 'false' }}
265
runs-on: blacksmith-8vcpu-ubuntu-2404
266
timeout-minutes: 10
267
steps:
@@ -231,6 +289,8 @@ jobs:
289
# isolation that flag buys is preserved exactly. One file at a time keeps
290
# about 1.5 cores busy, so 4 vCPU runners lose nothing against 8. The shards
291
# split files by recorded duration (apps/server/src/testUtils/weightedShardSequencer.ts).
292
+ # The shards are the longest jobs, so they gate themselves instead of waiting
293
+ # ~15s for `changes`: a shard the change cannot affect stops after checkout.
294
test_server:
295
name: Test Server ${{ matrix.shard }}
296
runs-on: blacksmith-4vcpu-ubuntu-2404
@@ -240,15 +300,22 @@ jobs:
300
matrix:
301
shard: [1, 2, 3, 4, 5, 6]
302
steps:
303
+ # Depth 2 brings the base commit the change is diffed against.
304
- name: Checkout
305
uses: actions/checkout@v6
306
with:
307
+ fetch-depth: 2
308
sparse-checkout: |
309
/*
310
!/.repos/
311
sparse-checkout-cone-mode: false
312
313
+ - name: Detect affected jobs
314
+ id: changes
315
+ uses: ./.github/actions/ci-changes
316
+
317
- name: Setup Vite+
318
+ if: steps.changes.outputs.test_server != 'false'
319
uses: voidzero-dev/setup-vp@v1
320
with:
321
node-version-file: package.json
@@ -259,9 +326,11 @@ jobs:
326
# and none of its tests touch the runtime. Only the non-server `test`
327
# job, which covers @t3tools/desktop, needs the download.
328
- name: Install Chromium for server browser integration tests
329
+ if: steps.changes.outputs.test_server != 'false'
330
run: node apps/server/node_modules/playwright-core/cli.js install --with-deps --only-shell chromium
331
332
- name: Test
333
+ if: steps.changes.outputs.test_server != 'false'
334
env:
335
T3CODE_TRANSFER_BUDGET_REPORT_PATH: ${{ runner.temp }}/t3code-transfer-budget.md
336
T3CODE_TRANSFER_BUDGET_RESULT_PATH: ${{ runner.temp }}/thread-transfer-result.json
@@ -301,7 +370,8 @@ jobs:
370
371
transfer-report:
372
name: Transfer report artifact
304
- needs: test_server
373
+ needs: [changes, test_server]
374
+ if: needs.changes.outputs.test_server != 'false'
375
# On Blacksmith like every other job here: the GitHub-hosted queue is shared
376
# with the PR bots and can leave this job waiting until it is abandoned,
377
# which fails `Check` on an otherwise green run.
@@ -318,6 +388,8 @@ jobs:
388
# for checks that take under 3s, on the critical path of every PR.
389
rust:
390
name: Rust
391
+ needs: changes
392
+ if: ${{ !cancelled() && needs.changes.outputs.rust != 'false' }}
393
runs-on: blacksmith-4vcpu-ubuntu-2404
394
timeout-minutes: 10
395
steps:
@@ -346,90 +418,10 @@ jobs:
418
cargo test --locked --manifest-path "native/$crate/Cargo.toml"
419
done
420
349
- # The static analysis below needs a macOS runner, which bills ~6.7x a Linux
350
- # minute, so gate it on the native sources it actually lints instead of paying
351
- # for it on every push. Detection is API-only (no checkout) and fails open: if
352
- # the diff cannot be resolved, the lint runs.
353
- mobile_native_changes:
354
- name: Mobile Native Changes
355
- runs-on: blacksmith-2vcpu-ubuntu-2404
356
- timeout-minutes: 5
357
- permissions:
358
- contents: read
359
- pull-requests: read
360
- outputs:
361
- changed: ${{ steps.detect.outputs.changed }}
362
- steps:
363
- - name: Detect mobile native changes
364
- id: detect
365
- env:
366
- GH_TOKEN: ${{ github.token }}
367
- PR_NUMBER: ${{ github.event.pull_request.number }}
368
- BEFORE_SHA: ${{ github.event.before }}
369
- run: |
370
- set -uo pipefail
371
-
372
- fail_open() {
373
- echo "$* Running native static analysis."
374
- echo "changed=true" >> "$GITHUB_OUTPUT"
375
- exit 0
376
- }
377
-
378
- count_rows() {
379
- printf '%s\n' "$1" | grep -c . || true
380
- }
381
-
382
- # One row per changed file, holding the new path and, for a rename,
383
- # the path it replaced: renaming a matched file out of the matched
384
- # paths removes a lint input just like editing it.
385
- row='[.filename, (.previous_filename // empty)] | @tsv'
386
-
387
- if [[ -n "${PR_NUMBER}" ]]; then
388
- # The PR files endpoint stops at 3000 files and pagination cannot
389
- # extend it, so cross-check against the count the PR itself reports.
390
- expected=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" --jq '.changed_files') \
391
- || fail_open "Could not read the pull request."
392
- rows=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/files" --paginate --jq ".[] | ${row}") \
393
- || fail_open "Could not resolve changed files."
394
-
395
- listed=$(count_rows "$rows")
396
- if [[ "$listed" -lt "$expected" ]]; then
397
- fail_open "GitHub listed only ${listed} of ${expected} changed files."
398
- fi
399
- else
400
- rows=$(gh api "repos/${GITHUB_REPOSITORY}/compare/${BEFORE_SHA}...${GITHUB_SHA}" --jq ".files[]? | ${row}") \
401
- || fail_open "Could not resolve changed files."
402
-
403
- # The compare endpoint reports at most 300 files and pagination does
404
- # not extend that list, so a full list may be hiding native changes.
405
- listed=$(count_rows "$rows")
406
- if [[ "$listed" -ge 300 ]]; then
407
- fail_open "GitHub listed ${listed} changed files, the compare endpoint maximum."
408
- fi
409
- fi
410
-
411
- paths=$(tr '\t' '\n' <<< "$rows")
412
-
413
- # Sources scripts/mobile-native-static-check.ts lints, plus the tool
414
- # and rule configuration that decides how it lints them, plus the
415
- # root package.json that defines the lint:mobile command.
416
- 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$'
417
-
418
- if grep -qE "$pattern" <<< "$paths"; then
419
- echo "Native sources or lint configuration changed:"
420
- grep -E "$pattern" <<< "$paths"
421
- echo "changed=true" >> "$GITHUB_OUTPUT"
422
- else
423
- echo "No mobile native sources or lint configuration changed."
424
- echo "changed=false" >> "$GITHUB_OUTPUT"
425
- fi
426
-
421
mobile_native_static_analysis:
422
name: Mobile Native Static Analysis
429
- needs: mobile_native_changes
430
- # Skip only on an explicit "no": a gate job that failed or errored leaves the
431
- # output empty, and that must run the lint rather than silently skip it.
432
- if: ${{ !cancelled() && needs.mobile_native_changes.outputs.changed != 'false' }}
423
+ needs: changes
424
+ if: ${{ !cancelled() && needs.changes.outputs.mobile_native != 'false' }}
425
runs-on: blacksmith-6vcpu-macos-26
426
timeout-minutes: 10
427
steps:
@@ -458,6 +450,8 @@ jobs:
450
451
release_smoke:
452
name: Release Smoke
453
+ needs: changes
454
+ if: ${{ !cancelled() && needs.changes.outputs.release_smoke != 'false' }}
455
runs-on: blacksmith-8vcpu-ubuntu-2404
456
timeout-minutes: 10
457
steps:
@@ -491,6 +485,7 @@ jobs:
485
if: ${{ always() }}
486
needs:
487
[
488
+ changes,
489
lint,
490
typecheck,
491
build,
@@ -499,7 +494,6 @@ jobs:
494
test_server,
495
transfer-report,
496
rust,
502
- mobile_native_changes,
497
mobile_native_static_analysis,
498
release_smoke,
499
]
@@ -511,7 +505,10 @@ jobs:
505
RESULTS: ${{ toJSON(needs) }}
506
run: |
507
echo "$RESULTS" | jq -r 'to_entries[] | "\(.key): \(.value.result)"'
514
- # Only the macOS lint skips on purpose, when no native mobile code changed.
515
- echo "$RESULTS" | jq -e 'all(to_entries[];
516
- .value.result == "success"
517
- or (.key == "mobile_native_static_analysis" and .value.result == "skipped"))' > /dev/null
508
+ # A job may skip only when `changes` said it was not needed. Gates are
509
+ # keyed by job name, except the macOS lint and the transfer report.
510
+ echo "$RESULTS" | jq -e '.changes.outputs as $gates
511
+ | {mobile_native_static_analysis: "mobile_native", "transfer-report": "test_server"} as $renamed
512
+ | all(to_entries[];
513
+ .value.result == "success"
514
+ or (.value.result == "skipped" and $gates[$renamed[.key] // .key] == "false"))' > /dev/null