From e14f6638740f1d8b4eb83517df378effef01bfa4 Mon Sep 17 00:00:00 2001 From: "kexuan.yang" Date: Mon, 29 Apr 2024 22:48:56 +0800 Subject: [PATCH] Fix build break of Android test Signed-off-by: kexuan.yang --- .github/workflows/android.yml | 38 ++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index a1f8aa7..5227bdc 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -9,17 +9,39 @@ on: jobs: build: - runs-on: macos-latest + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: set up JDK 17 - uses: actions/setup-java@v3 + - 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: Gradle cache + uses: gradle/actions/setup-gradle@v3 + + - name: AVD cache + uses: actions/cache@v4 + id: avd-cache + with: + path: | + ~/.android/avd/* + ~/.android/adb* + key: avd-34 + + - name: create AVD and generate snapshot for caching + if: steps.avd-cache.outputs.cache-hit != 'true' + uses: reactivecircus/android-emulator-runner@v2 with: - java-version: '17' - distribution: 'temurin' - cache: 'gradle' + api-level: 34 + arch: x86_64 + force-avd-creation: false + emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + disable-animations: true + script: echo "Generated AVD snapshot for caching." - name: Prepare Gradle build env: @@ -43,6 +65,8 @@ jobs: uses: reactivecircus/android-emulator-runner@v2 with: api-level: 34 - target: google_apis_playstore arch: x86_64 + force-avd-creation: false + emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + disable-animations: true script: cd ./android; ./gradlew connectedAndroidTest