Skip to content

Commit 2e38298

Browse files
authored
Merge pull request #4621 from EmmanuelMess/emmanuelmess/ci/add_ondemand_emulator
Add an action for on demand emulator tests
2 parents d3574e1 + c211a46 commit 2e38298

1 file changed

Lines changed: 110 additions & 0 deletions

File tree

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Android Emulator On-Demand
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
branch:
7+
description: 'Branch to run CI on'
8+
required: true
9+
default: 'master'
10+
type: string
11+
api-levels:
12+
description: 'API levels to test (comma-separated, e.g. "21,28")'
13+
required: false
14+
default: '21,28'
15+
type: string
16+
17+
jobs:
18+
test_emulator:
19+
timeout-minutes: 30 # Emulator can get stuck
20+
runs-on: ubuntu-latest
21+
strategy:
22+
fail-fast: true
23+
matrix:
24+
api-level: ${{ github.event_name == 'workflow_dispatch' && fromJson(format('[{0}]', inputs.api-levels)) }}
25+
steps:
26+
- name: checkout
27+
uses: actions/checkout@v6
28+
with:
29+
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.branch }}
30+
- name: Java 17
31+
uses: actions/setup-java@v5
32+
with:
33+
distribution: "temurin"
34+
java-version: 17
35+
- name: Install Rust
36+
uses: dtolnay/rust-toolchain@stable
37+
with:
38+
toolchain: stable
39+
- name: Cache Rust dependencies
40+
uses: actions/cache@v5
41+
with:
42+
path: |
43+
~/.cargo/bin/
44+
~/.cargo/registry/index/
45+
~/.cargo/registry/cache/
46+
~/.cargo/git/db/
47+
file_operations/target/
48+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
49+
restore-keys: |
50+
${{ runner.os }}-cargo-
51+
- name: Setup Rust for Android
52+
run: |
53+
cd file_operations
54+
chmod +x setup_rust_android.sh
55+
./setup_rust_android.sh
56+
- name: Verify Rust setup
57+
run: |
58+
cd file_operations
59+
echo "🔍 Verifying Rust Android targets..."
60+
rustup target list --installed | grep android || echo "No Android targets found"
61+
echo "🔍 Verifying cargo configuration..."
62+
if [ -f .cargo/config.toml ]; then
63+
echo "✅ .cargo/config.toml exists"
64+
else
65+
echo "❌ .cargo/config.toml missing"
66+
exit 1
67+
fi
68+
- name: Enable KVM
69+
run: |
70+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
71+
sudo udevadm control --reload-rules
72+
sudo udevadm trigger --name-match=kvm
73+
- name: AVD cache
74+
uses: actions/cache@v5
75+
id: avd-cache
76+
with:
77+
path: |
78+
~/.android/avd/*
79+
~/.android/adb*
80+
~/.android/debug.keystore
81+
key: avd-${{ matrix.api-level }}
82+
- name: create AVD and generate snapshot for caching
83+
if: steps.avd-cache.outputs.cache-hit != 'true'
84+
uses: reactivecircus/android-emulator-runner@v2
85+
with:
86+
api-level: ${{ matrix.api-level }}
87+
force-avd-creation: false
88+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
89+
disable-animations: false
90+
sdcard-path-or-size: 100M
91+
arch: x86_64
92+
ram-size: 2048M
93+
channel: canary
94+
script: echo "Generated AVD snapshot for caching."
95+
96+
- name: run tests
97+
uses: reactivecircus/android-emulator-runner@v2
98+
with:
99+
api-level: ${{ matrix.api-level }}
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+
sdcard-path-or-size: 100M
104+
arch: x86_64
105+
ram-size: 2048M
106+
channel: canary
107+
script: |
108+
adb logcat -c
109+
adb logcat *:E &
110+
./gradlew :app:connectedCheck

0 commit comments

Comments
 (0)