test android #22
This file contains 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: Main | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: ["**"] | |
merge_group: | |
types: [checks_requested] | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
android-test: | |
name: ${{ format('{0} {1}', matrix.platform.target, matrix.features)}} | |
runs-on: ubuntu-24.04 | |
env: | |
RUST_BACKTRACE: 1 | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- { target: aarch64-linux-android, arch: arm64-v8a } | |
- { target: x86_64-linux-android, arch: x86_64 } | |
features: | |
[ | |
"", | |
"chains sm-raw-window-handle-06", | |
"chains sm-raw-window-handle-05", | |
] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: "17" | |
distribution: "temurin" | |
- name: Setup Android SDK | |
uses: android-actions/setup-android@v3 | |
with: | |
packages: "tools platform-tools platforms;android-33" | |
- name: Install Android NDK | |
uses: nttld/setup-ndk@v1 | |
id: setup-ndk | |
with: | |
ndk-version: r26c | |
- name: Install rust | |
id: toolchain | |
uses: dtolnay/rust-toolchain@1.81.0 | |
with: | |
targets: ${{ matrix.platform.target }} | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-dinghy | |
- 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@v4 | |
id: avd-cache | |
with: | |
path: | | |
~/.android/avd/* | |
~/.android/adb* | |
key: avd-30-${{ github.workflow }}-${{ github.job }}-${{ runner.os }}-${{runner.arch}} | |
- name: Create directory for avd | |
# This shouldn't be necesary but this is a work around for | |
# https://github.com/ReactiveCircus/android-emulator-runner/issues/197 | |
if: steps.avd-cache.outputs.cache-hit != 'true' | |
run: mkdir -p ~/.android/avd | |
- name: Create AVD and generate snapshot for caching | |
if: steps.avd-cache.outputs.cache-hit != 'true' | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: 30 | |
ndk: ${{ steps.setup-ndk.outputs.ndk-full-version }} | |
force-avd-creation: false | |
arch: ${{ matrix.platform.arch }} | |
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: false | |
script: echo "Generated AVD snapshot for caching." | |
- name: Run tests in android emulator | |
uses: reactivecircus/android-emulator-runner@v2 | |
env: | |
RANLIB: "${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib" | |
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} | |
with: | |
api-level: 30 | |
ndk: ${{ steps.setup-ndk.outputs.ndk-full-version }} | |
arch: ${{ matrix.platform.arch }} | |
force-avd-creation: false | |
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: true | |
script: | | |
cargo dinghy all-platforms | |
cargo dinghy all-devices | |
cargo dinghy -p auto-android-${{ matrix.platform.arch }}-api30 test --features "${{ matrix.features }}" -- --test-threads 1 | |
Format: | |
name: Run `rustfmt` | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: mkroening/rust-toolchain-toml@main | |
- run: cargo fmt --check | |
build_result: | |
name: Result | |
runs-on: ubuntu-24.04 | |
needs: ["android-test", "Format"] | |
if: always() | |
steps: | |
- name: Mark the job as successful | |
if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }} | |
run: exit 0 | |
- name: Mark the job as unsuccessful | |
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') | |
run: exit 1 |