Skip to content

Commit cff1924

Browse files
committed
Add android testing to CI
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
1 parent b3a4060 commit cff1924

File tree

5 files changed

+64
-7
lines changed

5 files changed

+64
-7
lines changed

.github/workflows/main.yml

+48-2
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,11 @@ jobs:
5858
sudo apt install gcc libxxf86vm-dev libosmesa6-dev libgles2-mesa-dev xvfb weston -y
5959
- name: Install rust
6060
id: toolchain
61-
uses: dtolnay/rust-toolchain@stable
61+
uses: dtolnay/rust-toolchain@1.81.0
6262
with:
6363
targets: ${{ matrix.platform.target }}
6464
- name: Build
6565
run: |
66-
rustup target add ${{ matrix.platform.target }}
6766
cargo build --features "${{ matrix.features }}" --target ${{ matrix.platform.target }}
6867
- name: Test
6968
if: ${{ matrix.platform.test && startsWith(matrix.platform.os, 'ubuntu') }}
@@ -74,6 +73,53 @@ jobs:
7473
if: ${{ matrix.platform.test && !startsWith(matrix.platform.os, 'ubuntu') }}
7574
run: |
7675
cargo test --features "${{ matrix.features }}" --target ${{ matrix.platform.target }}
76+
77+
android-test:
78+
name: ${{ format('x86_64-linux-android {0}', matrix.features)}}
79+
runs-on: ubuntu-24.04
80+
env:
81+
RUST_BACKTRACE: 1
82+
strategy:
83+
fail-fast: false
84+
matrix:
85+
features:
86+
[
87+
"",
88+
"chains sm-raw-window-handle-06",
89+
"chains sm-raw-window-handle-05",
90+
]
91+
steps:
92+
- uses: actions/checkout@v4
93+
- name: Install rust
94+
id: toolchain
95+
uses: dtolnay/rust-toolchain@1.81.0
96+
with:
97+
targets: x86_64-linux-android
98+
99+
- uses: taiki-e/install-action@v2
100+
with:
101+
tool: cargo-dinghy
102+
103+
- name: Enable KVM
104+
run: |
105+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
106+
sudo udevadm control --reload-rules
107+
sudo udevadm trigger --name-match=kvm
108+
109+
- name: Run tests in android emulator
110+
uses: reactivecircus/android-emulator-runner@v2
111+
env:
112+
RANLIB: "${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib"
113+
with:
114+
api-level: 30
115+
arch: x86_64
116+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
117+
disable-animations: true
118+
script: |
119+
cargo dinghy all-platforms
120+
cargo dinghy all-devices
121+
cargo dinghy -p auto-android-x86_64-api30 test --features "${{ matrix.features }}" -- --test-threads 1
122+
77123
Format:
78124
name: Run `rustfmt`
79125
runs-on: ubuntu-24.04

Cargo.toml

+7-3
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,19 @@ libc = "0.2"
3939
log = "0.4"
4040
glow = "0.16"
4141
osmesa-sys = { version = "0.1", optional = true }
42-
rwh_05 = { package = "raw-window-handle", version = "0.5.2", features = ["std"], optional = true }
43-
rwh_06 = { package = "raw-window-handle", version = "0.6.2", features = ["std"], optional = true }
42+
rwh_05 = { package = "raw-window-handle", version = "0.5.2", features = [
43+
"std",
44+
], optional = true }
45+
rwh_06 = { package = "raw-window-handle", version = "0.6.2", features = [
46+
"std",
47+
], optional = true }
4448

4549
[dev-dependencies]
4650
clap = "2"
4751
gl = "0.14"
4852
png = "0.17"
4953
rand = "0.8"
50-
winit = "0.29"
54+
winit = { version = "0.29.10", features = ["android-native-activity"] }
5155
serial_test = "3.1.0"
5256

5357
[target.'cfg(target_os = "macos")'.dependencies]

examples/threads.rs

+3
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ fn make_native_widget(
111111
native_widget
112112
}
113113

114+
#[cfg(target_os = "android")]
115+
fn main() {}
116+
114117
#[cfg(not(target_os = "android"))]
115118
fn main() {
116119
use winit::{

rust-toolchain.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[toolchain]
2-
channel = "1.80.1"
3-
components = [ "rustfmt" ]
2+
channel = "1.81.0"
3+
components = ["rustfmt"]
44
profile = "minimal"

src/platform/egl/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ crate::implement_interfaces!();
1818
#[cfg(feature = "sm-test")]
1919
#[path = "../../tests.rs"]
2020
pub mod tests;
21+
22+
#[cfg(all(not(feature = "sm-test"), test))]
23+
#[path = "../../tests.rs"]
24+
pub mod tests;

0 commit comments

Comments
 (0)