Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions .github/workflows/android-emulator-ondemand.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Android Emulator On-Demand

on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to run CI on'
required: true
default: 'master'
type: string
api-levels:
description: 'API levels to test (comma-separated, e.g. "21,28")'
required: false
default: '21,28'
type: string

concurrency:
group: ondemand-${{ github.ref }}
cancel-in-progress: true

jobs:
test_emulator:
timeout-minutes: 30
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
api-level: ${{ github.event_name == 'workflow_dispatch' && fromJson(format('[{0}]', inputs.api-levels)) }}
steps:
- name: checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.branch || github.ref }}
- name: Java 17
uses: actions/setup-java@v5
with:
distribution: "temurin"
java-version: 17
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Cache Rust dependencies
uses: actions/cache@v5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
file_operations/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Setup Rust for Android
run: |
cd file_operations
chmod +x setup_rust_android.sh
./setup_rust_android.sh
- name: Verify Rust setup
run: |
cd file_operations
echo "🔍 Verifying Rust Android targets..."
rustup target list --installed | grep android || echo "No Android targets found"
echo "🔍 Verifying cargo configuration..."
if [ -f .cargo/config.toml ]; then
echo "✅ .cargo/config.toml exists"
else
echo "❌ .cargo/config.toml missing"
exit 1
fi
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: AVD cache
uses: actions/cache@v5
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
~/.android/debug.keystore
key: avd-${{ matrix.api-level }}
- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
sdcard-path-or-size: 100M
arch: x86_64
ram-size: 2048M
channel: canary
script: echo "Generated AVD snapshot for caching."
- name: run tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
sdcard-path-or-size: 100M
arch: x86_64
ram-size: 2048M
channel: canary
script: |
adb logcat -c
adb logcat *:E &
./gradlew :app:connectedCheck