Skip to content

Commit

Permalink
Introduce GMD + ATD (#479)
Browse files Browse the repository at this point in the history
Introduce Gradle Managed Device definitions to modules that have instrumented tests.

At the moment, defining it as a convention plugin isn't possible due to the bug. That bug is now fixed and will be included in Android Studio Flamingo.
Once Flamingo becomes stable, convert the GMD definitions as a convention plugin (#523)

Change-Id: I0866369e3d0bbe148ca5ec1f92bad59239a347b8
  • Loading branch information
thagikura authored Jan 10, 2023
1 parent de5ceb4 commit 4633609
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/AndroidCIWithGmd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Android CI with GMD

on:
push:
branches:
- main
pull_request:

jobs:

android-ci:
runs-on: macos-latest

steps:
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
- uses: actions/checkout@v2

- name: Run instrumented tests with GMD
continue-on-error: true
run: ./gradlew cleanManagedDevices --unused-only && ./gradlew pixel4api30DemoDebugAndroidTest -Dorg.gradle.workers.max=1 -Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect" -Pandroid.experimental.testOptions.managedDevices.emulator.showKernelLogging=true --info

- name: Upload test reports
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: test-reports
path: |
'**/*/build/reports/androidTests/'
11 changes: 11 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ android {
unitTests {
isIncludeAndroidResources = true
}
// TODO: Convert it as a convention plugin once Flamingo goes out (https://github.com/android/nowinandroid/issues/523)
managedDevices {
devices {
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel4api30").apply {
device = "Pixel 4"
apiLevel = 30
// ATDs currently support only API level 30.
systemImageSource = "aosp-atd"
}
}
}
}
namespace = "com.google.samples.apps.nowinandroid"
}
Expand Down
1 change: 1 addition & 0 deletions benchmarks/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ android {
experimentalProperties["android.experimental.self-instrumenting"] = true

testOptions {
// TODO: Convert it as a convention plugin once Flamingo goes out (https://github.com/android/nowinandroid/issues/523)
managedDevices {
devices {
create<ManagedVirtualDevice>("pixel6Api31") {
Expand Down
14 changes: 14 additions & 0 deletions core/database/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ android {
testInstrumentationRunner = "com.google.samples.apps.nowinandroid.core.testing.NiaTestRunner"
}
namespace = "com.google.samples.apps.nowinandroid.core.database"

testOptions {
// TODO: Convert it as a convention plugin once Flamingo goes out (https://github.com/android/nowinandroid/issues/523)
managedDevices {
devices {
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel4api30").apply {
device = "Pixel 4"
apiLevel = 30
// ATDs currently support only API level 30.
systemImageSource = "aosp-atd"
}
}
}
}
}

dependencies {
Expand Down
14 changes: 14 additions & 0 deletions feature/bookmarks/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ plugins {

android {
namespace = "com.google.samples.apps.nowinandroid.feature.bookmarks"

testOptions {
// TODO: Convert it as a convention plugin once Flamingo goes out (https://github.com/android/nowinandroid/issues/523)
managedDevices {
devices {
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel4api30").apply {
device = "Pixel 4"
apiLevel = 30
// ATDs currently support only API level 30.
systemImageSource = "aosp-atd"
}
}
}
}
}

dependencies {
Expand Down
14 changes: 14 additions & 0 deletions feature/foryou/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ plugins {

android {
namespace = "com.google.samples.apps.nowinandroid.feature.foryou"

testOptions {
// TODO: Convert it as a convention plugin once Flamingo goes out (https://github.com/android/nowinandroid/issues/523)
managedDevices {
devices {
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel4api30").apply {
device = "Pixel 4"
apiLevel = 30
// ATDs currently support only API level 30.
systemImageSource = "aosp-atd"
}
}
}
}
}

dependencies {
Expand Down
14 changes: 14 additions & 0 deletions feature/interests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,18 @@ plugins {
}
android {
namespace = "com.google.samples.apps.nowinandroid.feature.interests"

testOptions {
// TODO: Convert it as a convention plugin once Flamingo goes out (https://github.com/android/nowinandroid/issues/523)
managedDevices {
devices {
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel4api30").apply {
device = "Pixel 4"
apiLevel = 30
// ATDs currently support only API level 30.
systemImageSource = "aosp-atd"
}
}
}
}
}
14 changes: 14 additions & 0 deletions feature/settings/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,18 @@ plugins {

android {
namespace = "com.google.samples.apps.nowinandroid.feature.settings"

testOptions {
// TODO: Convert it as a convention plugin once Flamingo goes out (https://github.com/android/nowinandroid/issues/523)
managedDevices {
devices {
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel4api30").apply {
device = "Pixel 4"
apiLevel = 30
// ATDs currently support only API level 30.
systemImageSource = "aosp-atd"
}
}
}
}
}
14 changes: 14 additions & 0 deletions feature/topic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ plugins {

android {
namespace = "com.google.samples.apps.nowinandroid.feature.topic"

testOptions {
// TODO: Convert it as a convention plugin once Flamingo goes out (https://github.com/android/nowinandroid/issues/523)
managedDevices {
devices {
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel4api30").apply {
device = "Pixel 4"
apiLevel = 30
// ATDs currently support only API level 30.
systemImageSource = "aosp-atd"
}
}
}
}
}

dependencies {
Expand Down

0 comments on commit 4633609

Please sign in to comment.