From 14be2920c75337e0145a40a364099253c21cdd54 Mon Sep 17 00:00:00 2001 From: Max Inden Date: Thu, 1 Aug 2024 08:37:06 +0200 Subject: [PATCH] chore(.github): add android workflow --- .github/workflows/android.yml | 65 +++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/android.yml diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml new file mode 100644 index 0000000000..3037cc873e --- /dev/null +++ b/.github/workflows/android.yml @@ -0,0 +1,65 @@ +name: CI + +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-latest + + env: + ANDROID_SDK_ROOT: ${{ github.workspace }}/android-sdk + ANDROID_NDK_HOME: ${{ github.workspace }}/android-ndk + ANDROID_HOME: ${{ github.workspace }}/android-sdk + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up JDK + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '11' + + - name: Set up Android SDK + uses: android-actions/setup-android@v2 + with: + api-level: 30 + build-tools: 30.0.3 + ndk: 21.3.6528147 + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + components: rustfmt, clippy + + - name: Add Android targets + run: rustup target add aarch64-linux-android + + - name: Install cargo-ndk + run: cargo install cargo-ndk + + - name: Install cargo-mobile + run: cargo install --git https://github.com/BrainiumLLC/cargo-mobile + + - name: Build unit tests for Android + run: cargo ndk -t aarch64-linux-android test --no-run + + - name: Set up Android Emulator + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 30 + target: default + arch: x86_64 + profile: Nexus 6 + emulator-options: "-no-window -no-audio" + + - name: Run Tests on Android + run: | + for test in $(find target/aarch64-linux-android/debug/deps/ -type f -executable -name '*-*'); do + adb push "$test" /data/local/tmp/ + adb shell chmod +x /data/local/tmp/$(basename "$test") + adb shell /data/local/tmp/$(basename "$test") + done