From 3cf44b0b8a8cf58d95a2ae0f6fc8e3c18225e3cf Mon Sep 17 00:00:00 2001 From: blue928sky Date: Mon, 23 Sep 2024 10:08:31 +0900 Subject: [PATCH 1/9] Move Android instrumented test NiaAppStateTest to unit test Change-Id: I0a84dc37184a9ea7d4c18fa598bc447b0c48eb62 --- app/build.gradle.kts | 3 ++- .../samples/apps/nowinandroid/ui/NiaAppStateTest.kt | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) rename app/src/{androidTest => testDemo}/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppStateTest.kt (94%) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 5434df8c2..5b131b5d6 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -119,15 +119,16 @@ dependencies { testImplementation(projects.sync.syncTest) testImplementation(libs.kotlin.test) + testDemoImplementation(libs.androidx.navigation.testing) testDemoImplementation(libs.robolectric) testDemoImplementation(libs.roborazzi) testDemoImplementation(projects.core.screenshotTesting) + testDemoImplementation(projects.core.testing) androidTestImplementation(projects.core.testing) androidTestImplementation(projects.core.dataTest) androidTestImplementation(projects.core.datastoreTest) androidTestImplementation(libs.androidx.test.espresso.core) - androidTestImplementation(libs.androidx.navigation.testing) androidTestImplementation(libs.androidx.compose.ui.test) androidTestImplementation(libs.hilt.android.testing) androidTestImplementation(libs.kotlin.test) diff --git a/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppStateTest.kt b/app/src/testDemo/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppStateTest.kt similarity index 94% rename from app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppStateTest.kt rename to app/src/testDemo/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppStateTest.kt index c2c74458d..c6ddb54fb 100644 --- a/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppStateTest.kt +++ b/app/src/testDemo/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppStateTest.kt @@ -31,6 +31,8 @@ import com.google.samples.apps.nowinandroid.core.testing.repository.TestNewsRepo import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository import com.google.samples.apps.nowinandroid.core.testing.util.TestNetworkMonitor import com.google.samples.apps.nowinandroid.core.testing.util.TestTimeZoneMonitor +import dagger.hilt.android.testing.HiltAndroidTest +import dagger.hilt.android.testing.HiltTestApplication import kotlinx.coroutines.flow.collect import kotlinx.coroutines.launch import kotlinx.coroutines.test.UnconfinedTestDispatcher @@ -38,15 +40,18 @@ import kotlinx.coroutines.test.runTest import kotlinx.datetime.TimeZone import org.junit.Rule import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.annotation.Config import kotlin.test.assertEquals import kotlin.test.assertTrue /** * Tests [NiaAppState]. - * - * Note: This could become an unit test if Robolectric is added to the project and the Context - * is faked. */ +@RunWith(RobolectricTestRunner::class) +@Config(application = HiltTestApplication::class) +@HiltAndroidTest class NiaAppStateTest { @get:Rule From c69683fa3b3d5617dc76199e567567da7b2ed1ae Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 00:45:43 +0000 Subject: [PATCH 3/9] Update all dependencies 1.9.0 to v1.10.0 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5ac8236e9..ea68a516c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -41,7 +41,7 @@ hiltExt = "1.2.0" jacoco = "0.8.12" junit4 = "4.13.2" kotlin = "2.1.0" -kotlinxCoroutines = "1.9.0" +kotlinxCoroutines = "1.10.0" kotlinxDatetime = "0.6.1" kotlinxSerializationJson = "1.7.3" ksp = "2.1.0-1.0.29" From a8280310b953e074412468e1031c2c871250c94c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" Date: Fri, 20 Dec 2024 00:48:31 +0000 Subject: [PATCH 4/9] =?UTF-8?q?=F0=9F=A4=96=20Updates=20baselines=20for=20?= =?UTF-8?q?Dependency=20Guard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/dependencies/prodReleaseRuntimeClasspath.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/dependencies/prodReleaseRuntimeClasspath.txt b/app/dependencies/prodReleaseRuntimeClasspath.txt index 2db7fa46c..d7c2fa1df 100644 --- a/app/dependencies/prodReleaseRuntimeClasspath.txt +++ b/app/dependencies/prodReleaseRuntimeClasspath.txt @@ -216,12 +216,12 @@ org.jetbrains.kotlin:kotlin-stdlib-common:2.1.0 org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.0 org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.0 org.jetbrains.kotlin:kotlin-stdlib:2.1.0 -org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0 -org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.9.0 -org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.9.0 -org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0 -org.jetbrains.kotlinx:kotlinx-coroutines-guava:1.9.0 -org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.9.0 +org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.0 +org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.10.0 +org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.10.0 +org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.0 +org.jetbrains.kotlinx:kotlinx-coroutines-guava:1.10.0 +org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.10.0 org.jetbrains.kotlinx:kotlinx-datetime-jvm:0.6.1 org.jetbrains.kotlinx:kotlinx-datetime:0.6.1 org.jetbrains.kotlinx:kotlinx-serialization-bom:1.7.3 From c5c630b1c9d6203ac6f5ba7c52677ad71c4cc406 Mon Sep 17 00:00:00 2001 From: Simon Marquis Date: Fri, 20 Dec 2024 09:55:42 +0100 Subject: [PATCH 5/9] Add bot emails in `renovate.json` Followup on https://github.com/android/nowinandroid/pull/1766 --- .github/renovate.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/renovate.json b/.github/renovate.json index a9eab3c4d..bdd63664f 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -7,6 +7,8 @@ "main" ], "gitIgnoredAuthors": [ - "41898282+github-actions[bot]@users.noreply.github.com" + "41898282+github-actions[bot]@users.noreply.github.com", + "github-actions[bot]@users.noreply.github.com", + "renovate[bot]@users.noreply.github.com" ] } From 80caa2caa068f116c7f20a845b675da377f7e790 Mon Sep 17 00:00:00 2001 From: Simon Marquis Date: Fri, 20 Dec 2024 10:00:42 +0100 Subject: [PATCH 6/9] Re-order entries to limit changes in diff --- .github/renovate.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/renovate.json b/.github/renovate.json index bdd63664f..0eec647d9 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -7,8 +7,8 @@ "main" ], "gitIgnoredAuthors": [ - "41898282+github-actions[bot]@users.noreply.github.com", + "renovate[bot]@users.noreply.github.com", "github-actions[bot]@users.noreply.github.com", - "renovate[bot]@users.noreply.github.com" + "41898282+github-actions[bot]@users.noreply.github.com" ] } From 30ae078404cb650250d0ea99810f327d023f2a57 Mon Sep 17 00:00:00 2001 From: Simon Marquis Date: Fri, 20 Dec 2024 10:32:33 +0100 Subject: [PATCH 7/9] Fix CI workflow OOM Don't change the start directory with `-p :build-logic` which makes Gradle look for `build-logic/gradle.properties` file that does not exist. Therefore, the heap size was configured with default values (`-Xmx512m`) which is definitely not enough for our linting. Fixes #1769 --- .github/workflows/Build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Build.yaml b/.github/workflows/Build.yaml index e090e2155..cb7148ce7 100644 --- a/.github/workflows/Build.yaml +++ b/.github/workflows/Build.yaml @@ -52,7 +52,7 @@ jobs: run: yes | sdkmanager --licenses || true - name: Check build-logic - run: ./gradlew check -p build-logic + run: ./gradlew :build-logic:convention:check - name: Check spotless run: ./gradlew spotlessCheck --init-script gradle/init.gradle.kts --no-configuration-cache From 69b77cf783deb6a2bcddafc2c66aa96ea50af7e0 Mon Sep 17 00:00:00 2001 From: Simon Marquis Date: Fri, 20 Dec 2024 10:34:56 +0100 Subject: [PATCH 8/9] Update NightlyBaselineProfiles.yaml --- .github/workflows/NightlyBaselineProfiles.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/NightlyBaselineProfiles.yaml b/.github/workflows/NightlyBaselineProfiles.yaml index de626b0a5..cc48ff9c9 100644 --- a/.github/workflows/NightlyBaselineProfiles.yaml +++ b/.github/workflows/NightlyBaselineProfiles.yaml @@ -44,7 +44,7 @@ jobs: run: yes | sdkmanager --licenses || true - name: Check build-logic - run: ./gradlew check -p build-logic + run: ./gradlew :build-logic:convention:check - name: Setup GMD run: ./gradlew :benchmarks:pixel6Api33Setup @@ -57,4 +57,4 @@ jobs: run: ./gradlew :app:generateReleaseBaselineProfile -Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=baselineprofile -Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect" - --stacktrace \ No newline at end of file + --stacktrace From 700d570ff1d18dd2f888c210f55cd4c86458c711 Mon Sep 17 00:00:00 2001 From: Simon Marquis Date: Fri, 20 Dec 2024 10:48:35 +0100 Subject: [PATCH 9/9] Gradle Configuration Cache on CI - https://github.com/gradle/actions/blob/main/docs/setup-gradle.md#saving-configuration-cache-data - https://docs.gradle.org/current/userguide/configuration_cache.html#config_cache:secrets And enable parallel Configuration Cache: - https://docs.gradle.org/current/userguide/configuration_cache.html#config_cache:usage:parallel This needs a `GRADLE_ENCRYPTION_KEY` secret to be configured in the repository [settings/secrets/actions](https://github.com/android/nowinandroid/settings/secrets/actions), otherwise no configuration cache will be saved or restored. As explained in the docs, you can use this tool to generate a configuration-cache compatible key: `openssl rand -base64 16`. --- .github/ci-gradle.properties | 2 ++ .github/workflows/Build.yaml | 4 ++++ .github/workflows/NightlyBaselineProfiles.yaml | 2 ++ .github/workflows/Release.yml | 2 ++ build-logic/gradle.properties | 2 ++ gradle.properties | 1 + 6 files changed, 13 insertions(+) diff --git a/.github/ci-gradle.properties b/.github/ci-gradle.properties index dbafa68cd..a9abe496a 100644 --- a/.github/ci-gradle.properties +++ b/.github/ci-gradle.properties @@ -17,6 +17,8 @@ org.gradle.daemon=false org.gradle.parallel=true org.gradle.workers.max=2 +org.gradle.configuration-cache=true +org.gradle.configuration-cache.parallel=true kotlin.incremental=false diff --git a/.github/workflows/Build.yaml b/.github/workflows/Build.yaml index e090e2155..8454da821 100644 --- a/.github/workflows/Build.yaml +++ b/.github/workflows/Build.yaml @@ -44,6 +44,8 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 + with: + cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }} - name: Setup Android SDK uses: android-actions/setup-android@v3 @@ -199,6 +201,8 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 + with: + cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }} - name: Build projects and run instrumentation tests uses: reactivecircus/android-emulator-runner@v2 diff --git a/.github/workflows/NightlyBaselineProfiles.yaml b/.github/workflows/NightlyBaselineProfiles.yaml index de626b0a5..a6914b6b5 100644 --- a/.github/workflows/NightlyBaselineProfiles.yaml +++ b/.github/workflows/NightlyBaselineProfiles.yaml @@ -36,6 +36,8 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 + with: + cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }} - name: Setup Android SDK uses: android-actions/setup-android@v3 diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 71ee060e1..149a7bb6f 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -33,6 +33,8 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 + with: + cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }} - name: Setup Android SDK uses: android-actions/setup-android@v3 diff --git a/build-logic/gradle.properties b/build-logic/gradle.properties index 1c9073eb9..5e07c65d0 100644 --- a/build-logic/gradle.properties +++ b/build-logic/gradle.properties @@ -2,3 +2,5 @@ org.gradle.parallel=true org.gradle.caching=true org.gradle.configureondemand=true +org.gradle.configuration-cache=true +org.gradle.configuration-cache.parallel=true diff --git a/gradle.properties b/gradle.properties index 30c4eae04..2e9d9fc30 100644 --- a/gradle.properties +++ b/gradle.properties @@ -39,6 +39,7 @@ org.gradle.caching=true # Enable configuration caching between builds. org.gradle.configuration-cache=true +org.gradle.configuration-cache.parallel=true # This option is set because of https://github.com/google/play-services-plugins/issues/246 # to generate the Configuration Cache regardless of incompatible tasks. # See https://github.com/android/nowinandroid/issues/1022 before using it.