Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use gradle-managed devices for testing #36

Merged
merged 2 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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