Skip to content

Commit 76f6eb8

Browse files
committed
test android
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
1 parent 55a3680 commit 76f6eb8

File tree

1 file changed

+56
-53
lines changed

1 file changed

+56
-53
lines changed

.github/workflows/main.yml

+56-53
Original file line numberDiff line numberDiff line change
@@ -12,66 +12,35 @@ env:
1212
CARGO_TERM_COLOR: always
1313

1414
jobs:
15-
Build:
15+
android-test:
1616
name: ${{ format('{0} {1}', matrix.platform.target, matrix.features)}}
17-
runs-on: ${{ matrix.platform.os }}
17+
runs-on: ubuntu-24.04
1818
env:
1919
RUST_BACKTRACE: 1
2020
strategy:
2121
fail-fast: false
2222
matrix:
2323
platform:
24-
#- { target: aarch64-apple-darwin, os: macos-14, test: true }
25-
#- { target: x86_64-apple-darwin, os: macos-13, test: true }
26-
#- { target: x86_64-unknown-linux-gnu, os: ubuntu-24.04, test: true }
27-
#- { target: x86_64-pc-windows-msvc, os: windows-latest, test: true }
28-
#- { target: i686-pc-windows-msvc, os: windows-latest, test: false }
29-
#- { target: aarch64-pc-windows-msvc, os: windows-latest, test: false }
30-
#- {
31-
# target: aarch64-unknown-linux-ohos,
32-
# os: ubuntu-24.04,
33-
# test: false,
34-
# }
35-
- { target: arm-linux-androideabi, os: ubuntu-24.04, test: true }
36-
- { target: aarch64-linux-android, os: ubuntu-24.04, test: true }
37-
- { target: armv7-linux-androideabi, os: ubuntu-24.04, test: true }
38-
- { target: x86_64-linux-android, os: ubuntu-24.04, test: true }
24+
- { target: aarch64-linux-android, arch: arm64-v8a }
25+
- { target: x86_64-linux-android, arch: x86_64 }
3926
features:
4027
[
4128
"",
4229
"chains sm-raw-window-handle-06",
4330
"chains sm-raw-window-handle-05",
4431
]
45-
#include:
46-
#- features: "sm-x11 sm-wayland-default"
47-
# platform:
48-
# { target: x86_64-unknown-linux-gnu, os: ubuntu-24.04, test: true }
49-
#- features: "chains sm-angle-builtin"
50-
# platform:
51-
# { target: x86_64-pc-windows-msvc, os: windows-latest, test: true }
52-
#- features: "chains sm-no-wgl sm-angle-builtin"
53-
# platform:
54-
# { target: x86_64-pc-windows-msvc, os: windows-latest, test: true }
5532
steps:
5633
- uses: actions/checkout@v4
57-
- name: Install dependencies (Linux)
58-
if: startsWith(matrix.platform.os, 'ubuntu')
59-
run: |
60-
sudo apt update
61-
sudo apt install gcc libxxf86vm-dev libosmesa6-dev libgles2-mesa-dev xvfb weston -y
6234
- name: Set up JDK 17
63-
if: ${{ contains(matrix.platform.target, 'android') }}
6435
uses: actions/setup-java@v4
6536
with:
6637
java-version: "17"
6738
distribution: "temurin"
6839
- name: Setup Android SDK
69-
if: ${{ contains(matrix.platform.target, 'android') }}
7040
uses: android-actions/setup-android@v3
7141
with:
7242
packages: "tools platform-tools platforms;android-33"
7343
- name: Install Android NDK
74-
if: ${{ contains(matrix.platform.target, 'android') }}
7544
uses: nttld/setup-ndk@v1
7645
id: setup-ndk
7746
with:
@@ -81,26 +50,60 @@ jobs:
8150
uses: dtolnay/rust-toolchain@1.81.0
8251
with:
8352
targets: ${{ matrix.platform.target }}
84-
- name: Build
85-
run: |
86-
cargo build --features "${{ matrix.features }}" --target ${{ matrix.platform.target }}
87-
- name: Test
88-
if: ${{ matrix.platform.test && startsWith(matrix.platform.os, 'ubuntu') && !contains(matrix.platform.target, 'android') }}
89-
run: |
90-
weston --no-config --socket=wl-test-env --backend=headless &
91-
WAYLAND_DISPLAY=wl-test-env xvfb-run cargo test --features "${{ matrix.features }}" --target ${{ matrix.platform.target }}
92-
- name: Test
93-
if: ${{ matrix.platform.test && !startsWith(matrix.platform.os, 'ubuntu') && !contains(matrix.platform.target, 'android') }}
53+
54+
- uses: taiki-e/install-action@v2
55+
with:
56+
tool: cargo-dinghy
57+
58+
- name: Enable KVM
9459
run: |
95-
cargo test --features "${{ matrix.features }}" --target ${{ matrix.platform.target }}
96-
- name: Test
97-
if: ${{ matrix.platform.test && contains(matrix.platform.target, 'android') }}
60+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
61+
sudo udevadm control --reload-rules
62+
sudo udevadm trigger --name-match=kvm
63+
64+
- name: AVD cache
65+
uses: actions/cache@v4
66+
id: avd-cache
67+
with:
68+
path: |
69+
~/.android/avd/*
70+
~/.android/adb*
71+
key: avd-30-${{ github.workflow }}-${{ github.job }}-${{ runner.os }}-${{runner.arch}}
72+
73+
- name: Create directory for avd
74+
# This shouldn't be necesary but this is a work around for
75+
# https://github.com/ReactiveCircus/android-emulator-runner/issues/197
76+
if: steps.avd-cache.outputs.cache-hit != 'true'
77+
run: mkdir -p ~/.android/avd
78+
79+
- name: Create AVD and generate snapshot for caching
80+
if: steps.avd-cache.outputs.cache-hit != 'true'
81+
uses: reactivecircus/android-emulator-runner@v2
82+
with:
83+
api-level: 30
84+
ndk: ${{ steps.setup-ndk.outputs.ndk-full-version }}
85+
force-avd-creation: false
86+
arch: ${{ matrix.platform.arch }}
87+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
88+
disable-animations: false
89+
script: echo "Generated AVD snapshot for caching."
90+
91+
- name: Run tests in android emulator
92+
uses: reactivecircus/android-emulator-runner@v2
9893
env:
94+
RANLIB: "${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib"
9995
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
100-
run: |
101-
cargo install cargo-dinghy
102-
cargo dinghy all-platforms
103-
cargo dinghy test --features "${{ matrix.features }}" --target ${{ matrix.platform.target }}
96+
with:
97+
api-level: 30
98+
ndk: ${{ steps.setup-ndk.outputs.ndk-full-version }}
99+
arch: ${{ matrix.platform.arch }}
100+
force-avd-creation: false
101+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
102+
disable-animations: true
103+
script: |
104+
cargo dinghy all-platforms
105+
cargo dinghy all-devices
106+
cargo dinghy -p auto-android-${{ matrix.platform.arch }}-api30 test --features "${{ matrix.features }}" -- --test-threads 1
104107
Format:
105108
name: Run `rustfmt`
106109
runs-on: ubuntu-24.04
@@ -111,7 +114,7 @@ jobs:
111114
build_result:
112115
name: Result
113116
runs-on: ubuntu-24.04
114-
needs: ["Build", "Format"]
117+
needs: ["android-test", "Format"]
115118
if: always()
116119
steps:
117120
- name: Mark the job as successful

0 commit comments

Comments
 (0)