Skip to content

Commit 76dbee0

Browse files
authored
perf(ci): reuse iOS runner and narrow native cache key (#2952)
* perf(ci): reuse iOS runner and narrow native cache key * fix(ci): patch cached runner after native restore
1 parent 0414e12 commit 76dbee0

5 files changed

Lines changed: 38 additions & 9 deletions

File tree

‎.github/actions/setup-apple-runner-build/action.yml‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ runs:
4444
id: source-hash
4545
run: |
4646
set -euo pipefail
47-
echo "value=${{ hashFiles('apple/runner/**', 'apple/snapshot-presentation/**', 'scripts/build-xcuitest-apple.sh', 'scripts/swift-toolchain-tmpdir.ts', 'scripts/patch-xcuitest-runner-icon.ts', 'scripts/write-xcuitest-cache-metadata.mjs', 'packages/platform-apple/src/runner/**', '!packages/platform-apple/src/runner/__tests__/**', '.github/actions/setup-apple-runner-build/action.yml') }}" >> "$GITHUB_OUTPUT"
47+
echo "value=${{ hashFiles('apple/runner/**', 'apple/snapshot-presentation/**', 'scripts/build-xcuitest-apple.sh', 'scripts/swift-toolchain-tmpdir.ts', 'scripts/write-xcuitest-cache-metadata.mjs', '.github/actions/setup-apple-runner-build/action.yml') }}" >> "$GITHUB_OUTPUT"
4848
shell: bash
4949

5050
- name: Resolve Apple runner build variant
@@ -90,6 +90,7 @@ runs:
9090
AGENT_DEVICE_IOS_RUNNER_DERIVED_PATH: ${{ inputs.derived-path }}
9191
AGENT_DEVICE_XCUITEST_PLATFORM: ${{ inputs.xcuitest-platform }}
9292
AGENT_DEVICE_XCUITEST_DESTINATION: ${{ inputs.xcuitest-destination }}
93+
AGENT_DEVICE_XCUITEST_SKIP_ICON_PATCH: '1'
9394

9495
- name: Save Apple runner build cache
9596
if: steps.restore-runner-build.outputs.cache-hit != 'true'
@@ -98,6 +99,10 @@ runs:
9899
path: ${{ inputs.derived-path }}
99100
key: ${{ steps.restore-runner-build.outputs.cache-primary-key }}
100101

102+
- name: Patch XCTest runner icon
103+
shell: bash
104+
run: node --experimental-strip-types scripts/patch-xcuitest-runner-icon.ts "${{ inputs.derived-path }}"
105+
101106
- name: Report Apple runner build cache
102107
env:
103108
CACHE_HIT: ${{ steps.restore-runner-build.outputs.cache-hit }}
@@ -106,9 +111,9 @@ runs:
106111
run: |
107112
set -euo pipefail
108113
if [ "$CACHE_HIT" = 'true' ]; then
109-
RESULT='restored exact prebuilt runner; compilation skipped'
114+
RESULT='restored native build; compilation skipped; icon patch applied'
110115
else
111-
RESULT='cache miss; built runner and attempted cache save'
116+
RESULT='cache miss; built and cached native runner; icon patch applied'
112117
fi
113118
{
114119
printf '### Apple runner cache (%s)\n\n' "$BUILD_GATE"

‎.github/workflows/ios.yml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ jobs:
191191
- name: Run gesture pan-duration smoke replay
192192
run: |
193193
xcrun simctl install "${{ steps.ios-simulator.outputs.simulator-udid }}" "${{ steps.fixture-app.outputs.app-path }}"
194-
pnpm clean:daemon
195194
node --experimental-strip-types src/bin.ts test examples/test-app/replays/gesture-pan-duration.ad --udid "${{ steps.ios-simulator.outputs.simulator-udid }}" --timeout 180000 --retries 2 --artifacts-dir test/artifacts/replays-ios-gesture-pan-duration --report-junit test/artifacts/replays-ios-gesture-pan-duration.junit.xml
196195
pnpm clean:daemon
197196

‎.github/workflows/replays-manual.yml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ jobs:
128128
run: |
129129
pnpm clean:daemon
130130
node --experimental-strip-types src/bin.ts prepare ios-runner --platform ios --udid "${{ steps.ios-simulator.outputs.simulator-udid }}" --timeout "$AGENT_DEVICE_IOS_PREPARE_TIMEOUT_MS" --json
131-
pnpm clean:daemon
132131
133132
- name: Run iOS simulator replay suite
134133
uses: ./.github/actions/run-gate

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

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,12 @@ function workflowStepIndex(workflow: string, matches: (step: WorkflowStep) => bo
3434
.findIndex(matches);
3535
}
3636

37-
test('every runner build-cache input triggers the PR XCTest lane', () => {
37+
test('native runner build-cache inputs trigger the PR XCTest lane', () => {
3838
const action = fs.readFileSync(
3939
path.join(repoRoot, '.github/actions/setup-apple-runner-build/action.yml'),
4040
'utf8',
4141
);
42-
expect(cacheInputs(action)).toContain('packages/platform-apple/src/runner/**');
43-
expect(cacheInputs(action)).toContain('!packages/platform-apple/src/runner/__tests__/**');
42+
expect(cacheInputs(action).filter((input) => input.startsWith('packages/'))).toEqual([]);
4443
const uncovered = (text: string) =>
4544
cacheInputs(text)
4645
.filter((input) => !input.startsWith('!'))
@@ -63,6 +62,31 @@ test('every runner build-cache input triggers the PR XCTest lane', () => {
6362
).toEqual(['packages/platform-apple/src/foldable/**']);
6463
});
6564

65+
test('the cache stores native products before applying the current runner icon patch', () => {
66+
const action = fs.readFileSync(
67+
path.join(repoRoot, '.github/actions/setup-apple-runner-build/action.yml'),
68+
'utf8',
69+
);
70+
const doc = parse(action) as {
71+
runs: {
72+
steps: Array<{ name?: string; env?: Record<string, string>; if?: string; run?: string }>;
73+
};
74+
};
75+
const steps = doc.runs.steps;
76+
const build = steps.find((step) => step.name === 'Build Apple runner artifacts on cache miss');
77+
const saveIndex = steps.findIndex((step) => step.name === 'Save Apple runner build cache');
78+
const patchIndex = steps.findIndex((step) => step.name === 'Patch XCTest runner icon');
79+
expect(build?.env?.AGENT_DEVICE_XCUITEST_SKIP_ICON_PATCH).toBe('1');
80+
expect(saveIndex).toBeGreaterThan(-1);
81+
expect(patchIndex).toBeGreaterThan(saveIndex);
82+
expect(steps[patchIndex]?.if).toBeUndefined();
83+
expect(steps[patchIndex]?.run).toContain('scripts/patch-xcuitest-runner-icon.ts');
84+
expect(cacheInputs(action)).not.toContain('scripts/patch-xcuitest-runner-icon.ts');
85+
expect(fs.readFileSync(path.join(repoRoot, 'scripts/build-xcuitest-apple.sh'), 'utf8')).toContain(
86+
'if ! is_truthy "${AGENT_DEVICE_XCUITEST_SKIP_ICON_PATCH:-}"; then',
87+
);
88+
});
89+
6690
test('the PR workflow applies the impact decision to the XCTest step', () => {
6791
const workflow = fs.readFileSync(path.join(repoRoot, '.github/workflows/ios.yml'), 'utf8');
6892
expect(workflow).toContain('node --experimental-strip-types scripts/apple-ci-impact.ts xctest');

‎scripts/build-xcuitest-apple.sh‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,5 +165,7 @@ node --experimental-strip-types scripts/swift-toolchain-tmpdir.ts xcodebuild bui
165165
$ARCH_BUILD_SETTINGS \
166166
$SIGNING_BUILD_SETTINGS
167167

168-
node --experimental-strip-types scripts/patch-xcuitest-runner-icon.ts "$DERIVED_PATH"
168+
if ! is_truthy "${AGENT_DEVICE_XCUITEST_SKIP_ICON_PATCH:-}"; then
169+
node --experimental-strip-types scripts/patch-xcuitest-runner-icon.ts "$DERIVED_PATH"
170+
fi
169171
node scripts/write-xcuitest-cache-metadata.mjs "$PLATFORM" "$DERIVED_PATH" "$DESTINATION"

0 commit comments

Comments
 (0)