Skip to content

Commit 4633609

Browse files
authored
Introduce GMD + ATD (#479)
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
1 parent de5ceb4 commit 4633609

File tree

9 files changed

+127
-0
lines changed

9 files changed

+127
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Android CI with GMD
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
11+
android-ci:
12+
runs-on: macos-latest
13+
14+
steps:
15+
- uses: actions/setup-java@v3
16+
with:
17+
distribution: 'zulu'
18+
java-version: '11'
19+
- uses: actions/checkout@v2
20+
21+
- name: Run instrumented tests with GMD
22+
continue-on-error: true
23+
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
24+
25+
- name: Upload test reports
26+
if: success() || failure()
27+
uses: actions/upload-artifact@v3
28+
with:
29+
name: test-reports
30+
path: |
31+
'**/*/build/reports/androidTests/'

app/build.gradle.kts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ android {
7373
unitTests {
7474
isIncludeAndroidResources = true
7575
}
76+
// TODO: Convert it as a convention plugin once Flamingo goes out (https://github.com/android/nowinandroid/issues/523)
77+
managedDevices {
78+
devices {
79+
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel4api30").apply {
80+
device = "Pixel 4"
81+
apiLevel = 30
82+
// ATDs currently support only API level 30.
83+
systemImageSource = "aosp-atd"
84+
}
85+
}
86+
}
7687
}
7788
namespace = "com.google.samples.apps.nowinandroid"
7889
}

benchmarks/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ android {
6767
experimentalProperties["android.experimental.self-instrumenting"] = true
6868

6969
testOptions {
70+
// TODO: Convert it as a convention plugin once Flamingo goes out (https://github.com/android/nowinandroid/issues/523)
7071
managedDevices {
7172
devices {
7273
create<ManagedVirtualDevice>("pixel6Api31") {

core/database/build.gradle.kts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@ android {
3434
testInstrumentationRunner = "com.google.samples.apps.nowinandroid.core.testing.NiaTestRunner"
3535
}
3636
namespace = "com.google.samples.apps.nowinandroid.core.database"
37+
38+
testOptions {
39+
// TODO: Convert it as a convention plugin once Flamingo goes out (https://github.com/android/nowinandroid/issues/523)
40+
managedDevices {
41+
devices {
42+
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel4api30").apply {
43+
device = "Pixel 4"
44+
apiLevel = 30
45+
// ATDs currently support only API level 30.
46+
systemImageSource = "aosp-atd"
47+
}
48+
}
49+
}
50+
}
3751
}
3852

3953
dependencies {

feature/bookmarks/build.gradle.kts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ plugins {
2121

2222
android {
2323
namespace = "com.google.samples.apps.nowinandroid.feature.bookmarks"
24+
25+
testOptions {
26+
// TODO: Convert it as a convention plugin once Flamingo goes out (https://github.com/android/nowinandroid/issues/523)
27+
managedDevices {
28+
devices {
29+
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel4api30").apply {
30+
device = "Pixel 4"
31+
apiLevel = 30
32+
// ATDs currently support only API level 30.
33+
systemImageSource = "aosp-atd"
34+
}
35+
}
36+
}
37+
}
2438
}
2539

2640
dependencies {

feature/foryou/build.gradle.kts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ plugins {
2121

2222
android {
2323
namespace = "com.google.samples.apps.nowinandroid.feature.foryou"
24+
25+
testOptions {
26+
// TODO: Convert it as a convention plugin once Flamingo goes out (https://github.com/android/nowinandroid/issues/523)
27+
managedDevices {
28+
devices {
29+
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel4api30").apply {
30+
device = "Pixel 4"
31+
apiLevel = 30
32+
// ATDs currently support only API level 30.
33+
systemImageSource = "aosp-atd"
34+
}
35+
}
36+
}
37+
}
2438
}
2539

2640
dependencies {

feature/interests/build.gradle.kts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,18 @@ plugins {
2020
}
2121
android {
2222
namespace = "com.google.samples.apps.nowinandroid.feature.interests"
23+
24+
testOptions {
25+
// TODO: Convert it as a convention plugin once Flamingo goes out (https://github.com/android/nowinandroid/issues/523)
26+
managedDevices {
27+
devices {
28+
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel4api30").apply {
29+
device = "Pixel 4"
30+
apiLevel = 30
31+
// ATDs currently support only API level 30.
32+
systemImageSource = "aosp-atd"
33+
}
34+
}
35+
}
36+
}
2337
}

feature/settings/build.gradle.kts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,18 @@ plugins {
2121

2222
android {
2323
namespace = "com.google.samples.apps.nowinandroid.feature.settings"
24+
25+
testOptions {
26+
// TODO: Convert it as a convention plugin once Flamingo goes out (https://github.com/android/nowinandroid/issues/523)
27+
managedDevices {
28+
devices {
29+
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel4api30").apply {
30+
device = "Pixel 4"
31+
apiLevel = 30
32+
// ATDs currently support only API level 30.
33+
systemImageSource = "aosp-atd"
34+
}
35+
}
36+
}
37+
}
2438
}

feature/topic/build.gradle.kts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ plugins {
2121

2222
android {
2323
namespace = "com.google.samples.apps.nowinandroid.feature.topic"
24+
25+
testOptions {
26+
// TODO: Convert it as a convention plugin once Flamingo goes out (https://github.com/android/nowinandroid/issues/523)
27+
managedDevices {
28+
devices {
29+
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel4api30").apply {
30+
device = "Pixel 4"
31+
apiLevel = 30
32+
// ATDs currently support only API level 30.
33+
systemImageSource = "aosp-atd"
34+
}
35+
}
36+
}
37+
}
2438
}
2539

2640
dependencies {

0 commit comments

Comments
 (0)