Skip to content

Commit f9ce9ab

Browse files
committed
chore(gates): enforce iOS XCTest impact selection coverage
1 parent fe59d38 commit f9ce9ab

4 files changed

Lines changed: 59 additions & 3 deletions

File tree

‎docs/agents/testing.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ provider, and coverage tests mock the typed HDC seam. Real validation is local h
4545
Apple runner changes run `pnpm check:xctest-selection` and build the affected target. The source
4646
`#if` guard is the XCTest lane classification — never maintain a second test-name list. Pure runner
4747
decisions use the macOS host lane; iOS/XCTest semantics need a simulator lane.
48+
The iOS PR lane runs its XCTest list for native inputs or uncertain diffs; main and nightly remain broad.
4849

4950
Local host-lane XCTest may need signing and automation permission:
5051

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
import { expect, test } from 'vitest';
4+
import {
5+
affectsIosXctests,
6+
selectIosXctests,
7+
uncoveredRunnerCacheInputs,
8+
} from '../ios-xctest-impact.ts';
9+
10+
test('every runner build-cache input triggers the PR XCTest lane', () => {
11+
const action = fs.readFileSync(
12+
path.resolve('.github/actions/setup-apple-runner-build/action.yml'),
13+
'utf8',
14+
);
15+
expect(uncoveredRunnerCacheInputs(action)).toEqual([]);
16+
expect(
17+
uncoveredRunnerCacheInputs(action.replace('apple/runner/**', 'new-native-input/**')),
18+
).toEqual(['new-native-input/**']);
19+
});
20+
21+
test('the PR workflow applies the impact decision to the XCTest step', () => {
22+
const workflow = fs.readFileSync(path.resolve('.github/workflows/ios.yml'), 'utf8');
23+
expect(workflow).toContain('node --experimental-strip-types scripts/ios-xctest-impact.ts');
24+
expect(workflow).toMatch(
25+
/- name: Run targeted iOS runner XCTest regressions\n\s+if: steps\.xctest-impact\.outputs\.run == 'true'/,
26+
);
27+
});
28+
29+
test('native runner and golden-table changes run XCTest; TypeScript runtime changes use live E2E', () => {
30+
for (const file of [
31+
'apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift',
32+
'apple/snapshot-presentation/Sources/Presenter.swift',
33+
'contracts/fixtures/scroll-gesture.json',
34+
'.github/workflows/ios.yml',
35+
'scripts/ios-xctest-impact.ts',
36+
]) {
37+
expect(affectsIosXctests(file), file).toBe(true);
38+
}
39+
for (const file of [
40+
'packages/platform-apple/src/snapshot-source/cache.ts',
41+
'apple/fold-helper/fold-helper.c',
42+
'test/integration/ios-simulator-e2e/live-runner.ts',
43+
]) {
44+
expect(selectIosXctests('pull_request', [file]), file).toMatchObject({ run: false });
45+
}
46+
});
47+
48+
test('pushes and uncertain diffs keep the full XCTest selection', () => {
49+
expect(selectIosXctests('push', ['src/index.ts']).run).toBe(true);
50+
expect(selectIosXctests('pull_request', null).run).toBe(true);
51+
expect(selectIosXctests('pull_request', []).run).toBe(true);
52+
expect(selectIosXctests('pull_request', ['src/index.ts', 'package.json']).run).toBe(true);
53+
});

‎scripts/check-xctest-selection.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
// - host macos.yml, macOS host, every PR: the whole bundle as compiled for macOS, minus
99
// `-skip-testing:` — the pure runner-decision tests, whose guard is
1010
// `#if AGENT_DEVICE_RUNNER_UNIT_TESTS` alone.
11-
// - pr ios.yml, iOS Simulator, every PR: the hand-written `-only-testing:` list.
11+
// - pr ios.yml, iOS Simulator, when runner inputs change on a PR (and on every main
12+
// push): the hand-written `-only-testing:` list.
1213
// - nightly xctest-nightly.yml, iOS Simulator, scheduled: the whole bundle as compiled for
1314
// iOS, minus `-skip-testing:` — includes the simulator-only tests, whose guard is
1415
// `… && os(iOS)` (they launch the host app, route through SpringBoard, or assert an
@@ -51,7 +52,7 @@ const packageAppleRunnerScript = path.join(repoRoot, 'scripts/package-apple-runn
5152
/** The macOS host lane, which runs the whole macOS-compiled bundle on every PR. */
5253
export const HOST_WORKFLOW_FILE = '.github/workflows/macos.yml';
5354

54-
/** The PR lane, whose `-only-testing:` list decides what every pull request runs on the simulator. */
55+
/** The PR lane, whose `-only-testing:` list decides what selected pull requests run on the simulator. */
5556
export const PR_WORKFLOW_FILE = '.github/workflows/ios.yml';
5657

5758
/** The nightly lane, whose `-skip-testing:` list decides what the full simulator suite leaves out. */
@@ -349,7 +350,7 @@ export function formatSummary(report: SelectionReport): string {
349350
return (
350351
`xctest selection: ${declared} declared ${report.target} methods — host lane ` +
351352
`(${HOST_WORKFLOW_FILE}, macOS, every PR) reaches ${host}, PR list (${PR_WORKFLOW_FILE}, ` +
352-
`iOS Simulator, every PR) selects ${pr}, nightly (${NIGHTLY_WORKFLOW_FILE}, iOS Simulator) ` +
353+
`iOS Simulator, selected PRs and main) selects ${pr}, nightly (${NIGHTLY_WORKFLOW_FILE}, iOS Simulator) ` +
353354
`reaches ${nightly}; ${dark} reachable by no lane; ${ENTRY_POINT_METHOD} skipped everywhere.\n`
354355
);
355356
}

‎vitest.config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export default defineConfig({
128128
// Parses ios.yml and the runner's Swift sources: no Xcode, no simulator, and
129129
// the check it guards is what keeps the PR lane's `-only-testing:` list honest.
130130
'scripts/__tests__/xctest-selection.test.ts',
131+
'scripts/__tests__/ios-xctest-impact.test.ts',
131132
// The nightly XCTest lane's reporter/liveness check, which otherwise only ever
132133
// executes on a macOS runner at 04:30.
133134
'scripts/__tests__/xctest-run-summary.test.ts',

0 commit comments

Comments
 (0)