Skip to content

Commit

Permalink
Try gradle managed devices to speed up instrumentation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LachlanMcKee committed Jul 9, 2023
1 parent f05ea4f commit 11d850b
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 35 deletions.
37 changes: 2 additions & 35 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,46 +86,13 @@ jobs:
- uses: gradle/gradle-build-action@v2
with:
cache-read-only: ${{ env.MAIN_BRANCH != 'true' }}
- name: Pre build sources before launching emulator
run: ./gradlew compileDebugAndroidTestSources
- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-29
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
# Use API 29 https://github.com/ReactiveCircus/android-emulator-runner/issues/222
api-level: 29
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: Instrumentation tests
uses: reactivecircus/android-emulator-runner@v2
with:
# Use API 29 https://github.com/ReactiveCircus/android-emulator-runner/issues/222
api-level: 29
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: |
adb logcat > logcat.out &
./gradlew connectedCheck
- name: Managed device clean-up
run: >
./gradlew cleanManagedDevices --unused-only
adb logcat > logcat.out & ./gradlew cleanManagedDevices --unused-only && ./gradlew pixel2api30DebugAndroidTest -Dorg.gradle.workers.max=1 -Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect" -Pandroid.experimental.testOptions.managedDevices.emulator.showKernelLogging=true --info
- name: Screenshot tests
# Flags from https://github.com/android/nowinandroid/blob/main/.github/workflows/AndroidCIWithGmd.yaml
run: >
./gradlew screenshotTestsCompareBaseline
./gradlew cleanManagedDevices --unused-only && ./gradlew screenshotTestsCompareBaseline
-Dorg.gradle.workers.max=1
-Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect"
-Pandroid.experimental.testOptions.managedDevices.emulator.showKernelLogging=true
Expand Down
9 changes: 9 additions & 0 deletions appyx-components/internal/test-drive/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ android {
unitTests.all {
it.useJUnitPlatform()
}
managedDevices {
devices {
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel2api30").apply {
device = "Pixel 2"
apiLevel = 30
systemImageSource = "aosp-atd"
}
}
}
}
packagingOptions {
resources.excludes.apply {
Expand Down
9 changes: 9 additions & 0 deletions appyx-components/stable/backstack/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ android {
unitTests.all {
it.useJUnitPlatform()
}
managedDevices {
devices {
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel2api30").apply {
device = "Pixel 2"
apiLevel = 30
systemImageSource = "aosp-atd"
}
}
}
}
packagingOptions {
resources.excludes.apply {
Expand Down
9 changes: 9 additions & 0 deletions appyx-components/stable/spotlight/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ android {
unitTests.all {
it.useJUnitPlatform()
}
managedDevices {
devices {
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel2api30").apply {
device = "Pixel 2"
apiLevel = 30
systemImageSource = "aosp-atd"
}
}
}
}
packagingOptions {
resources.excludes.apply {
Expand Down
9 changes: 9 additions & 0 deletions appyx-navigation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ android {
// interface method default implementation
it.exclude("**/*\$DefaultImpls.class")
}
managedDevices {
devices {
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel2api30").apply {
device = "Pixel 2"
apiLevel = 30
systemImageSource = "aosp-atd"
}
}
}
}
}

Expand Down
11 changes: 11 additions & 0 deletions demos/navigation-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
}
testOptions {
managedDevices {
devices {
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel2api30").apply {
device = "Pixel 2"
apiLevel = 30
systemImageSource = "aosp-atd"
}
}
}
}
}

dependencies {
Expand Down
11 changes: 11 additions & 0 deletions utils/interop-ribs/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
}
testOptions {
managedDevices {
devices {
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel2api30").apply {
device = "Pixel 2"
apiLevel = 30
systemImageSource = "aosp-atd"
}
}
}
}
}

dependencies {
Expand Down

0 comments on commit 11d850b

Please sign in to comment.