diff --git a/.github/actions/setup-apple-runner-build/action.yml b/.github/actions/setup-apple-runner-build/action.yml index c05ecd9326..f2aba5b093 100644 --- a/.github/actions/setup-apple-runner-build/action.yml +++ b/.github/actions/setup-apple-runner-build/action.yml @@ -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 @@ -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' @@ -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 }} @@ -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" diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index ae56f320ed..17e7c7ce0d 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -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 diff --git a/.github/workflows/replays-manual.yml b/.github/workflows/replays-manual.yml index acdc155376..d5e0d8ad2e 100644 --- a/.github/workflows/replays-manual.yml +++ b/.github/workflows/replays-manual.yml @@ -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 diff --git a/scripts/__tests__/apple-ci-impact.test.ts b/scripts/__tests__/apple-ci-impact.test.ts index 7fa5a1a86d..31b79a3d86 100644 --- a/scripts/__tests__/apple-ci-impact.test.ts +++ b/scripts/__tests__/apple-ci-impact.test.ts @@ -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('!')) @@ -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; 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'); diff --git a/scripts/build-xcuitest-apple.sh b/scripts/build-xcuitest-apple.sh index 6c0b5fd556..3142a98be8 100644 --- a/scripts/build-xcuitest-apple.sh +++ b/scripts/build-xcuitest-apple.sh @@ -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"