Skip to content

wip: run tests on android emulator #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Android Test
on:
merge_group:
branches:
- main
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
android-arch:
- ndk-name: arm64-v8a
cargo-target: aarch64-linux-android
- ndk-name: x86_64
cargo-target: x86_64-linux-android
android-api-level: [29]
android-ndk-version: ["26.0.10792818"]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Go Toolchain
uses: actions/setup-go@v5
with:
go-version: '=1.20.0'

- name: Rust Toolchain
run: |
rustup toolchain install 1.81.0 --profile minimal --no-self-update
rustup target add ${{ matrix.android-arch.cargo-target }}
cargo install cargo-dinghy

- name: Build Tests
run: |
mkdir output-test-executables
cargo dinghy test -p holochain-conductor-runtime --no-run --target ${ANDROID_ARCH}-linux-android -- --out-dir /output-test-executables

- name: Rust Cache
uses: Swatinem/rust-cache@v2

- 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@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.android-api-level }}

- name: Avd Snapshot
if: steps.avd-cache.outputs.cache-hit != 'true'
env:
ANDROID_API_LEVEL: ${{ matrix.android-api-level }}
ANDROID_NDK_VERSION: ${{ matrix.android-ndk-version }}
ANDROID_ARCH: ${{ matrix.android-arch.ndk-name }}
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.android-api-level }}
ndk: ${{ matrix.android-ndk-version }}
arch: ${{ matrix.android-arch.ndk-name }}
target: google_apis
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
env:
ANDROID_API_LEVEL: ${{ matrix.android-api-level }}
ANDROID_NDK_VERSION: ${{ matrix.android-ndk-version }}
ANDROID_ARCH: ${{ matrix.android-arch.ndk-name }}
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.android-api-level }}
ndk: ${{ matrix.android-ndk-version }}
arch: ${{ matrix.android-arch.ndk-name }}
target: google_apis
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: |
for i in $(cat output-test-executables); do
adb push $i /data/local/tmp/$(basename $i)
adb shell chmod 500 /data/local/tmp/$(basename $i)
adb shell RUST_LOG=error RUST_BACKTRACE=1 /data/local/tmp/$(basename $i) --test-threads 1 --nocapture
adb shell rm -f /data/local/tmp/$(basename $i)
done


Loading