From 3bfd0cacbf93e00a395e08ddc108d7ca1d4fd777 Mon Sep 17 00:00:00 2001 From: Ricki Hirner Date: Fri, 1 Mar 2024 18:37:51 +0100 Subject: [PATCH 1/2] Use gradle-managed devices for testing --- .github/workflows/test-dev.yml | 29 ++++------------------------- lib/build.gradle.kts | 13 +++++++++++++ 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/.github/workflows/test-dev.yml b/.github/workflows/test-dev.yml index 8c67aa9..0e351a5 100644 --- a/.github/workflows/test-dev.yml +++ b/.github/workflows/test-dev.yml @@ -27,9 +27,6 @@ jobs: test_on_emulator: name: Tests with emulator runs-on: ubuntu-latest-4-cores - strategy: - matrix: - api-level: [ 31 ] steps: - uses: actions/checkout@v4 - uses: actions/setup-java@v4 @@ -49,30 +46,12 @@ jobs: id: avd-cache with: path: | - ~/.android/avd/* + ~/.android/avd/gradle-managed/* ~/.android/adb* - key: avd-${{ matrix.api-level }} + key: avd-${{ hashFiles('lib/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 --no-daemon connectedCheck + - name: Run device tests + run: ./gradlew --no-daemon pixel3Check - name: Archive results uses: actions/upload-artifact@v4 diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index ca2dc86..c2b7978 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -53,6 +53,19 @@ android { testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } + @Suppress("UnstableApiUsage") + testOptions { + managedDevices { + localDevices { + create("pixel3") { + device = "Pixel 3" + apiLevel = 33 + systemImageSource = "aosp-atd" + } + } + } + } + publishing { // Configure publish variant singleVariant("release") { From 39a62b68547d08003b76bde42055e365e507cdbc Mon Sep 17 00:00:00 2001 From: Ricki Hirner Date: Fri, 1 Mar 2024 18:43:16 +0100 Subject: [PATCH 2/2] Caching, rename AVD image --- .github/workflows/test-dev.yml | 7 +++---- lib/build.gradle.kts | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-dev.yml b/.github/workflows/test-dev.yml index 0e351a5..f01bc1e 100644 --- a/.github/workflows/test-dev.yml +++ b/.github/workflows/test-dev.yml @@ -41,17 +41,16 @@ 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/gradle-managed/* + ~/.android/avd ~/.android/adb* key: avd-${{ hashFiles('lib/build.gradle.kts') }} # gradle-managed devices are defined there - name: Run device tests - run: ./gradlew --no-daemon pixel3Check + run: ./gradlew --no-daemon virtualCheck - name: Archive results uses: actions/upload-artifact@v4 diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index c2b7978..85153be 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -57,7 +57,7 @@ android { testOptions { managedDevices { localDevices { - create("pixel3") { + create("virtual") { device = "Pixel 3" apiLevel = 33 systemImageSource = "aosp-atd"