Skip to content

Commit

Permalink
Add aarch64-android testing to CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
afranchuk committed Apr 11, 2024
1 parent 6278f4a commit 97217a7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
11 changes: 8 additions & 3 deletions .cargo/android-runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
BINARY=$1
shift

# When pushing a bin, the full target dir is appended (including the target
# triple). There's no need for this, so strip it away. This simplifies the
# `TEST_HELPER` definition across multiple architectures.
REMOTE_BINARY="/data/local/$(basename $BINARY)"

# Make sure to run the following to copy the test helper binary over.
# cargo run --target x86_64-linux-android --bin test
adb push "$BINARY" "/data/local/$BINARY"
adb shell "chmod 777 /data/local/$BINARY && env TEST_HELPER=/data/local/target/x86_64-linux-android/debug/test /data/local/$BINARY" "$@"
# cargo run --target ANDROID-TARGET --bin test
adb push $BINARY $REMOTE_BINARY
adb shell "chmod 777 $REMOTE_BINARY && env TEST_HELPER=/data/local/test $REMOTE_BINARY" "$@"
4 changes: 4 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@
[target.x86_64-linux-android]
linker = "x86_64-linux-android30-clang"
runner = [".cargo/android-runner.sh"]

[target.aarch64-linux-android]
linker = "aarch64-linux-android30-clang"
runner = [".cargo/android-runner.sh"]
16 changes: 11 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,21 @@ jobs:
# interacts with this job.
test-android:
name: Test android
runs-on: ubuntu-latest
runs-on: ${{ matrix.job.on }}
strategy:
matrix:
job:
- { target: x86_64-linux-android, arch: x86_64, on: ubuntu-latest }
- { target: aarch64-linux-android, arch: arm64-v8a, on: macos-14 }
env:
ANDROID_HOME: /usr/local/lib/android/sdk
CARGO_BUILD_TARGET: ${{ matrix.job.target }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
target: x86_64-linux-android
target: ${{ matrix.job.target }}
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
Expand All @@ -127,16 +133,16 @@ jobs:
- name: Build/run tests in android emulator
uses: reactivecircus/android-emulator-runner@v2
with:
arch: x86_64
arch: ${{ matrix.job.arch }}
api-level: 30
ndk: 26.2.11394342
script: |
# run adb as root so we can create remote directories
adb root
# Copy test helper binary over as a side-effect of running it.
cargo run --target x86_64-linux-android --bin test -- nop
cargo run --bin test -- nop
# Build and run tests
cargo test --target x86_64-linux-android
cargo test
deny-check:
runs-on: ubuntu-22.04
Expand Down

0 comments on commit 97217a7

Please sign in to comment.