|
| 1 | +# Copyright 2019-2024 Tauri Programme within The Commons Conservancy |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | +# SPDX-License-Identifier: MIT |
| 4 | + |
| 5 | +name: test `@tauri-apps/api` e2e (mobile) |
| 6 | + |
| 7 | +on: |
| 8 | + workflow_dispatch: |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - dev |
| 12 | + pull_request: |
| 13 | + paths: |
| 14 | + - '.github/workflows/test-api-e2e-mobile.yml' |
| 15 | + - 'packages/api/**' |
| 16 | + - 'packages/api-e2e/**' |
| 17 | + - 'examples/api/**' |
| 18 | + - 'crates/tauri/mobile/**' |
| 19 | + - 'crates/tauri-cli/templates/mobile/**' |
| 20 | + |
| 21 | +env: |
| 22 | + RUST_BACKTRACE: 1 |
| 23 | + CARGO_PROFILE_DEV_DEBUG: 0 # keeps the target folder small for better cache efficiency |
| 24 | + |
| 25 | +concurrency: |
| 26 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 27 | + cancel-in-progress: true |
| 28 | + |
| 29 | +permissions: |
| 30 | + contents: read |
| 31 | + |
| 32 | +jobs: |
| 33 | + android: |
| 34 | + runs-on: ubuntu-latest |
| 35 | + env: |
| 36 | + # The emulator runs the host architecture, so only that target is built. |
| 37 | + E2E_ANDROID_TARGET: x86_64 |
| 38 | + |
| 39 | + steps: |
| 40 | + - uses: actions/checkout@v7 |
| 41 | + |
| 42 | + - name: install Rust stable |
| 43 | + uses: dtolnay/rust-toolchain@stable |
| 44 | + with: |
| 45 | + targets: x86_64-linux-android |
| 46 | + |
| 47 | + - run: npm i -g --force corepack |
| 48 | + - name: setup node |
| 49 | + uses: actions/setup-node@v7 |
| 50 | + with: |
| 51 | + node-version: 'lts/*' |
| 52 | + cache: 'pnpm' |
| 53 | + |
| 54 | + - uses: actions/setup-java@v5 |
| 55 | + with: |
| 56 | + distribution: temurin |
| 57 | + java-version: 25 |
| 58 | + cache: gradle |
| 59 | + |
| 60 | + - name: Setup NDK |
| 61 | + uses: nttld/setup-ndk@v1 |
| 62 | + id: setup-ndk |
| 63 | + with: |
| 64 | + ndk-version: r29 |
| 65 | + local-cache: true |
| 66 | + |
| 67 | + # TODO check after https://github.com/nttld/setup-ndk/issues/518 is fixed |
| 68 | + - name: Restore Android Symlinks |
| 69 | + run: | |
| 70 | + directory="${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin" |
| 71 | + find "$directory" -type l | while read link; do |
| 72 | + current_target=$(readlink "$link") |
| 73 | + new_target="$directory/$(basename "$current_target")" |
| 74 | + ln -sf "$new_target" "$link" |
| 75 | + echo "Changed $(basename "$link") from $current_target to $new_target" |
| 76 | + done |
| 77 | +
|
| 78 | + # Hardware acceleration for the emulator. |
| 79 | + - name: enable KVM |
| 80 | + run: | |
| 81 | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules |
| 82 | + sudo udevadm control --reload-rules |
| 83 | + sudo udevadm trigger --name-match=kvm |
| 84 | +
|
| 85 | + - uses: Swatinem/rust-cache@v2 |
| 86 | + with: |
| 87 | + key: android |
| 88 | + |
| 89 | + - name: install dependencies |
| 90 | + run: pnpm i --frozen-lockfile |
| 91 | + |
| 92 | + - name: build @tauri-apps/api |
| 93 | + run: pnpm build:api |
| 94 | + |
| 95 | + - name: build @tauri-apps/cli |
| 96 | + run: pnpm build:cli |
| 97 | + |
| 98 | + # Built before the emulator is up so it does not sit idle (and time out) |
| 99 | + # during the Rust and Gradle builds; the suite then reuses the APK. |
| 100 | + - name: build the APK |
| 101 | + working-directory: ./examples/api |
| 102 | + env: |
| 103 | + NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} |
| 104 | + run: | |
| 105 | + pnpm tauri android init --ci --skip-targets-install |
| 106 | + pnpm tauri android build --debug --apk --target $E2E_ANDROID_TARGET |
| 107 | +
|
| 108 | + - name: run e2e tests |
| 109 | + uses: reactivecircus/android-emulator-runner@v2 |
| 110 | + timeout-minutes: 60 |
| 111 | + with: |
| 112 | + api-level: 35 |
| 113 | + arch: x86_64 |
| 114 | + # google_apis images ship an up-to-date Android System WebView. |
| 115 | + target: google_apis |
| 116 | + profile: pixel_6 |
| 117 | + emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none |
| 118 | + disable-animations: true |
| 119 | + script: E2E_SKIP_BUILD=1 E2E_SPEC_RETRIES=1 pnpm test:api-e2e:android |
| 120 | + |
| 121 | + - name: upload appium logs |
| 122 | + if: failure() |
| 123 | + uses: actions/upload-artifact@v7 |
| 124 | + with: |
| 125 | + name: android-appium-logs |
| 126 | + path: packages/api-e2e/logs |
| 127 | + if-no-files-found: ignore |
| 128 | + |
| 129 | + ios: |
| 130 | + runs-on: macos-latest |
| 131 | + |
| 132 | + steps: |
| 133 | + - uses: actions/checkout@v7 |
| 134 | + |
| 135 | + - name: install Rust stable |
| 136 | + uses: dtolnay/rust-toolchain@stable |
| 137 | + with: |
| 138 | + targets: aarch64-apple-ios-sim |
| 139 | + |
| 140 | + - run: npm i -g --force corepack |
| 141 | + - name: setup node |
| 142 | + uses: actions/setup-node@v7 |
| 143 | + with: |
| 144 | + node-version: 'lts/*' |
| 145 | + cache: 'pnpm' |
| 146 | + |
| 147 | + - uses: Swatinem/rust-cache@v2 |
| 148 | + with: |
| 149 | + key: ios |
| 150 | + |
| 151 | + - name: install dependencies |
| 152 | + run: pnpm i --frozen-lockfile |
| 153 | + |
| 154 | + - name: build @tauri-apps/api |
| 155 | + run: pnpm build:api |
| 156 | + |
| 157 | + - name: build @tauri-apps/cli |
| 158 | + run: pnpm build:cli |
| 159 | + |
| 160 | + # Simulator build (`aarch64-sim` on the Apple Silicon runners), unsigned. |
| 161 | + # Built ahead of the suite for symmetry with the Android job. |
| 162 | + - name: build the simulator app |
| 163 | + working-directory: ./examples/api |
| 164 | + run: | |
| 165 | + pnpm tauri ios init --ci --skip-targets-install |
| 166 | + pnpm tauri ios build --debug --target aarch64-sim --no-sign |
| 167 | +
|
| 168 | + # wdio.ios.conf picks the iPhone simulator on the newest installed runtime |
| 169 | + # (no device name is hardcoded) and Appium boots it; the XCUITest driver |
| 170 | + # compiles WebDriverAgent on the first session. |
| 171 | + - name: run e2e tests |
| 172 | + timeout-minutes: 60 |
| 173 | + env: |
| 174 | + E2E_SKIP_BUILD: '1' |
| 175 | + E2E_SPEC_RETRIES: '1' |
| 176 | + run: pnpm test:api-e2e:ios |
| 177 | + |
| 178 | + - name: upload appium logs |
| 179 | + if: failure() |
| 180 | + uses: actions/upload-artifact@v7 |
| 181 | + with: |
| 182 | + name: ios-appium-logs |
| 183 | + path: packages/api-e2e/logs |
| 184 | + if-no-files-found: ignore |
| 185 | + |
| 186 | + - name: collect app crash reports |
| 187 | + if: failure() |
| 188 | + run: .scripts/ci/collect-macos-crash-reports.sh "$RUNNER_TEMP/crash-reports" |
| 189 | + |
| 190 | + - name: upload app crash reports |
| 191 | + if: failure() |
| 192 | + uses: actions/upload-artifact@v7 |
| 193 | + with: |
| 194 | + name: ios-crash-reports |
| 195 | + path: ${{ runner.temp }}/crash-reports |
| 196 | + if-no-files-found: ignore |
0 commit comments