Skip to content

Commit

Permalink
Run build-artifacts from Ubuntu and Windows in the emulator (#169)
Browse files Browse the repository at this point in the history
* CI: Migrate emulator step to rust "run", for artifact sharing

* Run build-artifacts from Ubuntu and Windows in the emulator

* CI: Tee emulator logcat so that (filtered) output is visible directly

Without having to download the artifact.  Output is limited to errors
and app-specific output anyway.

* CI: Test `cargo apk run` with the emulator again
  • Loading branch information
MarijnS95 authored Aug 8, 2021
1 parent 070fdbc commit b665be0
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 31 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/android_test.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
#!/bin/bash

set -e
set -ex

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

if [ -z "$1" ];
then
cargo apk run -p ndk-examples --target x86_64-linux-android --example hello_world
else
adb install -r "$1/hello_world.apk"
adb shell am start -a android.intent.action.MAIN -n "rust.example.hello_world/android.app.NativeActivity"
fi

sleep 30s

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

if grep 'hello world' ~/logcat.log;
then
Expand Down
25 changes: 0 additions & 25 deletions .github/workflows/emulator.yml

This file was deleted.

49 changes: 49 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ jobs:
- os: windows-latest
rust-channel: 'stable'
rust-target: 'aarch64-linux-android'
- os: windows-latest
rust-channel: 'stable'
rust-target: 'x86_64-linux-android'

runs-on: ${{ matrix.os }}
name: Build apk
Expand All @@ -75,6 +78,52 @@ jobs:
- name: Cargo apk build for target ${{ matrix.rust-target }}
run: cargo apk build -p ndk-examples --target ${{ matrix.rust-target }} --examples

- uses: actions/upload-artifact@v2
# Only need this for CI, unless users are interested in downloading
# a ready-made app that does nothing but printing "hello world".
if: ${{ matrix.rust-target == 'x86_64-linux-android' }}
name: Upload hello_world apk
with:
name: hello_world_${{ matrix.os }}_${{ matrix.rust-target }}
path: ./target/debug/apk/examples/hello_world.apk

android_emulator:
name: hello_world example on emulator
needs: build
runs-on: macos-latest
strategy:
matrix:
source_os: [ubuntu-latest, windows-latest, local]
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/download-artifact@v2
name: Download hello_world APK
if: ${{ matrix.source_os != 'local' }}
id: download
with:
name: hello_world_${{ matrix.source_os }}_x86_64-linux-android
- name: Install `cargo-apk` and add `x86_64-linux-android` target
if: ${{ matrix.source_os == 'local' }}
run: |
cargo install --path cargo-apk
rustup target add x86_64-linux-android
- name: Start hello_world example
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: ./.github/workflows/android_test.sh "${{ steps.download.outputs.download-path }}"
- name: Upload emulator logs
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: log
path: ~/logcat.log

build-host:
strategy:
fail-fast: false
Expand Down

0 comments on commit b665be0

Please sign in to comment.