Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .github/actions/setup-apple-runner-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ runs:
id: source-hash
run: |
set -euo pipefail
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"
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"
shell: bash

- name: Resolve Apple runner build variant
Expand Down Expand Up @@ -90,6 +90,7 @@ runs:
AGENT_DEVICE_IOS_RUNNER_DERIVED_PATH: ${{ inputs.derived-path }}
AGENT_DEVICE_XCUITEST_PLATFORM: ${{ inputs.xcuitest-platform }}
AGENT_DEVICE_XCUITEST_DESTINATION: ${{ inputs.xcuitest-destination }}
AGENT_DEVICE_XCUITEST_SKIP_ICON_PATCH: '1'

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

- name: Patch XCTest runner icon
shell: bash
run: node --experimental-strip-types scripts/patch-xcuitest-runner-icon.ts "${{ inputs.derived-path }}"

- name: Report Apple runner build cache
env:
CACHE_HIT: ${{ steps.restore-runner-build.outputs.cache-hit }}
Expand All @@ -106,9 +111,9 @@ runs:
run: |
set -euo pipefail
if [ "$CACHE_HIT" = 'true' ]; then
RESULT='restored exact prebuilt runner; compilation skipped'
RESULT='restored native build; compilation skipped; icon patch applied'
else
RESULT='cache miss; built runner and attempted cache save'
RESULT='cache miss; built and cached native runner; icon patch applied'
fi
{
printf '### Apple runner cache (%s)\n\n' "$BUILD_GATE"
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ jobs:
- name: Run gesture pan-duration smoke replay
run: |
xcrun simctl install "${{ steps.ios-simulator.outputs.simulator-udid }}" "${{ steps.fixture-app.outputs.app-path }}"
pnpm clean:daemon
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
pnpm clean:daemon

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/replays-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ jobs:
run: |
pnpm clean:daemon
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
pnpm clean:daemon

- name: Run iOS simulator replay suite
uses: ./.github/actions/run-gate
Expand Down
30 changes: 27 additions & 3 deletions scripts/__tests__/apple-ci-impact.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ function workflowStepIndex(workflow: string, matches: (step: WorkflowStep) => bo
.findIndex(matches);
}

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

test('the cache stores native products before applying the current runner icon patch', () => {
const action = fs.readFileSync(
path.join(repoRoot, '.github/actions/setup-apple-runner-build/action.yml'),
'utf8',
);
const doc = parse(action) as {
runs: {
steps: Array<{ name?: string; env?: Record<string, string>; if?: string; run?: string }>;
};
};
const steps = doc.runs.steps;
const build = steps.find((step) => step.name === 'Build Apple runner artifacts on cache miss');
const saveIndex = steps.findIndex((step) => step.name === 'Save Apple runner build cache');
const patchIndex = steps.findIndex((step) => step.name === 'Patch XCTest runner icon');
expect(build?.env?.AGENT_DEVICE_XCUITEST_SKIP_ICON_PATCH).toBe('1');
expect(saveIndex).toBeGreaterThan(-1);
expect(patchIndex).toBeGreaterThan(saveIndex);
expect(steps[patchIndex]?.if).toBeUndefined();
expect(steps[patchIndex]?.run).toContain('scripts/patch-xcuitest-runner-icon.ts');
expect(cacheInputs(action)).not.toContain('scripts/patch-xcuitest-runner-icon.ts');
expect(fs.readFileSync(path.join(repoRoot, 'scripts/build-xcuitest-apple.sh'), 'utf8')).toContain(
'if ! is_truthy "${AGENT_DEVICE_XCUITEST_SKIP_ICON_PATCH:-}"; then',
);
});

test('the PR workflow applies the impact decision to the XCTest step', () => {
const workflow = fs.readFileSync(path.join(repoRoot, '.github/workflows/ios.yml'), 'utf8');
expect(workflow).toContain('node --experimental-strip-types scripts/apple-ci-impact.ts xctest');
Expand Down
4 changes: 3 additions & 1 deletion scripts/build-xcuitest-apple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,7 @@ node --experimental-strip-types scripts/swift-toolchain-tmpdir.ts xcodebuild bui
$ARCH_BUILD_SETTINGS \
$SIGNING_BUILD_SETTINGS

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