name: Mobile E2E Testing # Runs a generated Craft app on a real iOS simulator and a real Android # emulator and asserts that a call made from JavaScript reached native code and # came back. # # The version this replaces asserted nothing. Every iOS step that would have # tested something was guarded by # `if: hashFiles('packages/ios/TestApp/TestApp.xcodeproj') != ''` against a # project that has never existed in the tree, and the Android job's only test # invocation was gated on `packages/android/gradlew`, which the generator does # not write. Both skipped on every run, and the job reported success. Its # header also blamed the iOS Zig sources for not compiling since the 0.17 # migration (1b6f285); that is no longer true — # `zig build build-ios-simulator` succeeds at this commit, and the iOS job # below depends on it. # # What the harness asserts, per platform, is in scripts/mobile-e2e/protocol.ts: # a required list of cases that must all run and all pass, covering at least # one success path and one rejection path. Nothing here skips. A missing # toolchain, an absent device, or an app that printed nothing is a failure with # a named cause. # GitHub Actions does not resolve YAML anchors, so the two path filters are # written out rather than shared. Keep them identical. on: workflow_call: {} push: branches: [main] paths: - packages/ios/** - packages/android/** # The mobile Zig sources are flat files under src/, not src/ios/ and # src/android/ as the previous filters claimed — those two directories # have never existed, so the filter matched nothing. - packages/zig/src/ios*.zig - packages/zig/src/android*.zig - packages/zig/src/mobile*.zig - packages/zig/src/bridge_mobile_*.zig - packages/zig/src/bridge_android_*.zig - packages/zig/src/jni*.zig - packages/zig/src/platform_uuid.zig # Shared layout is compiled into both mobile runtimes. - packages/zig/src/native_layout.zig - packages/zig/src/metal_surface.zig - packages/zig/src/vulkan_surface.zig - packages/zig/src/vulkan_api.zig - packages/zig/src/graphics.zig - packages/zig/src/graphics_scene.zig - packages/zig/test/fixtures/vulkan-surface-consumer/** - packages/zig/src/objc_runtime.zig - packages/zig/build.zig - packages/zig/build.zig.zon - scripts/zig.ts - pantry.lock - scripts/mobile-e2e.ts - scripts/mobile-e2e/** - scripts/media-cache.ts - packages/typescript/src/mobile-media-testing.ts - packages/typescript/fixtures/media-cache/** - .github/workflows/media-cache.yml - .github/workflows/mobile-e2e.yml pull_request: paths: - packages/ios/** - packages/android/** - packages/zig/src/ios*.zig - packages/zig/src/android*.zig - packages/zig/src/mobile*.zig - packages/zig/src/bridge_mobile_*.zig - packages/zig/src/bridge_android_*.zig - packages/zig/src/jni*.zig - packages/zig/src/platform_uuid.zig - packages/zig/src/native_layout.zig - packages/zig/src/metal_surface.zig - packages/zig/src/vulkan_surface.zig - packages/zig/src/vulkan_api.zig - packages/zig/src/graphics.zig - packages/zig/src/graphics_scene.zig - packages/zig/test/fixtures/vulkan-surface-consumer/** - packages/zig/src/objc_runtime.zig - packages/zig/build.zig - packages/zig/build.zig.zon - scripts/zig.ts - pantry.lock - scripts/mobile-e2e.ts - scripts/mobile-e2e/** - scripts/media-cache.ts - packages/typescript/src/mobile-media-testing.ts - packages/typescript/fixtures/media-cache/** - .github/workflows/media-cache.yml - .github/workflows/mobile-e2e.yml workflow_dispatch: inputs: scope: description: Test all mobile suites or focused Android/rendering/navigation/hybrid suites type: choice options: [all, android, android-vulkan, android-checkpoints, ios-render, ios-checkpoints, ios-navigation, ios-hybrid, android-navigation] default: all android_suite: description: Android native fixture coverage for the android-navigation scope type: choice options: [focused, full, system-bars, maps, accessibility, identity, capabilities, teardown] default: focused selectors: description: Optional XCTest selector for focused native iOS rendering or navigation type: string default: '' concurrency: # Releaser requires the exact release SHA. Give it its own pending slot, # just as Main CI does, so a newer push cannot replace native acceptance. group: "mobile-e2e-${{ (github.event_name == 'push' && startsWith(github.event.head_commit.message, 'chore: release v') && github.sha) || (github.head_ref || github.ref) }}-${{ inputs.scope || 'all' }}" # A newer push to main cancels the superseded commit's run, freeing its # macOS runners; a release commit's run, in its own group, is never # cancelled and cancels nothing (see ci.yml). cancel-in-progress: "${{ github.event_name == 'pull_request' || (github.event_name == 'push' && !startsWith(github.event.head_commit.message, 'chore: release v')) }}" permissions: contents: read defaults: run: shell: bash # One source of truth for the compiler used by every native fixture. Keep this # at the workflow level so a released compiler qualification changes one line, # not four checkout steps plus documentation and a second test constant. env: STX_COMPILER_VERSION: v0.2.923 jobs: media-cache: if: ${{ inputs.scope != 'ios-navigation' && inputs.scope != 'android-navigation' && inputs.scope != 'android' && inputs.scope != 'ios-render' && inputs.scope != 'ios-checkpoints' && inputs.scope != 'ios-hybrid' && inputs.scope != 'android-vulkan' && inputs.scope != 'android-checkpoints' }} uses: ./.github/workflows/media-cache.yml # The transcript reader and the required-case list are the part of this # harness that can be tested without a device, and nothing ran those tests: # every `bun test` in this repository is scoped to a package directory or to # one explicit file, and the root `test` script is the Zig suite. So the # ratchet that stops the suite being hollowed out was itself unenforced. harness: name: Harness unit tests runs-on: ubuntu-latest timeout-minutes: 10 steps: - uses: actions/checkout@v6 - name: Setup Pantry (provides Bun, Zig, etc.) uses: pantry-pm/pantry/packages/action@f6a85d762e728b7f91e3bebe700f08d0dc5ee5e0 # v0.11.214 with: version: '0.11.214' - name: Install dependencies run: bun install --frozen-lockfile # The explicit path is load-bearing: a bare filter makes bun walk the # repository and run out of file descriptors under the hoisted linker. # See the note in native-lifecycle.yml. - name: Test the report protocol run: bun test ./scripts/mobile-e2e/protocol.test.ts ./packages/android/scripts/test-vulkan-surface.test.ts ./packages/android/scripts/vulkan-surface-result.test.ts ./packages/android/scripts/test-checkpoint-interruption.test.ts ios-native: if: ${{ inputs.scope != 'android-navigation' && inputs.scope != 'android' && inputs.scope != 'ios-hybrid' && inputs.scope != 'android-vulkan' && inputs.scope != 'android-checkpoints' }} name: iOS native UI (${{ matrix.suite }}) strategy: fail-fast: false matrix: suite: ${{ fromJSON((inputs.scope == 'ios-render' || inputs.scope == 'ios-checkpoints') && '["uikit"]' || inputs.scope == 'ios-navigation' && inputs.selectors != '' && '["navigation"]' || inputs.scope == 'ios-navigation' && '["navigation-unit","navigation-ui-core-1","navigation-ui-core-2","navigation-ui-controls-1","navigation-ui-controls-2"]' || '["uikit","navigation-unit","navigation-ui-core-1","navigation-ui-core-2","navigation-ui-controls-1","navigation-ui-controls-2"]') }} runs-on: macos-15 # Every navigation UI case belongs to exactly one required group. Core # navigation and the controls journeys each run as two legs (#508): one leg # of either reached this limit with its cases intact. Unit reconciliation # and UIKit retain separate results and the same bounded backstop. timeout-minutes: 45 env: CRAFT_EVIDENCE_LABEL: ios-native # XCTest and WebKit hit testing must come from the runtime's toolchain. DEVELOPER_DIR: /Applications/Xcode_26.2.app/Contents/Developer steps: - uses: actions/checkout@v6 # A fresh macOS runner is still building its Spotlight index while the # simulator boots: load averages of 200-400, with mds_stores on top, # starved XCTest's app launch until it timed out (#560). Nothing these # jobs run searches with Spotlight. - name: Stop Spotlight indexing run: sudo mdutil -a -i off || true # These fixtures explicitly use runtimeDir: null; they need Bun and # Xcode, while the separate protocol job builds and tests Zig. - name: Setup Bun uses: oven-sh/setup-bun@v2 with: bun-version: '1.4.3' - name: Install XcodeGen run: brew install xcodegen - name: Install dependencies run: bun install --frozen-lockfile # The fixtures compile real .stx sources. Pin the # @stacksjs/stx compiler (`stx native compile`) so this job cannot silently change # underneath us. Both iOS jobs and Android use the same released version. - name: Checkout stx compiler if: ${{ startsWith(matrix.suite, 'navigation') }} uses: actions/checkout@v6 with: repository: stacksjs/stx ref: ${{ env.STX_COMPILER_VERSION }} path: .stx-compiler - name: Install stx compiler dependencies if: ${{ startsWith(matrix.suite, 'navigation') }} working-directory: .stx-compiler run: bun install --frozen-lockfile - name: Test native UIKit reconciliation id: uikit if: ${{ matrix.suite == 'uikit' }} env: CRAFT_NATIVE_RENDER_RESULT: ${{ github.workspace }}/artifacts/mobile-e2e/ios-native/uikit.xcresult CRAFT_ONLY_TESTING: ${{ inputs.scope == 'ios-checkpoints' && 'NativeRenderUnitTests/PersistentRecordingCheckpointUnitTests' || inputs.scope == 'ios-render' && inputs.selectors || '' }} run: | mkdir -p artifacts/mobile-e2e/ios-native bun packages/ios/scripts/test-native-render.ts 2>&1 | tee artifacts/mobile-e2e/ios-native/uikit.log - name: Test native driver text editing if: ${{ !cancelled() && matrix.suite == 'uikit' && inputs.scope != 'ios-checkpoints' }} env: CRAFT_DRIVER_TEXT_RESULT: ${{ github.workspace }}/artifacts/mobile-e2e/ios-native/driver-text.xcresult CRAFT_DRIVER_TEXT_LIVE_LOG: ${{ github.workspace }}/artifacts/mobile-e2e/ios-native/driver-text.log run: | # Reuse this disposable job's simulator after its UIKit fixture. export CRAFT_DRIVER_SIMULATOR="$(xcrun simctl list devices booted --json | bun -e 'const payload=await Bun.stdin.json(); const devices=Object.values(payload.devices).flat().filter(device=>device.state === "Booted"); if(devices.length !== 1) throw new Error("Expected exactly one job-owned booted simulator"); console.log(devices[0].udid)')" bun packages/ios/scripts/test-driver-text.ts 2>&1 | tee artifacts/mobile-e2e/ios-native/driver-text.log - name: Test native multi-screen navigation id: navigation # Reconciliation and navigation are independent suites. Keep the # navigation evidence when reconciliation fails; the job still fails. if: ${{ !cancelled() && startsWith(matrix.suite, 'navigation') }} env: STX_CLI: ${{ github.workspace }}/.stx-compiler/packages/stx/bin/cli.ts CRAFT_ONLY_TESTING: ${{ matrix.suite == 'navigation-unit' && 'NativeNavigationUnitTests' || inputs.selectors }} CRAFT_NATIVE_NAVIGATION_GROUP: ${{ matrix.suite == 'navigation-ui-core-1' && 'core-1' || matrix.suite == 'navigation-ui-core-2' && 'core-2' || matrix.suite == 'navigation-ui-controls-1' && 'controls-1' || matrix.suite == 'navigation-ui-controls-2' && 'controls-2' || '' }} CRAFT_NATIVE_NAVIGATION_RESULT: ${{ github.workspace }}/artifacts/mobile-e2e/ios-native/navigation.xcresult CRAFT_NATIVE_NAVIGATION_LIVE_LOG: ${{ github.workspace }}/artifacts/mobile-e2e/ios-native/navigation.log run: | mkdir -p artifacts/mobile-e2e/ios-native bun packages/ios/scripts/test-native-navigation.ts 2>&1 | tee artifacts/mobile-e2e/ios-native/navigation.log - name: Collect iOS simulator diagnostics id: diagnostics if: always() run: | evidence_dir="artifacts/mobile-e2e/ios-native/diagnostics" mkdir -p "$evidence_dir" run_bounded() { local seconds="$1" shift "$@" & local command_pid=$! ( sleep "$seconds"; kill "$command_pid" 2>/dev/null || true ) & local watchdog_pid=$! local status=0 if wait "$command_pid"; then status=0; else status=$?; fi kill "$watchdog_pid" 2>/dev/null || true wait "$watchdog_pid" 2>/dev/null || true return "$status" } { echo "uikit=${{ steps.uikit.conclusion }}" echo "navigation=${{ steps.navigation.conclusion }}" echo "runner=$(uname -a)" echo run_bounded 20 xcrun simctl list devices || true } > "$evidence_dir/simulator.txt" 2>&1 run_bounded 20 xcrun simctl spawn booted log show --last 10m --style compact > "$evidence_dir/system.log" 2>&1 || true # The whole device's log is cut off by the bound above before it # reaches the end of the window; the test app's own lines (the # animation probe, #522) reach it. run_bounded 60 xcrun simctl spawn booted log show --last 30m --style compact --predicate 'process BEGINSWITH "Native"' > "$evidence_dir/app.log" 2>&1 || true { find "$HOME/Library/Logs/DiagnosticReports" -maxdepth 1 -type f \ \( -name '*NativeNavigation*' -o -name '*NativeRender*' -o -name '*Craft*' \) -print 2>/dev/null || true } > "$evidence_dir/crash-reports.txt" while IFS= read -r report; do cp "$report" "$evidence_dir/$(basename "$report")" || true done < "$evidence_dir/crash-reports.txt" - name: Upload iOS evidence if: always() uses: actions/upload-artifact@v4 with: name: mobile-e2e-ios-native-${{ matrix.suite }} # Console logs, build logs, screenshots, the generated project.yml and # the exact page that ran. Excludes work/ — the generated projects and # their DerivedData are hundreds of megabytes and the interesting # parts are copied out. path: | artifacts/mobile-e2e/ios-native/** !artifacts/mobile-e2e/ios-native/work/** # A run that produced no evidence is a broken harness, not a pass. if-no-files-found: error retention-days: 30 ios-metal: name: iOS native Metal surface if: ${{ inputs.scope != 'ios-checkpoints' && inputs.scope != 'ios-navigation' && inputs.scope != 'android-navigation' && inputs.scope != 'android' && inputs.scope != 'ios-hybrid' && inputs.scope != 'android-vulkan' && inputs.scope != 'android-checkpoints' }} runs-on: macos-15 timeout-minutes: 25 env: DEVELOPER_DIR: /Applications/Xcode_26.2.app/Contents/Developer steps: - uses: actions/checkout@v6 # A fresh macOS runner is still building its Spotlight index while the # simulator boots: load averages of 200-400, with mds_stores on top, # starved XCTest's app launch until it timed out (#560). Nothing these # jobs run searches with Spotlight. - name: Stop Spotlight indexing run: sudo mdutil -a -i off || true - name: Install the pinned native fixture toolchain uses: pantry-pm/pantry/packages/action@f6a85d762e728b7f91e3bebe700f08d0dc5ee5e0 # v0.11.214 with: version: '0.11.214' install: 'false' packages: bun.com@1.4.3 git-scm.org@2.56.0 ziglang.org@0.18.0-dev.146+35accc06e github.com/yonaskolb/XcodeGen@2.46.0 - name: Install dependencies run: bun install --frozen-lockfile - name: Verify actual UIKit Metal pixels and displayed frames run: >- bun packages/ios/scripts/test-metal-surface.ts --runtime com.apple.CoreSimulator.SimRuntime.iOS-26-2 --xcodegen "$PWD/pantry/.bin/xcodegen" --output artifacts/mobile-e2e/ios-metal - name: Retain native Metal execution evidence if: always() uses: actions/upload-artifact@v4 with: name: ios-native-metal-surface path: artifacts/mobile-e2e/ios-metal if-no-files-found: error retention-days: 30 ios-hybrid: name: iOS hybrid navigation if: ${{ inputs.scope != 'ios-navigation' && inputs.scope != 'android-navigation' && inputs.scope != 'ios-render' && inputs.scope != 'ios-checkpoints' && inputs.scope != 'android' && inputs.scope != 'android-vulkan' && inputs.scope != 'android-checkpoints' }} runs-on: macos-15 timeout-minutes: 35 env: DEVELOPER_DIR: /Applications/Xcode_26.2.app/Contents/Developer steps: - uses: actions/checkout@v6 # A fresh macOS runner is still building its Spotlight index while the # simulator boots: load averages of 200-400, with mds_stores on top, # starved XCTest's app launch until it timed out (#560). Nothing these # jobs run searches with Spotlight. - name: Stop Spotlight indexing run: sudo mdutil -a -i off || true - name: Setup Bun uses: oven-sh/setup-bun@v2 with: bun-version: '1.4.3' - name: Install XcodeGen run: brew install xcodegen - name: Install dependencies run: bun install --frozen-lockfile - name: Typecheck the hybrid fixture harness run: >- bun x --bun tsc --noEmit --ignoreConfig --strict --skipLibCheck --target esnext --module preserve --moduleResolution bundler --types bun --lib esnext,dom --allowImportingTsExtensions packages/ios/scripts/test-hybrid-navigation.ts - name: Checkout stx compiler uses: actions/checkout@v6 with: repository: stacksjs/stx ref: ${{ env.STX_COMPILER_VERSION }} path: .stx-compiler - name: Install stx compiler dependencies working-directory: .stx-compiler run: bun install --frozen-lockfile - name: Test hybrid web navigation transitions env: STX_CLI: ${{ github.workspace }}/.stx-compiler/packages/stx/bin/cli.ts run: bun packages/ios/scripts/test-hybrid-navigation.ts - name: Retain hybrid XCTest evidence if: always() uses: actions/upload-artifact@v4 with: name: mobile-e2e-ios-hybrid path: artifacts/mobile-e2e/ios-hybrid/** if-no-files-found: error retention-days: 30 ios-simulator: name: iOS simulator if: ${{ inputs.scope != 'ios-navigation' && inputs.scope != 'android-navigation' && inputs.scope != 'ios-render' && inputs.scope != 'ios-checkpoints' && inputs.scope != 'android' && inputs.scope != 'ios-hybrid' && inputs.scope != 'android-vulkan' && inputs.scope != 'android-checkpoints' }} runs-on: macos-15 # Keep protocol acceptance separate from hybrid XCTest. Both are required; # combining them exhausted this budget after all app assertions passed. timeout-minutes: 45 env: CRAFT_EVIDENCE_LABEL: ios-simulator DEVELOPER_DIR: /Applications/Xcode_26.2.app/Contents/Developer steps: - uses: actions/checkout@v6 # A fresh macOS runner is still building its Spotlight index while the # simulator boots: load averages of 200-400, with mds_stores on top, # starved XCTest's app launch until it timed out (#560). Nothing these # jobs run searches with Spotlight. - name: Stop Spotlight indexing run: sudo mdutil -a -i off || true - name: Setup Pantry (provides Bun, Zig, etc.) uses: pantry-pm/pantry/packages/action@f6a85d762e728b7f91e3bebe700f08d0dc5ee5e0 # v0.11.214 with: version: '0.11.214' - name: Setup Bun for the frozen stx compiler lockfile uses: oven-sh/setup-bun@v2 with: bun-version: '1.4.3' - name: Install XcodeGen run: brew install xcodegen - name: Install dependencies run: bun install --frozen-lockfile - name: Cache Zig artifacts uses: actions/cache@v5 with: path: | ~/.cache/zig packages/zig/.zig-cache key: mobile-e2e-ios-${{ runner.os }}-${{ hashFiles('packages/zig/build.zig') }} - name: First-party Zig dependencies uses: ./.github/actions/first-party-zig-deps # The SDK builds all slices with this probe's permission profile and # verifies their identity before installation. Keep the real Zig leg. - name: Run mobile E2E on the simulator id: harness run: bun scripts/mobile-e2e.ts --platform ios --ios-runtime-source packages/zig - name: Collect iOS simulator diagnostics id: diagnostics if: always() run: | evidence_dir="artifacts/mobile-e2e/ios-simulator/diagnostics" mkdir -p "$evidence_dir" run_bounded() { local seconds="$1" shift "$@" & local command_pid=$! ( sleep "$seconds"; kill "$command_pid" 2>/dev/null || true ) & local watchdog_pid=$! local status=0 if wait "$command_pid"; then status=0; else status=$?; fi kill "$watchdog_pid" 2>/dev/null || true wait "$watchdog_pid" 2>/dev/null || true return "$status" } { echo "harness=${{ steps.harness.conclusion }}" echo "runner=$(uname -a)" echo run_bounded 20 xcrun simctl list devices || true } > "$evidence_dir/simulator.txt" 2>&1 run_bounded 20 xcrun simctl spawn booted log show --last 10m --style compact > "$evidence_dir/system.log" 2>&1 || true { find "$HOME/Library/Logs/DiagnosticReports" -maxdepth 1 -type f \ \( -name '*NativeNavigation*' -o -name '*Craft*' \) -print 2>/dev/null || true } > "$evidence_dir/crash-reports.txt" while IFS= read -r report; do cp "$report" "$evidence_dir/$(basename "$report")" || true done < "$evidence_dir/crash-reports.txt" - name: Upload iOS evidence if: always() uses: actions/upload-artifact@v4 with: name: mobile-e2e-ios # Console logs, build logs, screenshots, the generated project.yml and # the exact page that ran. Excludes work/ — the generated projects and # their DerivedData are hundreds of megabytes and the interesting # parts are copied out. path: | artifacts/mobile-e2e/ios-simulator/** !artifacts/mobile-e2e/ios-simulator/work/** # A run that produced no evidence is a broken harness, not a pass. if-no-files-found: error retention-days: 30 android-emulator: name: Android emulator if: ${{ inputs.scope != 'ios-navigation' && inputs.scope != 'android-navigation' && inputs.scope != 'ios-render' && inputs.scope != 'ios-checkpoints' && inputs.scope != 'ios-hybrid' && inputs.scope != 'android-vulkan' && inputs.scope != 'android-checkpoints' }} runs-on: ubuntu-latest timeout-minutes: 60 env: CRAFT_EVIDENCE_LABEL: android-emulator steps: - uses: actions/checkout@v6 - name: Setup Pantry (provides Bun, Zig, etc.) uses: pantry-pm/pantry/packages/action@f6a85d762e728b7f91e3bebe700f08d0dc5ee5e0 # v0.11.214 with: version: '0.11.214' - name: Setup Bun for the frozen stx compiler lockfile uses: oven-sh/setup-bun@v2 with: bun-version: '1.4.3' - name: Setup Java uses: actions/setup-java@v6 with: distribution: temurin java-version: '17' - name: Setup Android SDK uses: android-actions/setup-android@v4 with: # The action defaults to `tools platform-tools`, but the obsolete # `tools` package is no longer offered by the Android SDK repository. packages: platform-tools # Same platform and build-tools as ci.yml's android-builder, so the # emulator job and the compile gate cannot drift onto different SDKs. - name: Install Android platform run: sdkmanager "platforms;android-36" "build-tools;36.0.0" - name: Setup Gradle uses: gradle/actions/setup-gradle@v6 with: gradle-version: '8.11.1' - name: Install dependencies run: bun install --frozen-lockfile - name: Checkout @stacksjs/stx compiler for Android uses: actions/checkout@v6 with: repository: stacksjs/stx ref: ${{ env.STX_COMPILER_VERSION }} path: .stx-compiler - name: Install Android stx compiler dependencies working-directory: .stx-compiler run: bun install --frozen-lockfile - name: Cache Zig artifacts uses: actions/cache@v5 with: path: | ~/.cache/zig packages/zig/.zig-cache key: mobile-e2e-android-${{ runner.os }}-${{ hashFiles('packages/zig/build.zig') }} - name: First-party Zig dependencies uses: ./.github/actions/first-party-zig-deps # The NDK is what supplies bionic. Without it the JNI library builds and # then fails at dlopen with `cannot locate symbol "__tls_get_addr"`, which # CraftNative catches and turns into a silent fallback to the Kotlin shim # — the failure this whole leg exists to catch. - name: Install the Android NDK run: | sdkmanager --install "ndk;26.1.10909125" echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/26.1.10909125" >> "$GITHUB_ENV" # Both ABIs. x86_64 is the one the emulator actually loads; arm64-v8a is # built so the runtime leg installs the same APK a phone would get. - name: Build the Zig Android runtime working-directory: packages/zig run: zig build build-android-all -Doptimize=ReleaseSafe -Dandroid-ndk="$ANDROID_NDK_HOME" - name: Enable KVM run: | echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules sudo udevadm control --reload-rules sudo udevadm trigger --name-match=kvm - name: AVD cache uses: actions/cache@v5 id: avd-cache with: path: | ~/.android/avd/* ~/.android/adb* # The device, not just the API level. With force-avd-creation off the # action reuses whatever the cache restored, so a key that ignores # arch and profile would keep testing the old device after someone # changed them. key: avd-api-34-x86_64-pixel_6-${{ runner.os }} # `script:` is the only place a command can run with the emulator # attached, so the harness is invoked from inside it rather than as its # own step. - name: Run mobile E2E on the emulator id: harness uses: reactivecircus/android-emulator-runner@v2 with: api-level: 34 arch: x86_64 profile: pixel_6 force-avd-creation: false emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim disable-animations: true script: | adb wait-for-device bun scripts/mobile-e2e.ts --platform android --android-runtime packages/zig/zig-out/android ANDROID_SERIAL=emulator-5554 CRAFT_ANDROID_NATIVE_ARTIFACTS="$GITHUB_WORKSPACE/artifacts/mobile-e2e/android-emulator/native-navigation" STX_CLI="$GITHUB_WORKSPACE/.stx-compiler/packages/stx/bin/cli.ts" bun packages/android/scripts/test-native-navigation.ts - name: Collect Android emulator diagnostics id: diagnostics if: always() run: | evidence_dir="artifacts/mobile-e2e/android-emulator/diagnostics" mkdir -p "$evidence_dir" run_bounded() { local seconds="$1" shift "$@" & local command_pid=$! ( sleep "$seconds"; kill "$command_pid" 2>/dev/null || true ) & local watchdog_pid=$! local status=0 if wait "$command_pid"; then status=0; else status=$?; fi kill "$watchdog_pid" 2>/dev/null || true wait "$watchdog_pid" 2>/dev/null || true return "$status" } { echo "harness=${{ steps.harness.conclusion }}" echo "runner=$(uname -a)" echo run_bounded 20 adb devices -l || true } > "$evidence_dir/adb.txt" 2>&1 run_bounded 20 adb logcat -d -v threadtime > "$evidence_dir/logcat.txt" 2>&1 || true { pgrep -af 'emulator|qemu' || true echo ps aux | grep -E '[e]mulator|[q]emu' || true } > "$evidence_dir/processes.txt" - name: Upload Android evidence if: always() uses: actions/upload-artifact@v4 with: name: mobile-e2e-android path: | artifacts/mobile-e2e/android-emulator/** !artifacts/mobile-e2e/android-emulator/work/** if-no-files-found: error retention-days: 30 # The Zig runtime's own simulator fixture: a hand-linked four-file app that # drives libcraft-ios-simulator directly, with assertions the generated-app # suite cannot make — the host hand-off, the error route's escaping, a # Keychain round trip, in-process SQLite, and a sensor the simulator does not # have refusing rather than fabricating a stream. It has been in the tree, # passing, and wired into no workflow. ios-zig-slice: name: iOS Zig runtime slice if: ${{ inputs.scope != 'ios-navigation' && inputs.scope != 'android-navigation' && inputs.scope != 'ios-render' && inputs.scope != 'ios-checkpoints' && inputs.scope != 'android' && inputs.scope != 'ios-hybrid' && inputs.scope != 'android-vulkan' && inputs.scope != 'android-checkpoints' }} runs-on: macos-15 timeout-minutes: 45 env: DEVELOPER_DIR: /Applications/Xcode_26.2.app/Contents/Developer steps: - uses: actions/checkout@v6 # A fresh macOS runner is still building its Spotlight index while the # simulator boots: load averages of 200-400, with mds_stores on top, # starved XCTest's app launch until it timed out (#560). Nothing these # jobs run searches with Spotlight. - name: Stop Spotlight indexing run: sudo mdutil -a -i off || true - name: Setup Pantry (provides Bun, Zig, etc.) uses: pantry-pm/pantry/packages/action@f6a85d762e728b7f91e3bebe700f08d0dc5ee5e0 # v0.11.214 with: version: '0.11.214' - name: Cache Zig artifacts uses: actions/cache@v5 with: path: | ~/.cache/zig packages/zig/.zig-cache key: mobile-e2e-slice-${{ runner.os }}-${{ hashFiles('packages/zig/build.zig') }} - name: First-party Zig dependencies uses: ./.github/actions/first-party-zig-deps # The script defaults CRAFT_ZIG to a pinned toolchain under # ~/.cache/craft-ci-local, which exists on the author's machine and not on # a runner. Point it at the one pantry provides. - name: Exercise the Zig runtime on a simulator id: harness # The fixture polls for its late markers against a wall-clock deadline. # A runner is several times slower than a laptop here — the first CI run # of this job reached marker 36 of 42 before the old iteration-count # budget ran out — so give it room. It exits as soon as the markers # arrive; the budget only matters when something is genuinely stuck. env: CRAFT_SLICE_TIMEOUT: '900' run: | CRAFT_ZIG="$(command -v zig)" \ packages/ios/fixtures/zig-slice/build-and-run.sh \ "$PWD/artifacts/mobile-e2e/ios-zig-slice" - name: Upload slice evidence if: always() && steps.harness.conclusion != 'skipped' uses: actions/upload-artifact@v4 with: name: mobile-e2e-ios-zig-slice path: | artifacts/mobile-e2e/ios-zig-slice/console.log artifacts/mobile-e2e/ios-zig-slice/console.plain artifacts/mobile-e2e/ios-zig-slice/app-stdout.log artifacts/mobile-e2e/ios-zig-slice/app-stderr.log artifacts/mobile-e2e/ios-zig-slice/failure.png artifacts/mobile-e2e/ios-zig-slice/failure-screenshot.log artifacts/mobile-e2e/ios-zig-slice/failure-location.log if-no-files-found: error retention-days: 30 android-navigation: strategy: fail-fast: false matrix: api-level: ${{ fromJSON((inputs.scope != 'android-navigation' || inputs.android_suite == 'full' || inputs.android_suite == 'teardown') && '[34,35]' || inputs.android_suite == 'system-bars' && '[35]' || '[34]') }} env: CRAFT_ANDROID_NATIVE_SUITE: ${{ inputs.scope != 'android-navigation' && 'full' || inputs.android_suite || 'focused' }} CRAFT_ANDROID_TEST_CLASS: ${{ inputs.scope == 'android-navigation' && inputs.android_suite == 'teardown' && 'dev.craft.navigationtest.NativeCapabilitiesTest,dev.craft.navigationtest.NativeNavigationTest#nativeTeardownRecordsSynchronousStorageBeforeReturning' || inputs.scope == 'android-navigation' && inputs.android_suite == 'capabilities' && 'dev.craft.navigationtest.NativeCapabilitiesTest' || inputs.scope == 'android-navigation' && inputs.android_suite == 'accessibility' && 'dev.craft.navigationtest.NativeNavigationTest#nativeTestIdsRemainQueryableWithoutReplacingVisibleLabels,dev.craft.navigationtest.NativeNavigationTest#spokenLanguageUpdatesNativeTextAndItsAccessibilityDescription,dev.craft.navigationtest.NativeNavigationTest#announcementEmitsSpeechWithoutMovingInputFocus' || inputs.scope == 'android-navigation' && inputs.android_suite == 'maps' && 'dev.craft.navigationtest.NativeMapTest#keyFreeBasemapsKeepTheRecordedRouteAndDirectionSignsVisible,dev.craft.navigationtest.NativeMapTest#nativeMapStrokeWidthsStayInLogicalPointsAcrossDensities,dev.craft.navigationtest.NativeMapTest#nativeMapMutationsUpdateThePinAndCameraWithoutReloadingTheStyle,dev.craft.navigationtest.NativeMapTest#showingTheLocationDotDoesNotRequestPermissionDuringRendering,dev.craft.navigationtest.NativeMapTest#controlledRegionEchoPreservesTheCameraAfterANativeDrag,dev.craft.navigationtest.NativeMapTest#backgroundAndResumeKeepTheNativeMapAndCamera' || inputs.scope == 'android-navigation' && inputs.android_suite == 'identity' && 'dev.craft.navigationtest.NativeNavigationTest#repeatedTestIdsKeepDistinctProtocolViewsAcrossReorders' || inputs.scope == 'android-navigation' && inputs.android_suite == 'system-bars' && 'dev.craft.navigationtest.NativeNavigationTest#nativeScreenBackgroundOptionAppliesAndResets,dev.craft.navigationtest.NativeNavigationTest#nativeStatusBarPropsUpdateWithoutNavigation,dev.craft.navigationtest.NativeNavigationTest#nativeStatusBarTracksLiveDeviceAppearance,dev.craft.navigationtest.NativeMutationTest#materializesTheCommittedRootWithoutAssumingItsProtocolId,dev.craft.navigationtest.NativeNavigationTest#compiledBundleRendersNavigatesAndRetainsNativeControls,dev.craft.navigationtest.NativeNavigationTest#safeAreaInsetsPreserveAuthoredPaddingWhenRetained' || inputs.scope == 'android-navigation' && inputs.android_suite != 'full' && 'dev.craft.navigationtest.NativeNavigationTest#nativeStatusBarPropsUpdateWithoutNavigation,dev.craft.navigationtest.NativeNavigationTest#nativeStatusBarTracksLiveDeviceAppearance,dev.craft.navigationtest.NativeMutationTest#materializesTheCommittedRootWithoutAssumingItsProtocolId,dev.craft.navigationtest.NativeNavigationTest#compiledBundleRendersNavigatesAndRetainsNativeControls,dev.craft.navigationtest.NativeNavigationTest#safeAreaInsetsPreserveAuthoredPaddingWhenRetained,dev.craft.navigationtest.NativeNavigationTest#outgoingTabTapWinsOverSettlingSwipe,dev.craft.navigationtest.NativeNavigationTest#thirdTabTapWinsOverSettlingSwipe,dev.craft.navigationtest.NativeNavigationTest#cancelledSwipeTargetIsVisibleWhenSelectedLater,dev.craft.navigationtest.NativeNavigationTest#completedReverseSwipeKeepsRetainedTabVisible,dev.craft.navigationtest.NativeNavigationTest#nativePullToRefreshSurvivesViewReattachment,dev.craft.navigationtest.NativeFlatListTest#refreshAppearanceUsesTheScreenContrastFallback,dev.craft.navigationtest.NativeNavigationTest#pushedScreenTabAccessoryOpensNativeRouteAndClearsOnBack,dev.craft.navigationtest.NativeNavigationTest#nativeDatePickerKeepsFollowingControlsMounted' || '' }} if: ${{ inputs.scope != 'ios-navigation' && inputs.scope != 'ios-render' && inputs.scope != 'ios-checkpoints' && inputs.scope != 'ios-hybrid' && inputs.scope != 'android-vulkan' && inputs.scope != 'android-checkpoints' }} runs-on: ubuntu-latest timeout-minutes: 35 steps: - uses: actions/checkout@v6 - uses: ./.github/actions/prepare-android-disk - uses: oven-sh/setup-bun@v2 with: bun-version: '1.4.3' - uses: actions/setup-java@v6 with: distribution: temurin java-version: '17' - uses: android-actions/setup-android@v4 with: packages: platform-tools - run: sdkmanager "platforms;android-36" "build-tools;36.0.0" - uses: gradle/actions/setup-gradle@v6 with: gradle-version: '8.11.1' - run: bun install --frozen-lockfile - uses: actions/checkout@v6 with: repository: stacksjs/stx ref: ${{ env.STX_COMPILER_VERSION }} path: .stx-compiler - run: bun install --frozen-lockfile working-directory: .stx-compiler - name: Compile native fixtures before booting Android id: native-project run: | mkdir -p artifacts/android-navigation STX_CLI="$GITHUB_WORKSPACE/.stx-compiler/packages/stx/bin/cli.ts" CRAFT_KEEP_ANDROID_NATIVE_PROJECT=1 TMPDIR="$GITHUB_WORKSPACE/artifacts/android-navigation" bun packages/android/scripts/test-native-navigation.ts --prepare-only bun --eval ' import { appendFileSync } from "node:fs"; import { dirname } from "node:path"; const configs = [...new Bun.Glob("**/NativeNavigation/craft.config.json").scanSync({ cwd: "artifacts/android-navigation", absolute: true })]; if (configs.length !== 1) throw new Error("Expected one generated native fixture project"); const project = dirname(configs[0]); const target = process.env.GITHUB_OUTPUT; if (!target) throw new Error("Missing workflow output file"); const build = Bun.spawnSync(["gradle", "--no-daemon", ":app:assembleDebug", ":app:assembleDebugAndroidTest"], { cwd: project, stdout: "inherit", stderr: "inherit" }); if (build.exitCode !== 0) throw new Error("Native fixture compilation failed"); appendFileSync(target, "project=" + project + "\n"); ' - name: Enable KVM run: | echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules sudo udevadm control --reload-rules sudo udevadm trigger --name-match=kvm - name: Run native acceptance on the SDK-owned emulator env: CRAFT_NATIVE_TEST_PROJECT: ${{ steps.native-project.outputs.project }} CRAFT_ANDROID_NATIVE_API: ${{ matrix.api-level }} run: bun scripts/run-native-android-acceptance.ts - name: Require the selected Android suite to pass without skips run: | python3 - <<'PY' from pathlib import Path import os import xml.etree.ElementTree as ET files = list(Path('artifacts/android-navigation').rglob('TEST-*.xml')) cases = [case for file in files for case in ET.parse(file).iter('testcase')] selection = os.environ.get('CRAFT_ANDROID_TEST_CLASS', '') suite = os.environ['CRAFT_ANDROID_NATIVE_SUITE'] if suite == 'full': expected = sum(path.read_text().count('@Test') for path in Path('packages/android/fixtures/native-navigation').glob('*.kt')) elif suite in ['capabilities', 'teardown']: expected = Path('packages/android/fixtures/native-navigation/NativeCapabilitiesTest.kt').read_text().count('@Test') + (1 if suite == 'teardown' else 0) else: expected = len([item for item in selection.split(',') if item.strip()]) assert expected > 0, 'The selected Android suite is empty' assert len(cases) == expected, f'Expected {expected} tests, got {len(cases)}' assert not any(case.find(tag) is not None for case in cases for tag in ['failure', 'error', 'skipped']) print(f'Passed {expected} Android native checks, zero skips') PY - uses: actions/upload-artifact@v4 if: always() with: name: android-navigation-recovery-api${{ matrix.api-level }} path: | artifacts/android-navigation/**/app/build/outputs/androidTest-results/** artifacts/android-navigation/emulator/** artifacts/android-navigation/failure-*.json artifacts/android-navigation/**/app/build/reports/androidTests/** artifacts/android-navigation/**/app/build/outputs/connected_android_test_additional_output/** artifacts/android-navigation/launcher-*.txt artifacts/android-navigation/launcher-*.xml artifacts/android-navigation/*.log if-no-files-found: error retention-days: 14 android-checkpoints: name: Android checkpoint process interruption if: ${{ inputs.scope == '' || inputs.scope == 'all' || inputs.scope == 'android' || inputs.scope == 'android-checkpoints' }} runs-on: ubuntu-latest timeout-minutes: 35 steps: - uses: actions/checkout@v6 - uses: ./.github/actions/prepare-android-disk - uses: oven-sh/setup-bun@v2 with: bun-version: '1.4.3' - uses: actions/setup-java@v6 with: distribution: temurin java-version: '17' - uses: android-actions/setup-android@v4 with: packages: platform-tools - name: Install checkpoint compile toolchain run: sdkmanager --sdk_root="$ANDROID_HOME" "ndk;27.2.12479018" "platforms;android-36" "build-tools;36.0.0" - uses: gradle/actions/setup-gradle@v6 with: gradle-version: '8.11.1' - run: bun install --frozen-lockfile - name: Enable owned emulator hardware CPU virtualization run: | echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules sudo udevadm control --reload-rules sudo udevadm trigger --name-match=kvm - name: Require controlled Android checkpoint interruption and recovery run: >- ANDROID_NDK_HOME="$ANDROID_HOME/ndk/27.2.12479018" bun packages/android/scripts/test-checkpoint-interruption.ts --output artifacts/mobile-e2e/android-checkpoints - name: Retain original Android checkpoint evidence on every result if: always() uses: actions/upload-artifact@v4 with: name: android-checkpoint-interruption path: artifacts/mobile-e2e/android-checkpoints if-no-files-found: error retention-days: 30 android-vulkan: name: Android native Vulkan surface if: ${{ inputs.scope == '' || inputs.scope == 'all' || inputs.scope == 'android' || inputs.scope == 'android-vulkan' }} runs-on: ubuntu-latest timeout-minutes: 35 steps: - uses: actions/checkout@v6 - uses: ./.github/actions/prepare-android-disk - name: Install the pinned native fixture toolchain uses: pantry-pm/pantry/packages/action@f6a85d762e728b7f91e3bebe700f08d0dc5ee5e0 # v0.11.214 with: version: '0.11.214' install: 'false' packages: bun.com@1.4.3 git-scm.org@2.56.0 ziglang.org@0.18.0-dev.146+35accc06e - uses: actions/setup-java@v6 with: distribution: temurin java-version: '17' - uses: android-actions/setup-android@v4 with: packages: platform-tools - name: Install the qualified NDK and Android compile platform run: sdkmanager --sdk_root="$ANDROID_HOME" "ndk;27.2.12479018" "platforms;android-35" "build-tools;35.0.0" - uses: gradle/actions/setup-gradle@v6 with: gradle-version: '8.11.1' - run: bun install --frozen-lockfile - uses: ./.github/actions/first-party-zig-deps - name: Enable owned emulator hardware CPU virtualization run: | echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules sudo udevadm control --reload-rules sudo udevadm trigger --name-match=kvm - name: Require actual software-Vulkan pixels and native lifecycle ownership run: >- ANDROID_NDK_HOME="$ANDROID_HOME/ndk/27.2.12479018" bun packages/android/scripts/test-vulkan-surface.ts --image 'system-images;android-35;google_apis;x86_64' --output artifacts/mobile-e2e/android-vulkan - name: Retain original Android Vulkan qualification and failure evidence if: always() uses: actions/upload-artifact@v4 with: name: android-native-vulkan-surface path: artifacts/mobile-e2e/android-vulkan if-no-files-found: error retention-days: 30 mobile-summary: name: Mobile E2E summary needs: [harness, ios-native, ios-metal, ios-hybrid, ios-simulator, android-emulator, ios-zig-slice, android-navigation, android-vulkan, android-checkpoints, media-cache] runs-on: ubuntu-latest # Hang guard, not a budget: 1 min was the slowest of the last six # successful runs. Without it the job takes GitHub's 360-minute default, and a # push to main does not cancel in progress, so one wedged job holds this # workflow's only running slot for six hours while every later push waits. timeout-minutes: 15 if: always() steps: - name: Report env: NATIVE_SELECTORS: ${{ inputs.scope == 'ios-checkpoints' && 'NativeRenderUnitTests/PersistentRecordingCheckpointUnitTests' || inputs.selectors }} run: | { echo "## Mobile E2E (${{ inputs.scope || 'all' }})" echo "Native XCTest selectors: ${NATIVE_SELECTORS:-all}" echo echo "| Leg | Result |" echo "|-----|--------|" echo "| Android checkpoint interruption | ${{ needs.android-checkpoints.result }} |" echo "| Android native Vulkan surface | ${{ needs.android-vulkan.result }} |" echo "| Android native navigation | ${{ needs.android-navigation.result }} |" echo "| Harness unit tests | ${{ needs.harness.result }} |" echo "| iOS native UIKit and navigation | ${{ needs.ios-native.result }} |" echo "| iOS native Metal surface | ${{ needs.ios-metal.result }} |" echo "| iOS hybrid navigation | ${{ needs.ios-hybrid.result }} |" echo "| iOS simulator (generated app) | ${{ needs.ios-simulator.result }} |" echo "| Android emulator (generated app) | ${{ needs.android-emulator.result }} |" echo "| iOS Zig runtime slice | ${{ needs.ios-zig-slice.result }} |" echo "| Native media storage and recovery | ${{ needs.media-cache.result }} |" } >> "$GITHUB_STEP_SUMMARY" # The summary job used to be the whole story, and it reported whatever it # was given without ever failing. `needs` does not fail a job on a failed # dependency when `if: always()` is set, so say it explicitly. # # `failure` and `skipped`, not `!= success`: with cancel-in-progress on, # pushing twice in quick succession cancels the first run, and treating # `cancelled` as a failure would put a red X on it — a signal about # nothing, which is how the workflow this replaces earned its reputation. - name: Fail if any leg failed if: >- contains(fromJSON('["failure", "skipped"]'), needs.harness.result) || ((inputs.scope == '' || inputs.scope == 'all' || inputs.scope == 'android' || inputs.scope == 'android-checkpoints') && contains(fromJSON('["failure", "skipped"]'), needs.android-checkpoints.result)) || ((inputs.scope == '' || inputs.scope == 'all' || inputs.scope == 'android' || inputs.scope == 'android-vulkan') && contains(fromJSON('["failure", "skipped"]'), needs.android-vulkan.result)) || (inputs.scope != 'android-vulkan' && inputs.scope != 'android-checkpoints' && inputs.scope != 'ios-hybrid' && inputs.scope != 'ios-navigation' && inputs.scope != 'ios-render' && inputs.scope != 'ios-checkpoints' && contains(fromJSON('["failure", "skipped"]'), needs.android-navigation.result)) || (inputs.scope != 'android-vulkan' && inputs.scope != 'android-checkpoints' && inputs.scope != 'ios-hybrid' && inputs.scope != 'android-navigation' && inputs.scope != 'android' && contains(fromJSON('["failure", "skipped"]'), needs.ios-native.result)) || (inputs.scope == 'android' && contains(fromJSON('["failure", "skipped"]'), needs.android-emulator.result)) || (inputs.scope == 'ios-hybrid' && contains(fromJSON('["failure", "skipped"]'), needs.ios-hybrid.result)) || (inputs.scope != 'android-vulkan' && inputs.scope != 'android-checkpoints' && inputs.scope != 'ios-checkpoints' && inputs.scope != 'ios-hybrid' && inputs.scope != 'ios-navigation' && inputs.scope != 'android-navigation' && inputs.scope != 'android' && contains(fromJSON('["failure", "skipped"]'), needs.ios-metal.result)) || (inputs.scope != 'android-vulkan' && inputs.scope != 'android-checkpoints' && inputs.scope != 'ios-hybrid' && inputs.scope != 'ios-navigation' && inputs.scope != 'android-navigation' && inputs.scope != 'ios-render' && inputs.scope != 'ios-checkpoints' && inputs.scope != 'android' && ( contains(fromJSON('["failure", "skipped"]'), needs.ios-simulator.result) || contains(fromJSON('["failure", "skipped"]'), needs.ios-hybrid.result) || contains(fromJSON('["failure", "skipped"]'), needs.android-emulator.result) || contains(fromJSON('["failure", "skipped"]'), needs.ios-zig-slice.result) || contains(fromJSON('["failure", "skipped"]'), needs.media-cache.result) )) run: | echo "::error::at least one mobile E2E leg did not succeed" exit 1