Use gradle-managed device for testing (#609)

This commit is contained in:
Ricki Hirner 2024-03-01 20:15:45 +01:00 committed by GitHub
parent dc1c77c336
commit e3485ec3ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 32 deletions

View File

@ -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

View File

@ -107,6 +107,19 @@ android {
androidResources {
generateLocaleConfig = true
}
@Suppress("UnstableApiUsage")
testOptions {
managedDevices {
localDevices {
create("virtual") {
device = "Pixel 3"
apiLevel = 34
systemImageSource = "aosp-atd"
}
}
}
}
}
ksp {