From e3485ec3ec0718f6a49d0290fac085d656340784 Mon Sep 17 00:00:00 2001 From: Ricki Hirner Date: Fri, 1 Mar 2024 20:15:45 +0100 Subject: [PATCH] Use gradle-managed device for testing (#609) --- .github/workflows/test-dev.yml | 39 ++++++---------------------------- app/build.gradle.kts | 13 ++++++++++++ 2 files changed, 20 insertions(+), 32 deletions(-) diff --git a/.github/workflows/test-dev.yml b/.github/workflows/test-dev.yml index 5732ec1f..b7ba337f 100644 --- a/.github/workflows/test-dev.yml +++ b/.github/workflows/test-dev.yml @@ -52,9 +52,6 @@ jobs: test_on_emulator: name: Tests with emulator runs-on: ubuntu-latest-4-cores - strategy: - matrix: - api-level: [ 34 ] steps: - uses: actions/checkout@v4 - uses: actions/setup-java@v4 @@ -87,41 +84,19 @@ jobs: sudo udevadm control --reload-rules sudo udevadm trigger --name-match=kvm - - name: Cache AVD and APKs + - name: Cache AVD uses: actions/cache@v4 - id: avd-cache with: - path: | - ~/.android/avd/* - ~/.android/adb* - key: avd-${{ matrix.api-level }} + path: ~/.config/.android/avd + key: avd-${{ hashFiles('app/build.gradle.kts') }} # gradle-managed devices are defined there - - 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 }} - arch: x86_64 - force-avd-creation: false - emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - disable-animations: false - script: echo "Generated AVD snapshot for caching." - - - name: Run tests - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: ${{ matrix.api-level }} - 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: ./gradlew app:connectedCheck + - name: Run device tests + run: ./gradlew --no-daemon app:virtualCheck - name: Archive results if: always() uses: actions/upload-artifact@v4 with: name: test-results - path: | - app/build/reports - overwrite: true + path: app/build/reports + overwrite: true \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts index d55098ce..97d9daac 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -107,6 +107,19 @@ android { androidResources { generateLocaleConfig = true } + + @Suppress("UnstableApiUsage") + testOptions { + managedDevices { + localDevices { + create("virtual") { + device = "Pixel 3" + apiLevel = 34 + systemImageSource = "aosp-atd" + } + } + } + } } ksp {