name: Android
on:
push:
branches-ignore: [ '**win**', '**linux**', '**macos**', '**bsd**', '**haiku**', '**wasm**', '**ios**' ]
pull_request:
branches: [ master ]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
CARGO_APK_VERSION: '0.8.2'
jobs:
build:
name: Build
runs-on: macos-latest
strategy:
matrix:
rust: [stable ]
api-level: [ 29 ]
ndk-version: [ '22.1.7171670' ]
cmake-version: [ '3.18.1' ]
continue-on-error: ${{ matrix.rust != 'stable' }}
steps:
- uses: actions/checkout@v2
name: Checkout
- uses: actions-rs/toolchain@v1
name: Install Rust Toolchain
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: i686-linux-android
override: true
components: rustfmt, clippy
- uses: actions/cache@v2
name: Fetch cargo-apk from cache
id: cargo-apk-cache
with:
path: ~/.cargo/bin/cargo-apk
key: cargo-apk-${{ env.CARGO_APK_VERSION }}
- name: Install cargo-apk
if: steps.cargo-apk-cache.outputs.cache-hit != 'true'
uses: actions-rs/install@v0.1
with:
crate: cargo-apk
version: ${{ env.CARGO_APK_VERSION }}
use-tool-cache: false
- uses: actions-rs/cargo@v1
name: Compile
with:
command: build
- name: AVD cache
uses: actions/cache@v2
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}
- name: Create AVD
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
force-avd-creation: false
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
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
ndk: ${{ matrix.ndk-version }}
cmake: ${{ matrix.cmake-version }}
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: bash -c 'ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/${{ matrix.ndk-version }} cargo test --test test_android -- --ignored'
- uses: actions-rs/cargo@v1
name: Check Code Formatting
with:
command: fmt
args: --all -- --check
- uses: actions-rs/cargo@v1
name: Lints
with:
command: clippy
args: --all-targets -- -D warnings