Skip to content

Commit 47c6008

Browse files
committed
fix(ci): patch cached runner after native restore
1 parent 8e70f7c commit 47c6008

3 files changed

Lines changed: 36 additions & 4 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', '.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"

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,31 @@ test('native runner build-cache inputs trigger the PR XCTest lane', () => {
6262
).toEqual(['packages/platform-apple/src/foldable/**']);
6363
});
6464

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+
6590
test('the PR workflow applies the impact decision to the XCTest step', () => {
6691
const workflow = fs.readFileSync(path.join(repoRoot, '.github/workflows/ios.yml'), 'utf8');
6792
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)