|
11 | 11 | CARGO_TARGET_WASM32_WASIP2_RUNNER: "/home/runner/.wasmtime/bin/wasmtime --dir /tmp/" |
12 | 12 | RUSTFLAGS: "-D warnings" |
13 | 13 | RUSTDOCFLAGS: "-D warnings" |
| 14 | + NDK_VERSION: "r26d" |
| 15 | + ANDROID_VERSION: "12.0.0" |
14 | 16 |
|
15 | 17 | name: CI |
16 | 18 | jobs: |
|
44 | 46 | - name: "MacOS" |
45 | 47 | os: macos-latest |
46 | 48 | target: aarch64-apple-darwin |
| 49 | + - name: "Android" |
| 50 | + os: ubuntu-latest |
| 51 | + target: x86_64-linux-android |
| 52 | + exclude: |
| 53 | + - rust-version: "1.63" |
| 54 | + platform: |
| 55 | + name: "Android" |
| 56 | + os: ubuntu-latest |
| 57 | + target: x86_64-linux-android |
47 | 58 | include: |
48 | 59 | - rust-version: "nightly" |
49 | 60 | test-flags: --tests |
@@ -75,10 +86,50 @@ jobs: |
75 | 86 | - name: Install Wasmtime |
76 | 87 | if: ${{ startsWith(matrix.platform.target, 'wasm32-wasi') }} |
77 | 88 | run: curl https://wasmtime.dev/install.sh -sSf | bash |
| 89 | + - name: Setup Android Environment |
| 90 | + if: ${{ contains(matrix.platform.target, 'android') }} |
| 91 | + run: | |
| 92 | + NDK_URL="https://dl.google.com/android/repository/android-ndk-${NDK_VERSION}-linux.zip" |
| 93 | + NDK_DIR="${HOME}/android-ndk-${NDK_VERSION}" |
| 94 | +
|
| 95 | + # Download and extract NDK |
| 96 | + echo "Downloading NDK from $NDK_URL" |
| 97 | + wget -q "$NDK_URL" -O android-ndk.zip |
| 98 | + unzip -q android-ndk.zip -d "$HOME" |
| 99 | +
|
| 100 | + # Set ANDROID_NDK_ROOT environment variable |
| 101 | + echo "ANDROID_NDK_ROOT=$NDK_DIR" >> $GITHUB_ENV |
| 102 | +
|
| 103 | + # Setup & start redroid container |
| 104 | + sudo apt-get install -y linux-modules-extra-$(uname -r) android-tools-adb |
| 105 | + sudo modprobe binder_linux devices=binder,hwbinder,vndbinder |
| 106 | +
|
| 107 | + docker run -itd --rm --privileged \ |
| 108 | + --mount "type=bind,src=$(pwd),dst=/data/host$(pwd),ro" \ |
| 109 | + --mount "type=bind,src=/tmp,dst=/data/host/tmp,ro" \ |
| 110 | + --mount "type=bind,src=$(pwd)/.github/workflows/run-on-host.sh,dst=/system/xbin/run-on-host,ro" \ |
| 111 | + --name redroid-test \ |
| 112 | + -p 5555:5555 \ |
| 113 | + redroid/redroid:${ANDROID_VERSION}_64only-latest |
| 114 | +
|
| 115 | + # Start ADB server and connect to our redroid container |
| 116 | + adb start-server |
| 117 | + timeout 60 bash -c 'until adb connect localhost:5555; do sleep 2; done' |
| 118 | +
|
| 119 | + # Configure Android environment |
| 120 | + echo "CARGO_TARGET_X86_64_LINUX_ANDROID_RUNNER=adb -s localhost:5555 shell run-on-host" >> $GITHUB_ENV |
| 121 | + echo "CC_X86_64_linux_android=$NDK_DIR/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android34-clang" >> $GITHUB_ENV |
| 122 | + echo "AR_x86_64_linux_android=$NDK_DIR/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" >> $GITHUB_ENV |
| 123 | + echo "CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=$NDK_DIR/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android34-clang" >> $GITHUB_ENV |
| 124 | + echo "CARGO_TARGET_AARCH64_LINUX_ANDROID_RUSTFLAGS=-C link-arg=-Wl,--as-needed" >> $GITHUB_ENV |
78 | 125 | - name: Build |
79 | 126 | run: cargo build --target ${{ matrix.platform.target }} ${{ matrix.rust-version == 'nightly' && '--features nightly' || '' }} |
80 | 127 | - name: Test |
81 | 128 | run: cargo test --target ${{ matrix.platform.target }} ${{ matrix.rust-version == 'nightly' && '--features nightly' || '' }} ${{ matrix.test-flags }} |
| 129 | + - name: Stop the redroid container |
| 130 | + if: ${{ contains(matrix.platform.target, 'android') }} |
| 131 | + run: | |
| 132 | + docker stop redroid-test || true |
82 | 133 | wasm: |
83 | 134 | name: WASM Test Build |
84 | 135 | runs-on: ubuntu-latest |
|
0 commit comments