Repository navigation
fix(android): end close once the pre-close processes are gone #4067
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Apple | |
| on: | |
| pull_request: | |
| types: | |
| - opened | |
| - synchronize | |
| - reopened | |
| - ready_for_review | |
| - converted_to_draft | |
| paths-ignore: | |
| - docs/** | |
| - website/** | |
| - README.md | |
| - AGENTS.md | |
| - CONTEXT.md | |
| - CONTRIBUTING.md | |
| - LICENSE | |
| - SECURITY.md | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| actions: read | |
| concurrency: | |
| group: ci-${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| smoke-apple-platform: | |
| name: Smoke Tests (${{ matrix.platform }}) | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: [ios, macos] | |
| if: ${{ !github.event.pull_request.draft }} | |
| runs-on: blacksmith-6vcpu-macos-26 | |
| timeout-minutes: 90 | |
| env: | |
| BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
| IOS_RUNTIME_VERSION: '26.2' | |
| IOS_STATE_DIR: ${{ github.workspace }}/.tmp/ios-agent-device-state | |
| MACOS_STATE_DIR: ${{ github.workspace }}/.tmp/macos-agent-device-state | |
| IOS_DERIVED_PATH: ${{ github.workspace }}/.tmp/ios-runner-derived | |
| MACOS_DERIVED_PATH: ${{ github.workspace }}/.tmp/macos-runner-derived | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| - name: Setup toolchain | |
| uses: ./.github/actions/setup-node-pnpm | |
| with: | |
| cache-dependency-path: | | |
| pnpm-lock.yaml | |
| examples/test-app/pnpm-lock.yaml | |
| - name: Fetch the PR base for Apple selectors | |
| if: github.event_name == 'pull_request' | |
| shell: bash | |
| run: | | |
| git fetch origin "$BASE_SHA" --depth=1 || echo "Base fetch failed; Apple selection will fail open." | |
| - name: Select iOS smoke tests | |
| id: ios-impact | |
| shell: bash | |
| env: | |
| APPLE_PLATFORM: ${{ matrix.platform }} | |
| run: | | |
| if [ "$APPLE_PLATFORM" = ios ]; then | |
| node --experimental-strip-types scripts/apple-ci-impact.ts smoke | |
| else | |
| echo "run=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Select macOS smoke tests | |
| id: macos-impact | |
| shell: bash | |
| env: | |
| APPLE_PLATFORM: ${{ matrix.platform }} | |
| run: | | |
| if [ "$APPLE_PLATFORM" = macos ]; then | |
| node --experimental-strip-types scripts/apple-ci-impact.ts macos | |
| else | |
| echo "run=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Build the shared CLI | |
| id: build | |
| if: steps.ios-impact.outputs.run != 'false' || steps.macos-impact.outputs.run != 'false' | |
| uses: ./.github/actions/run-gate | |
| with: | |
| gate: build | |
| # The canary records the frontmost app before anything can take focus. It stays ahead of the | |
| # group because one of its members starts the simulator boot, which can raise the Simulator | |
| # app. A host that cannot hand focus to Finder is not a usable automation host, so the iOS | |
| # phase below requires its success: it no longer fails the phase by running inside it. | |
| - name: Establish host focus canary | |
| id: host-focus-canary | |
| if: ${{ !cancelled() && steps.build.outcome == 'success' && steps.ios-impact.outputs.run != 'false' }} | |
| run: | | |
| set -euo pipefail | |
| osascript -e 'tell application "Finder" to activate' | |
| sleep 1 | |
| FRONTMOST="$(osascript -e 'tell application "System Events" to get bundle identifier of first application process whose frontmost is true')" | |
| test "$FRONTMOST" = "com.apple.finder" | |
| mkdir -p .tmp | |
| echo "$FRONTMOST" > .tmp/ios-host-focus-before | |
| shell: bash | |
| # The fixture wait policy decides how long the restore polls for a concurrently produced | |
| # artifact, and a background step's outputs reach only the steps after its group, so this | |
| # cheap decision stays sequential ahead of the group. | |
| - name: Set fixture producer wait policy | |
| id: fixture-producer | |
| if: ${{ !cancelled() && steps.build.outcome == 'success' && steps.ios-impact.outputs.run != 'false' }} | |
| run: | | |
| set -euo pipefail | |
| WAIT_SECONDS=1800 | |
| if [ "${{ github.event_name }}" = "pull_request" ] && [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then | |
| echo "Fork pull request cannot publish the shared fixture artifact; a cache miss will build inline." | |
| WAIT_SECONDS=0 | |
| fi | |
| echo "wait-seconds=$WAIT_SECONDS" >> "$GITHUB_OUTPUT" | |
| shell: bash | |
| # None of these needs a booted simulator, and the iOS phase cannot start XCTest, preflight, | |
| # or the fixture replays until all three finish. The phase ran them in sequence, so the | |
| # runner paid the boot, the native build, and the fixture restore one after another while the | |
| # simulator sat idle. They share no outputs and write disjoint paths (the simulator, the | |
| # runner DerivedData, and .tmp/fixture-app through examples/test-app/node_modules), so they | |
| # run as one parallel group and the phase pays the slowest instead of all three. The boot | |
| # keeps its deferred readiness so it still overlaps the build it now starts beside. | |
| - parallel: | |
| - name: Boot iOS test simulator | |
| id: ios-simulator | |
| if: ${{ !cancelled() && steps.build.outcome == 'success' && steps.ios-impact.outputs.run != 'false' }} | |
| uses: ./.github/actions/boot-ios-test-simulator | |
| with: | |
| runtime-version: ${{ env.IOS_RUNTIME_VERSION }} | |
| preferred-device-name: iPhone 17 Pro | |
| wait-for-boot: 'false' | |
| - name: Restore and build iOS XCTest runner | |
| id: ios-runner-build | |
| if: ${{ !cancelled() && steps.build.outcome == 'success' && steps.ios-impact.outputs.run != 'false' }} | |
| uses: ./.github/actions/setup-apple-runner-build | |
| with: | |
| derived-path: ${{ env.IOS_DERIVED_PATH }} | |
| cache-key-prefix: ios-runner-prebuilt | |
| cache-key-suffix: -ios-${{ env.IOS_RUNTIME_VERSION }}-arm64 | |
| gate: swift-runner-ios | |
| xcuitest-platform: ios | |
| xcuitest-destination: generic/platform=iOS Simulator | |
| # The build variant is part of the cache key, so these must stay exactly as the phase | |
| # passed them while the build ran inside it. | |
| env: | |
| AGENT_DEVICE_XCUITEST_INCLUDE_UNIT_TESTS: '1' | |
| AGENT_DEVICE_XCUITEST_ARCHS: arm64 | |
| - name: Restore fixture app | |
| id: fixture-app | |
| if: ${{ !cancelled() && steps.build.outcome == 'success' && steps.ios-impact.outputs.run != 'false' }} | |
| uses: ./.github/actions/setup-fixture-app | |
| with: | |
| install: 'false' | |
| wait-for-artifact-seconds: ${{ steps.fixture-producer.outputs.wait-seconds }} | |
| # A background step publishes its outputs only after the group's wait, which is why the | |
| # phase reads them as inputs rather than as its own steps. It also takes each member's | |
| # outcome: a member that failed would otherwise leave the phase skipped, and the phase | |
| # guard would report an unexplained skip instead of the member that caused it. | |
| - name: iOS smoke tests | |
| id: ios | |
| uses: ./.github/actions/smoke-ios-run | |
| continue-on-error: true | |
| timeout-minutes: 80 | |
| with: | |
| simulator-udid: ${{ steps.ios-simulator.outputs.simulator-udid }} | |
| boot-timeout-seconds: ${{ steps.ios-simulator.outputs.boot-timeout-seconds }} | |
| fixture-app-path: ${{ steps.fixture-app.outputs.app-path }} | |
| fixture-app-id: ${{ steps.fixture-app.outputs.app-id }} | |
| fixture-source: ${{ steps.fixture-app.outputs.source }} | |
| env: | |
| IOS_UDID: ${{ vars.IOS_UDID }} | |
| AGENT_DEVICE_STATE_DIR: ${{ env.IOS_STATE_DIR }} | |
| AGENT_DEVICE_IOS_RUNNER_DERIVED_PATH: ${{ env.IOS_DERIVED_PATH }} | |
| AGENT_DEVICE_IOS_PREPARE_TIMEOUT_MS: '420000' | |
| AGENT_DEVICE_XCUITEST_INCLUDE_UNIT_TESTS: '1' | |
| AGENT_DEVICE_XCUITEST_ARCHS: arm64 | |
| AGENT_DEVICE_IOS_APP_EVENT_URL_TEMPLATE: agent-device-test-app:///automation?event={event}&payload={payload} | |
| if: ${{ !cancelled() && steps.build.outcome == 'success' && steps.host-focus-canary.outcome == 'success' && steps.ios-simulator.outcome == 'success' && steps.ios-runner-build.outcome == 'success' && steps.fixture-app.outcome == 'success' && steps.ios-impact.outputs.run != 'false' }} | |
| - name: Clean the iOS host | |
| id: ios-cleanup | |
| if: ${{ always() && steps.build.outcome == 'success' && steps.ios-impact.outputs.run != 'false' }} | |
| continue-on-error: true | |
| env: | |
| AGENT_DEVICE_STATE_DIR: ${{ env.IOS_STATE_DIR }} | |
| shell: bash | |
| run: bash scripts/teardown-ios-smoke.sh | |
| - name: macOS smoke tests | |
| id: macos | |
| uses: ./.github/actions/smoke-macos | |
| continue-on-error: true | |
| timeout-minutes: 80 | |
| env: | |
| AGENT_DEVICE_STATE_DIR: ${{ env.MACOS_STATE_DIR }} | |
| AGENT_DEVICE_IOS_RUNNER_DERIVED_PATH: ${{ env.MACOS_DERIVED_PATH }} | |
| AGENT_DEVICE_XCUITEST_INCLUDE_UNIT_TESTS: '1' | |
| RESULT_BUNDLE_PATH: ${{ github.workspace }}/.tmp/xctest-host/RunnerTests.xcresult | |
| RESULT_SUMMARY_PATH: ${{ github.workspace }}/.tmp/xctest-host/test-results-summary.json | |
| XCTEST_LANE: host | |
| if: ${{ !cancelled() && steps.build.outcome == 'success' && steps.macos-impact.outputs.run != 'false' }} | |
| - name: Diagnose the Apple host after a phase failure | |
| # The canary, boot, runner build, and fixture restore can now fail outside the phase, where | |
| # the phase's own outcome reads as skipped rather than failed. | |
| if: ${{ always() && (steps.ios.outcome == 'failure' || steps.macos.outcome == 'failure' || steps.ios-cleanup.outcome == 'failure' || steps.host-focus-canary.outcome == 'failure' || steps.ios-simulator.outcome == 'failure' || steps.ios-runner-build.outcome == 'failure' || steps.fixture-app.outcome == 'failure') }} | |
| continue-on-error: true | |
| shell: bash | |
| run: | | |
| mkdir -p test/screenshots | |
| screencapture -x test/screenshots/apple-host-after-failure.png | |
| osascript scripts/decline-hosted-compute-local-network.applescript diagnose | |
| - name: Clean macOS daemon and retained runners | |
| id: macos-cleanup | |
| if: ${{ always() && steps.build.outcome == 'success' && steps.macos-impact.outputs.run != 'false' }} | |
| continue-on-error: true | |
| env: | |
| AGENT_DEVICE_STATE_DIR: ${{ env.MACOS_STATE_DIR }} | |
| shell: bash | |
| run: | | |
| pnpm clean:daemon | |
| - name: Require the selected Apple phases to succeed | |
| if: always() | |
| env: | |
| IOS_SELECTED: ${{ steps.ios-impact.outputs.run }} | |
| IOS_OUTCOME: ${{ steps.ios.outcome }} | |
| MACOS_SELECTED: ${{ steps.macos-impact.outputs.run }} | |
| MACOS_OUTCOME: ${{ steps.macos.outcome }} | |
| IOS_CLEANUP_OUTCOME: ${{ steps.ios-cleanup.outcome }} | |
| MACOS_CLEANUP_OUTCOME: ${{ steps.macos-cleanup.outcome }} | |
| IOS_SETUP_OUTCOMES: 'canary=${{ steps.host-focus-canary.outcome }} boot=${{ steps.ios-simulator.outcome }} runner=${{ steps.ios-runner-build.outcome }} fixture=${{ steps.fixture-app.outcome }}' | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| printf "### Apple smoke phases\n\n| Phase | Outcome |\n| --- | --- |\n| iOS | %s |\n| macOS | %s |\n" "$IOS_OUTCOME" "$MACOS_OUTCOME" >> "$GITHUB_STEP_SUMMARY" | |
| # A step hoisted out of the phase shows up below only as a skipped phase. Name them so the | |
| # skip has a cause. | |
| printf 'iOS setup outside the phase: %s\n' "$IOS_SETUP_OUTCOMES" >> "$GITHUB_STEP_SUMMARY" | |
| if [ "$IOS_SELECTED" = false ]; then | |
| test "$IOS_OUTCOME" = skipped | |
| test "$IOS_CLEANUP_OUTCOME" = skipped | |
| else | |
| test "$IOS_OUTCOME" = success | |
| test "$IOS_CLEANUP_OUTCOME" = success | |
| fi | |
| if [ "$MACOS_SELECTED" = false ]; then | |
| test "$MACOS_OUTCOME" = skipped | |
| test "$MACOS_CLEANUP_OUTCOME" = skipped | |
| else | |
| test "$MACOS_OUTCOME" = success | |
| test "$MACOS_CLEANUP_OUTCOME" = success | |
| fi | |
| - name: Upload Apple artifacts | |
| if: always() | |
| uses: ./.github/actions/upload-agent-device-artifacts | |
| with: | |
| artifact-name: apple-artifacts-${{ matrix.platform }} | |
| agent-state-dir: ${{ env.IOS_STATE_DIR }} | |
| runner-derived-path: ${{ env.IOS_DERIVED_PATH }} | |
| additional-paths: | | |
| ${{ env.MACOS_STATE_DIR }}/daemon.log | |
| ${{ env.MACOS_STATE_DIR }}/sessions/** | |
| ${{ env.MACOS_DERIVED_PATH }}/.agent-device-runner-cache.json | |
| ${{ env.MACOS_DERIVED_PATH }}/Logs/** | |
| smoke-apple: | |
| name: Smoke Tests | |
| if: ${{ always() && !github.event.pull_request.draft }} | |
| needs: smoke-apple-platform | |
| runs-on: blacksmith-2vcpu-ubuntu-2404 | |
| steps: | |
| - name: Require both Apple jobs to succeed | |
| env: | |
| RESULT: ${{ needs.smoke-apple-platform.result }} | |
| run: test "$RESULT" = success | |
| # PR-time compile guard for the runner platforms the smoke lanes never build. The iOS and | |
| # macOS runners are compiled by smoke-apple-platform above, but tvOS, visionOS, and watchOS | |
| # compiled only at release time (scripts/build-package-xcuitest.mjs), which let #4608 escape | |
| # to release. This job runs the same xcodebuild build-for-testing compile for those three | |
| # platforms, on the same PRs that own the runner sources, so a build break that only the | |
| # release would have caught fails the PR instead. | |
| build-runner-tvos-visionos-watchos: | |
| name: Runner Build (tvOS + visionOS + watchOS) | |
| if: ${{ !github.event.pull_request.draft }} | |
| # Same image as the smoke lane's runner build; its Xcode ships the tvOS, visionOS, and watchOS SDKs | |
| # alongside iOS, so no separate image or toolchain selection is needed. | |
| runs-on: blacksmith-6vcpu-macos-26 | |
| timeout-minutes: 60 | |
| env: | |
| BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
| TVOS_DERIVED_PATH: ${{ github.workspace }}/.tmp/tvos-runner-derived | |
| VISIONOS_DERIVED_PATH: ${{ github.workspace }}/.tmp/visionos-runner-derived | |
| WATCHOS_DERIVED_PATH: ${{ github.workspace }}/.tmp/watchos-runner-derived | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| - name: Setup toolchain | |
| uses: ./.github/actions/setup-node-pnpm | |
| with: | |
| cache-dependency-path: | | |
| pnpm-lock.yaml | |
| examples/test-app/pnpm-lock.yaml | |
| - name: Fetch the PR base for the runner selector | |
| if: github.event_name == 'pull_request' | |
| shell: bash | |
| run: | | |
| git fetch origin "$BASE_SHA" --depth=1 || echo "Base fetch failed; the runner selector will fail open." | |
| # The same selector the iOS runner build rides on (scripts/device-lane-impact.ts over the | |
| # affected-check model): the job pays macOS minutes only on PRs that own the runner build | |
| # sources (apple/runner/** and the other own:swift trees), and fails open when the change | |
| # set cannot be established. Pushes to main run every build unconditionally. | |
| - name: Select tvOS/visionOS/watchOS runner builds | |
| id: runner-impact | |
| shell: bash | |
| run: node --experimental-strip-types scripts/device-lane-impact.ts swift-runner-tvos swift-runner-visionos swift-runner-watchos | |
| # One build per platform, mirroring the iOS runner build step: separate DerivedData and | |
| # cache key per platform, generic simulator destinations so no device or runtime boot is | |
| # needed, and the release package build's variant (no unit-test flag), which is the | |
| # compile the release actually ships. | |
| - parallel: | |
| - name: Restore and build tvOS XCTest runner | |
| if: ${{ !cancelled() && steps.runner-impact.outputs.run != 'false' }} | |
| uses: ./.github/actions/setup-apple-runner-build | |
| with: | |
| derived-path: ${{ env.TVOS_DERIVED_PATH }} | |
| cache-key-prefix: tvos-runner-prebuilt | |
| cache-key-suffix: -tvos-arm64 | |
| gate: swift-runner-tvos | |
| xcuitest-platform: tvos | |
| xcuitest-destination: generic/platform=tvOS Simulator | |
| env: | |
| AGENT_DEVICE_XCUITEST_ARCHS: arm64 | |
| - name: Restore and build visionOS XCTest runner | |
| if: ${{ !cancelled() && steps.runner-impact.outputs.run != 'false' }} | |
| uses: ./.github/actions/setup-apple-runner-build | |
| with: | |
| derived-path: ${{ env.VISIONOS_DERIVED_PATH }} | |
| cache-key-prefix: visionos-runner-prebuilt | |
| cache-key-suffix: -visionos-arm64 | |
| gate: swift-runner-visionos | |
| xcuitest-platform: visionos | |
| xcuitest-destination: generic/platform=visionOS Simulator | |
| env: | |
| AGENT_DEVICE_XCUITEST_ARCHS: arm64 | |
| - name: Restore and build watchOS XCTest runner | |
| if: ${{ !cancelled() && steps.runner-impact.outputs.run != 'false' }} | |
| uses: ./.github/actions/setup-apple-runner-build | |
| with: | |
| derived-path: ${{ env.WATCHOS_DERIVED_PATH }} | |
| cache-key-prefix: watchos-runner-prebuilt | |
| cache-key-suffix: -watchos-arm64 | |
| gate: swift-runner-watchos | |
| xcuitest-platform: watchos | |
| xcuitest-destination: generic/platform=watchOS Simulator | |
| env: | |
| AGENT_DEVICE_XCUITEST_ARCHS: arm64 |