Skip to content

Commit 317b027

Browse files
Max Lvclaude
authored andcommitted
Add Android emulator instrumentation tests to CI
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 60de804 commit 317b027

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

.github/workflows/build.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,67 @@ jobs:
120120
name: test-results
121121
path: app/build/reports/
122122

123+
android-emulator-test:
124+
name: Android Emulator Tests
125+
runs-on: ubuntu-latest
126+
steps:
127+
- uses: actions/checkout@v4
128+
with:
129+
submodules: recursive
130+
131+
- name: Enable KVM
132+
run: |
133+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
134+
sudo udevadm control --reload-rules
135+
sudo udevadm trigger --name-match=kvm
136+
137+
- name: Set up JDK 17
138+
uses: actions/setup-java@v4
139+
with:
140+
java-version: '17'
141+
distribution: 'temurin'
142+
143+
- name: Install NDK
144+
run: echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "ndk;27.2.12479018"
145+
146+
- name: Install Rust toolchain
147+
uses: dtolnay/rust-toolchain@stable
148+
with:
149+
targets: x86_64-linux-android
150+
151+
- name: Cache cargo registry and build
152+
uses: actions/cache@v4
153+
with:
154+
path: |
155+
~/.cargo/registry
156+
~/.cargo/git
157+
app/src/main/rust/qtun/target
158+
key: ${{ runner.os }}-cargo-emulator-${{ hashFiles('**/Cargo.lock') }}
159+
restore-keys: |
160+
${{ runner.os }}-cargo-emulator-
161+
162+
- name: Setup Gradle
163+
uses: gradle/actions/setup-gradle@v4
164+
165+
- name: Build debug APK for tests
166+
run: ./gradlew assembleDebug assembleDebugAndroidTest
167+
168+
- name: Run emulator tests
169+
uses: reactivecircus/android-emulator-runner@v2
170+
with:
171+
api-level: 31
172+
arch: x86_64
173+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim
174+
disable-animations: true
175+
script: ./gradlew connectedAndroidTest
176+
177+
- name: Upload test results
178+
if: always()
179+
uses: actions/upload-artifact@v4
180+
with:
181+
name: emulator-test-results
182+
path: app/build/reports/androidTests/
183+
123184
build:
124185
name: Build APK
125186
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)