From 46c1d510d49529d1aed1aeb194dac759c5395ac4 Mon Sep 17 00:00:00 2001 From: Mohsen Rzna Date: Fri, 20 Jan 2023 04:40:03 +0100 Subject: [PATCH] Android-CI workflow -> GMD refactor (#537) This PR is about updating the operating system to macOS-12 as the previous one was going to be deprecated, as well as updating the checkout to v3 to avoid the warnings in the panel; adding setup SDK action to accept the license which was missing from the beginning. I also added imports instead of adding them directly with the codes. As a reference, there was another PR with a similar topic, but it wasn't complete: #483 --- .github/workflows/AndroidCIWithGmd.yaml | 36 ++++++++++++++----------- app/build.gradle.kts | 3 ++- core/database/build.gradle.kts | 8 ++++-- feature/bookmarks/build.gradle.kts | 5 +++- feature/foryou/build.gradle.kts | 5 +++- feature/interests/build.gradle.kts | 5 +++- feature/settings/build.gradle.kts | 5 +++- feature/topic/build.gradle.kts | 5 +++- 8 files changed, 48 insertions(+), 24 deletions(-) diff --git a/.github/workflows/AndroidCIWithGmd.yaml b/.github/workflows/AndroidCIWithGmd.yaml index fb01ab1e8..6721d3aa0 100644 --- a/.github/workflows/AndroidCIWithGmd.yaml +++ b/.github/workflows/AndroidCIWithGmd.yaml @@ -9,23 +9,27 @@ on: jobs: android-ci: - runs-on: macos-latest + runs-on: macos-12 steps: - - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: '11' - - uses: actions/checkout@v2 + - uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '11' + - uses: actions/checkout@v3 - - 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: Setup Android SDK + uses: android-actions/setup-android@v2 - - name: Upload test reports - if: success() || failure() - uses: actions/upload-artifact@v3 - with: - name: test-reports - path: | - '**/*/build/reports/androidTests/' + - name: Run instrumented tests with GMD + 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/' diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 3cc48f284..b52d54d12 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -14,6 +14,7 @@ * limitations under the License. */ import com.google.samples.apps.nowinandroid.NiaBuildType +import com.android.build.api.dsl.ManagedVirtualDevice plugins { id("nowinandroid.android.application") @@ -76,7 +77,7 @@ android { // TODO: Convert it as a convention plugin once Flamingo goes out (https://github.com/android/nowinandroid/issues/523) managedDevices { devices { - maybeCreate("pixel4api30").apply { + maybeCreate("pixel4api30").apply { device = "Pixel 4" apiLevel = 30 // ATDs currently support only API level 30. diff --git a/core/database/build.gradle.kts b/core/database/build.gradle.kts index 1177ae0f5..79fd4ded9 100644 --- a/core/database/build.gradle.kts +++ b/core/database/build.gradle.kts @@ -13,6 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +import com.android.build.api.dsl.ManagedVirtualDevice + // TODO: Remove once https://youtrack.jetbrains.com/issue/KTIJ-19369 is fixed @Suppress("DSL_SCOPE_VIOLATION") plugins { @@ -31,7 +34,8 @@ android { arg("room.schemaLocation", "$projectDir/schemas") } - testInstrumentationRunner = "com.google.samples.apps.nowinandroid.core.testing.NiaTestRunner" + testInstrumentationRunner = + "com.google.samples.apps.nowinandroid.core.testing.NiaTestRunner" } namespace = "com.google.samples.apps.nowinandroid.core.database" @@ -39,7 +43,7 @@ android { // TODO: Convert it as a convention plugin once Flamingo goes out (https://github.com/android/nowinandroid/issues/523) managedDevices { devices { - maybeCreate("pixel4api30").apply { + maybeCreate("pixel4api30").apply { device = "Pixel 4" apiLevel = 30 // ATDs currently support only API level 30. diff --git a/feature/bookmarks/build.gradle.kts b/feature/bookmarks/build.gradle.kts index 18212ba4a..2bbeec9a1 100644 --- a/feature/bookmarks/build.gradle.kts +++ b/feature/bookmarks/build.gradle.kts @@ -13,6 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +import com.android.build.api.dsl.ManagedVirtualDevice + plugins { id("nowinandroid.android.feature") id("nowinandroid.android.library.compose") @@ -26,7 +29,7 @@ android { // TODO: Convert it as a convention plugin once Flamingo goes out (https://github.com/android/nowinandroid/issues/523) managedDevices { devices { - maybeCreate("pixel4api30").apply { + maybeCreate("pixel4api30").apply { device = "Pixel 4" apiLevel = 30 // ATDs currently support only API level 30. diff --git a/feature/foryou/build.gradle.kts b/feature/foryou/build.gradle.kts index 84fe81ff0..59e0cc904 100644 --- a/feature/foryou/build.gradle.kts +++ b/feature/foryou/build.gradle.kts @@ -13,6 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +import com.android.build.api.dsl.ManagedVirtualDevice + plugins { id("nowinandroid.android.feature") id("nowinandroid.android.library.compose") @@ -26,7 +29,7 @@ android { // TODO: Convert it as a convention plugin once Flamingo goes out (https://github.com/android/nowinandroid/issues/523) managedDevices { devices { - maybeCreate("pixel4api30").apply { + maybeCreate("pixel4api30").apply { device = "Pixel 4" apiLevel = 30 // ATDs currently support only API level 30. diff --git a/feature/interests/build.gradle.kts b/feature/interests/build.gradle.kts index 477093d2b..8fd9dcd8d 100644 --- a/feature/interests/build.gradle.kts +++ b/feature/interests/build.gradle.kts @@ -13,6 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +import com.android.build.api.dsl.ManagedVirtualDevice + plugins { id("nowinandroid.android.feature") id("nowinandroid.android.library.compose") @@ -25,7 +28,7 @@ android { // TODO: Convert it as a convention plugin once Flamingo goes out (https://github.com/android/nowinandroid/issues/523) managedDevices { devices { - maybeCreate("pixel4api30").apply { + maybeCreate("pixel4api30").apply { device = "Pixel 4" apiLevel = 30 // ATDs currently support only API level 30. diff --git a/feature/settings/build.gradle.kts b/feature/settings/build.gradle.kts index 3fbe1cef8..41dee24dc 100644 --- a/feature/settings/build.gradle.kts +++ b/feature/settings/build.gradle.kts @@ -13,6 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +import com.android.build.api.dsl.ManagedVirtualDevice + plugins { id("nowinandroid.android.feature") id("nowinandroid.android.library.compose") @@ -26,7 +29,7 @@ android { // TODO: Convert it as a convention plugin once Flamingo goes out (https://github.com/android/nowinandroid/issues/523) managedDevices { devices { - maybeCreate("pixel4api30").apply { + maybeCreate("pixel4api30").apply { device = "Pixel 4" apiLevel = 30 // ATDs currently support only API level 30. diff --git a/feature/topic/build.gradle.kts b/feature/topic/build.gradle.kts index 76e803b67..48e2563f8 100644 --- a/feature/topic/build.gradle.kts +++ b/feature/topic/build.gradle.kts @@ -13,6 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +import com.android.build.api.dsl.ManagedVirtualDevice + plugins { id("nowinandroid.android.feature") id("nowinandroid.android.library.compose") @@ -26,7 +29,7 @@ android { // TODO: Convert it as a convention plugin once Flamingo goes out (https://github.com/android/nowinandroid/issues/523) managedDevices { devices { - maybeCreate("pixel4api30").apply { + maybeCreate("pixel4api30").apply { device = "Pixel 4" apiLevel = 30 // ATDs currently support only API level 30.