Skip to content

Commit

Permalink
Use gradle-managed devices for testing (#36)
Browse files Browse the repository at this point in the history
* Use gradle-managed devices for testing

* Caching, rename AVD image
  • Loading branch information
rfc2822 authored Mar 1, 2024
1 parent 03ef99a commit d5ee8b8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 27 deletions.
32 changes: 5 additions & 27 deletions .github/workflows/test-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -44,35 +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/*
~/.android/avd
~/.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 virtualCheck

- name: Archive results
uses: actions/upload-artifact@v4
Expand Down
13 changes: 13 additions & 0 deletions lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

@Suppress("UnstableApiUsage")
testOptions {
managedDevices {
localDevices {
create("virtual") {
device = "Pixel 3"
apiLevel = 33
systemImageSource = "aosp-atd"
}
}
}
}

publishing {
// Configure publish variant
singleVariant("release") {
Expand Down

0 comments on commit d5ee8b8

Please sign in to comment.