Skip to content
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

Test hello-world example with Android Emulator on CI #133

Merged
merged 1 commit into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
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
29 changes: 29 additions & 0 deletions .github/workflows/android_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

set -e

rustup target install x86_64-linux-android
cargo install --path "$GITHUB_WORKSPACE/cargo-apk" --force
cd "$GITHUB_WORKSPACE/ndk-examples"
cargo apk run --example hello_world --target x86_64-linux-android

sleep 30s

adb logcat *:E hello-world:V -d > ~/logcat.log

if grep 'hello world' ~/logcat.log;
then
echo "App running"
else
echo "::error::App not running"
exit 1
fi

ERROR_MSG=$(grep -e 'thread.*panicked at' "$HOME"/logcat.log | true)
if [ -z "${ERROR_MSG}" ];
then
exit 0
else
echo "::error::${ERROR_MSG}"
exit 1
fi
25 changes: 25 additions & 0 deletions .github/workflows/emulator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Android Emulator

on: [push, pull_request]

jobs:
android_emulator:
runs-on: macos-10.15
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
arch: x86_64
# the `googleapis` emulator target is considerably slower on CI.
target: default
profile: Nexus 5X
script: bash ./.github/workflows/android_test.sh
- uses: actions/upload-artifact@master
if: ${{ always() }}
with:
name: log
path: |
~/logcat.log
4 changes: 4 additions & 0 deletions ndk-examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ crate-type = ["cdylib"]
[[example]]
name = "jni_audio"
crate-type = ["cdylib"]

[package.metadata.android.sdk]
min_sdk_version = 16
target_sdk_version = 29