Skip to content

Commit d0c85f9

Browse files
thymikeeclaude
andcommitted
ci: skip device smoke lanes when a PR changes no lane input
Android, Linux, macOS, and web smoke now use the affected-check model the iOS smoke already used. Unit tests own no device lane, so a test-only PR skips every device lane. Pushes to main and uncertain diffs still run all. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent e3ed027 commit d0c85f9

9 files changed

Lines changed: 357 additions & 88 deletions

File tree

‎.github/workflows/android.yml‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,27 @@ jobs:
4141
- name: Setup toolchain
4242
uses: ./.github/actions/setup-node-pnpm
4343

44+
- name: Fetch the PR base for Android smoke selection
45+
if: github.event_name == 'pull_request'
46+
env:
47+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
48+
run: git fetch origin "$BASE_SHA" --depth=1 || echo "Base fetch failed; Android smoke selection will fail open."
49+
50+
- name: Select Android smoke tests
51+
id: impact
52+
env:
53+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
54+
run: node --experimental-strip-types scripts/device-lane-impact.ts replay-android android-helpers
55+
4456
- name: Setup Android replay host
57+
if: steps.impact.outputs.run != 'false'
4558
id: android-replay-host
4659
uses: ./.github/actions/setup-android-replay-host
4760
with:
4861
package-helpers: 'true'
4962

5063
- name: Restore fixture APK
64+
if: steps.impact.outputs.run != 'false'
5165
id: fixture-app
5266
uses: ./.github/actions/setup-fixture-app
5367
with:
@@ -56,12 +70,15 @@ jobs:
5670
wait-for-artifact-seconds: '1800'
5771

5872
- name: Report fixture cache source
73+
if: steps.impact.outputs.run != 'false'
5974
run: echo "Android fixture APK source=${{ steps.fixture-app.outputs.source }}"
6075

6176
- name: Run Android emulator catalog coverage contract
77+
if: steps.impact.outputs.run != 'false'
6278
run: node --experimental-strip-types scripts/node-test-tmpdir.ts --test test/integration/smoke-android-emulator-coverage.test.ts
6379

6480
- name: Run Android smoke checks
81+
if: steps.impact.outputs.run != 'false'
6582
uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b # v2.35.0
6683
with:
6784
api-level: 36
@@ -79,7 +96,7 @@ jobs:
7996
node --experimental-strip-types src/bin.ts test test/integration/replays/android/emulator/01-settings.ad --retries 2 --report-junit test/artifacts/replays-android-smoke.junit.xml
8097
8198
- name: Upload Android artifacts
82-
if: always()
99+
if: always() && steps.impact.outputs.run != 'false'
83100
uses: ./.github/actions/upload-agent-device-artifacts
84101
with:
85102
artifact-name: android-artifacts

‎.github/workflows/apple.yml‎

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,20 @@ jobs:
5656
shell: bash
5757
run: |
5858
git fetch origin "$BASE_SHA" --depth=1 || echo "Base fetch failed; Apple selection will fail open."
59+
- name: Select iOS smoke tests
60+
id: ios-impact
61+
shell: bash
62+
run: node --experimental-strip-types scripts/apple-ci-impact.ts smoke
63+
- name: Select macOS smoke tests
64+
id: macos-impact
65+
shell: bash
66+
run: node --experimental-strip-types scripts/apple-ci-impact.ts macos
5967
- name: Build the shared CLI
6068
id: build
69+
if: steps.ios-impact.outputs.run != 'false' || steps.macos-impact.outputs.run != 'false'
6170
uses: ./.github/actions/run-gate
6271
with:
6372
gate: build
64-
- name: Select iOS smoke tests
65-
id: ios-impact
66-
shell: bash
67-
run: node --experimental-strip-types scripts/apple-ci-impact.ts smoke
6873
# The macOS clean-install proof may raise permission UI. Run the iOS focus proof first.
6974
- name: iOS smoke tests
7075
id: ios
@@ -101,7 +106,7 @@ jobs:
101106
RESULT_BUNDLE_PATH: ${{ github.workspace }}/.tmp/xctest-host/RunnerTests.xcresult
102107
RESULT_SUMMARY_PATH: ${{ github.workspace }}/.tmp/xctest-host/test-results-summary.json
103108
XCTEST_LANE: host
104-
if: ${{ !cancelled() && steps.build.outcome == 'success' && steps.ios-cleanup.outcome == 'success' }}
109+
if: ${{ !cancelled() && steps.build.outcome == 'success' && steps.ios-cleanup.outcome == 'success' && steps.macos-impact.outputs.run != 'false' }}
105110
- name: Diagnose the Apple host after a phase failure
106111
if: ${{ always() && (steps.ios.outcome == 'failure' || steps.macos.outcome == 'failure' || steps.ios-cleanup.outcome == 'failure') }}
107112
continue-on-error: true
@@ -119,11 +124,12 @@ jobs:
119124
shell: bash
120125
run: |
121126
pnpm clean:daemon
122-
- name: Require both Apple phases to succeed
127+
- name: Require the selected Apple phases to succeed
123128
if: always()
124129
env:
125130
IOS_SELECTED: ${{ steps.ios-impact.outputs.run }}
126131
IOS_OUTCOME: ${{ steps.ios.outcome }}
132+
MACOS_SELECTED: ${{ steps.macos-impact.outputs.run }}
127133
MACOS_OUTCOME: ${{ steps.macos.outcome }}
128134
IOS_CLEANUP_OUTCOME: ${{ steps.ios-cleanup.outcome }}
129135
MACOS_CLEANUP_OUTCOME: ${{ steps.macos-cleanup.outcome }}
@@ -136,9 +142,18 @@ jobs:
136142
else
137143
test "$IOS_OUTCOME" = success
138144
fi
139-
test "$MACOS_OUTCOME" = success
140-
test "$IOS_CLEANUP_OUTCOME" = success
141-
test "$MACOS_CLEANUP_OUTCOME" = success
145+
if [ "$MACOS_SELECTED" = false ]; then
146+
test "$MACOS_OUTCOME" = skipped
147+
else
148+
test "$MACOS_OUTCOME" = success
149+
fi
150+
if [ "$IOS_SELECTED" = false ] && [ "$MACOS_SELECTED" = false ]; then
151+
test "$IOS_CLEANUP_OUTCOME" = skipped
152+
test "$MACOS_CLEANUP_OUTCOME" = skipped
153+
else
154+
test "$IOS_CLEANUP_OUTCOME" = success
155+
test "$MACOS_CLEANUP_OUTCOME" = success
156+
fi
142157
- name: Upload Apple artifacts
143158
if: always()
144159
uses: ./.github/actions/upload-agent-device-artifacts

‎.github/workflows/ci.yml‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,21 +395,35 @@ jobs:
395395
uses: ./.github/actions/run-gate
396396
with: { gate: fixture-cache }
397397

398+
- name: Fetch the PR base for web smoke selection
399+
if: github.event_name == 'pull_request'
400+
env:
401+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
402+
run: git fetch origin "$BASE_SHA" --depth=1 || echo "Base fetch failed; web smoke selection will fail open."
403+
404+
- name: Select web smoke tests
405+
id: web-impact
406+
env:
407+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
408+
run: node --experimental-strip-types scripts/device-lane-impact.ts web-smoke
409+
398410
# Shares this job's ubuntu toolchain. AGENT_DEVICE_WEB_E2E is step-scoped
399411
# so it cannot leak into the node/provider suites above.
400412
- name: Run live web smoke
413+
if: steps.web-impact.outputs.run != 'false'
401414
env:
402415
AGENT_DEVICE_WEB_E2E: '1'
403416
run: pnpm clean:daemon
404417

405418
- name: Execute live web smoke
419+
if: steps.web-impact.outputs.run != 'false'
406420
env:
407421
AGENT_DEVICE_WEB_E2E: '1'
408422
uses: ./.github/actions/run-gate
409423
with: { gate: web-smoke }
410424

411425
- name: Upload web smoke artifacts
412-
if: always()
426+
if: always() && steps.web-impact.outputs.run != 'false'
413427
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
414428
with:
415429
name: web-smoke-artifacts

‎.github/workflows/linux.yml‎

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@ jobs:
4646
- name: Checkout
4747
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4848

49+
- name: Setup toolchain
50+
uses: ./.github/actions/setup-node-pnpm
51+
52+
- name: Fetch the PR base for Linux smoke selection
53+
if: github.event_name == 'pull_request'
54+
env:
55+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
56+
run: git fetch origin "$BASE_SHA" --depth=1 || echo "Base fetch failed; Linux smoke selection will fail open."
57+
58+
- name: Select Linux smoke tests
59+
id: impact
60+
env:
61+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
62+
run: node --experimental-strip-types scripts/device-lane-impact.ts replay-linux linux-command-evidence
63+
4964
# Unbounded, this step could not fail — it could only stall. On 2026-08-19 a slow mirror
5065
# held apt past the job's 30-minute budget on four main-branch runs and several unrelated
5166
# PRs, which reported as a red check on branches that never ran a line of project code.
@@ -54,6 +69,7 @@ jobs:
5469
# that drips bytes slowly enough to defeat the socket timeout. A healthy install takes
5570
# about a minute, so six is generous.
5671
- name: Install Linux desktop dependencies
72+
if: steps.impact.outputs.run != 'false'
5773
timeout-minutes: 6
5874
run: |
5975
set -euo pipefail
@@ -77,10 +93,8 @@ jobs:
7793
gnome-calculator \
7894
wmctrl
7995
80-
- name: Setup toolchain
81-
uses: ./.github/actions/setup-node-pnpm
82-
8396
- name: Start Xvfb and D-Bus
97+
if: steps.impact.outputs.run != 'false'
8498
run: |
8599
# Start virtual framebuffer (1280x1024, 24-bit color)
86100
Xvfb :99 -screen 0 1280x1024x24 &
@@ -93,6 +107,7 @@ jobs:
93107
echo "DBUS_SESSION_BUS_PID=$DBUS_SESSION_BUS_PID" >> "$GITHUB_ENV"
94108
95109
- name: Start AT-SPI2 registry
110+
if: steps.impact.outputs.run != 'false'
96111
run: |
97112
# The registry must start AFTER DBUS_SESSION_BUS_ADDRESS is available
98113
# (it was written to GITHUB_ENV in the previous step).
@@ -112,6 +127,7 @@ jobs:
112127
fi
113128
114129
- name: Verify environment
130+
if: steps.impact.outputs.run != 'false'
115131
run: |
116132
echo "=== Display ==="
117133
xdotool getdisplaygeometry
@@ -125,9 +141,11 @@ jobs:
125141
xdotool version
126142
127143
- name: Run Linux replay smoke test
144+
if: steps.impact.outputs.run != 'false'
128145
run: pnpm clean:daemon
129146

130147
- name: Execute Linux replay smoke test
148+
if: steps.impact.outputs.run != 'false'
131149
uses: ./.github/actions/run-gate
132150
with:
133151
gate: replay-linux
@@ -138,15 +156,17 @@ jobs:
138156
test/artifacts/replays-linux.junit.xml
139157
140158
- name: Reset daemon before Linux command evidence
159+
if: steps.impact.outputs.run != 'false'
141160
run: pnpm clean:daemon
142161

143162
- name: Execute Linux command evidence
163+
if: steps.impact.outputs.run != 'false'
144164
uses: ./.github/actions/run-gate
145165
with:
146166
gate: linux-command-evidence
147167

148168
- name: Upload Linux artifacts
149-
if: always()
169+
if: always() && steps.impact.outputs.run != 'false'
150170
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
151171
with:
152172
name: linux-artifacts

‎scripts/__tests__/apple-ci-impact.test.ts‎

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ import path from 'node:path';
55
import { expect, test } from 'vitest';
66
import { parse } from 'yaml';
77
import { mkdtempForTestSync } from '@agent-device/test-kit';
8-
import { selectAppleBridgeProof, selectIosSmoke, selectIosXctests } from '../apple-ci-impact.ts';
8+
import {
9+
selectAppleBridgeProof,
10+
selectIosSmoke,
11+
selectIosXctests,
12+
selectMacosSmoke,
13+
} from '../apple-ci-impact.ts';
914
import { selectChecks } from '../check-affected/model.ts';
1015

1116
const repoRoot = path.resolve(import.meta.dirname, '../..');
@@ -226,12 +231,32 @@ test.each([
226231
['macOS silently skipped', { MACOS_OUTCOME: 'skipped' }, 1],
227232
['iOS cleanup fails', { IOS_CLEANUP_OUTCOME: 'failure' }, 1],
228233
['macOS cleanup fails', { MACOS_CLEANUP_OUTCOME: 'failure' }, 1],
234+
['macOS not selected', { MACOS_SELECTED: 'false', MACOS_OUTCOME: 'skipped' }, 0],
235+
['unselected macOS unexpectedly ran', { MACOS_SELECTED: 'false' }, 1],
236+
[
237+
'no phase selected',
238+
{
239+
IOS_SELECTED: 'false',
240+
IOS_OUTCOME: 'skipped',
241+
MACOS_SELECTED: 'false',
242+
MACOS_OUTCOME: 'skipped',
243+
IOS_CLEANUP_OUTCOME: 'skipped',
244+
MACOS_CLEANUP_OUTCOME: 'skipped',
245+
},
246+
0,
247+
],
248+
[
249+
'cleanup skipped while a phase ran',
250+
{ IOS_SELECTED: 'false', IOS_OUTCOME: 'skipped', MACOS_CLEANUP_OUTCOME: 'skipped' },
251+
1,
252+
],
229253
] as const)('the final Apple status guard preserves failure: %s', (_label, overrides, expected) => {
230254
const guard = appleJob().steps.find((step) => step.env?.IOS_OUTCOME)!;
231255
expect(guard.if).toBe('always()');
232256
expect(guard.env).toEqual({
233257
IOS_SELECTED: '${{ steps.ios-impact.outputs.run }}',
234258
IOS_OUTCOME: '${{ steps.ios.outcome }}',
259+
MACOS_SELECTED: '${{ steps.macos-impact.outputs.run }}',
235260
MACOS_OUTCOME: '${{ steps.macos.outcome }}',
236261
IOS_CLEANUP_OUTCOME: '${{ steps.ios-cleanup.outcome }}',
237262
MACOS_CLEANUP_OUTCOME: '${{ steps.macos-cleanup.outcome }}',
@@ -241,6 +266,7 @@ test.each([
241266
...process.env,
242267
IOS_SELECTED: 'true',
243268
IOS_OUTCOME: 'success',
269+
MACOS_SELECTED: 'true',
244270
MACOS_OUTCOME: 'success',
245271
IOS_CLEANUP_OUTCOME: 'success',
246272
MACOS_CLEANUP_OUTCOME: 'success',
@@ -280,6 +306,35 @@ test('iOS smoke uses affected-check ownership and fails open on uncertain diffs'
280306
expect(selectIosSmoke('push', ['src/foo.test.ts']).run).toBe(true);
281307
});
282308

309+
test('macOS smoke uses affected-check ownership and keeps the bridge proof inputs', () => {
310+
const steps = appleJob().steps;
311+
const select = steps.find((step) => step.id === 'macos-impact')!;
312+
const build = steps.find((step) => step.id === 'build')!;
313+
const macos = steps.find((step) => step.id === 'macos')!;
314+
expect(select.run).toContain('scripts/apple-ci-impact.ts macos');
315+
expect(steps.indexOf(select)).toBeLessThan(steps.indexOf(build));
316+
expect(build.if).toContain("steps.macos-impact.outputs.run != 'false'");
317+
expect(macos.if).toContain("steps.macos-impact.outputs.run != 'false'");
318+
for (const file of [
319+
'src/foo.test.ts',
320+
'packages/daemon/src/sessions/__tests__/session.test.ts',
321+
'packages/platform-android/src/index.ts',
322+
'test/integration/replays/ios/basic.ad',
323+
]) {
324+
expect(selectMacosSmoke('pull_request', [file]).run, file).toBe(false);
325+
}
326+
for (const file of [
327+
'packages/platform-apple/src/foldable/fold-helper-cache.test.ts',
328+
'packages/platform-apple/src/index.ts',
329+
'src/index.ts',
330+
'.github/actions/smoke-macos/action.yml',
331+
]) {
332+
expect(selectMacosSmoke('pull_request', [file]).run, file).toBe(true);
333+
}
334+
expect(selectMacosSmoke('pull_request', null).run).toBe(true);
335+
expect(selectMacosSmoke('push', ['src/foo.test.ts']).run).toBe(true);
336+
});
337+
283338
function cacheInputs(action: string, stepId = 'source-hash'): string[] {
284339
const doc = parse(action) as { runs?: { steps?: Array<{ id?: string; run?: string }> } };
285340
const hashStep = doc.runs?.steps?.find((step) => step.id === stepId)?.run ?? '';
@@ -542,7 +597,7 @@ test('a shallow PR merge still yields a known change set for all Apple selectors
542597
);
543598
expect(select('xctest')).toContain('skip;');
544599
expect(select('bridge')).toContain('skip;');
545-
expect(select('smoke')).toContain('run; iOS device-lane input changed: src/feature.ts');
600+
expect(select('smoke')).toContain('run; replay-ios input changed: src/feature.ts');
546601
} finally {
547602
fs.rmSync(root, { recursive: true, force: true });
548603
}

0 commit comments

Comments
 (0)