Skip to content

A fully functional Android app built entirely with Kotlin and Jetpack Compose

[CI] Better caching and fewer jobs run

Jose Alcérreca3f22248cb734
diff --git a/.github/workflows/Build.yaml b/.github/workflows/Build.yaml
index ccea5dc4f..dec4dedcc 100644
--- a/.github/workflows/Build.yaml
+++ b/.github/workflows/Build.yaml
@@ -11,45 +11,8 @@ concurrency:
cancel-in-progress: true
jobs:
- build:
- runs-on: ubuntu-latest
- timeout-minutes: 90
-
- steps:
- - name: Checkout
- uses: actions/checkout@v4
-
- - name: Validate Gradle Wrapper
- uses: gradle/wrapper-validation-action@v1
-
- - name: Copy CI gradle.properties
- run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
-
- - name: Set up JDK 17
- uses: actions/setup-java@v3
- with:
- distribution: 'zulu'
- java-version: 17
-
- - name: Setup Gradle
- uses: gradle/gradle-build-action@v2
-
- - name: Check spotless
- run: ./gradlew spotlessCheck --init-script gradle/init.gradle.kts --no-configuration-cache
-
- - name: Build all build type and flavor permutations
- run: ./gradlew assemble
-
- - name: Upload build outputs (APKs)
- uses: actions/upload-artifact@v3
- with:
- name: APKs
- path: '**/build/outputs/apk/**/*.apk'
-
- - name: Run local tests
- run: ./gradlew testDemoDebug testProdDebug :lint:test
-
- test:
+ test_and_apk:
+ name: "Local tests and APKs"
runs-on: ubuntu-latest
permissions:
@@ -76,6 +39,9 @@ jobs:
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
+ - name: Check spotless
+ run: ./gradlew spotlessCheck --init-script gradle/init.gradle.kts --no-configuration-cache
+
- name: Run all local screenshot tests (Roborazzi)
id: screenshotsverify
continue-on-error: true
@@ -106,7 +72,16 @@ jobs:
# Run local tests after screenshot tests to avoid wrong UP-TO-DATE. TODO: Ignore screenshots.
- name: Run local tests
if: always()
- run: ./gradlew testDemoDebug testProdDebug
+ run: ./gradlew testDemoDebug testProdDebug :lint:test
+
+ - name: Build all build type and flavor permutations
+ run: ./gradlew assemble
+
+ - name: Upload build outputs (APKs)
+ uses: actions/upload-artifact@v3
+ with:
+ name: APKs
+ path: '**/build/outputs/apk/**/*.apk'
- name: Upload test results (XML)
if: always()
@@ -129,7 +104,6 @@ jobs:
run: ./gradlew :app:checkProdReleaseBadging
androidTest:
- needs: build
runs-on: macOS-latest # enables hardware acceleration in the virtual machine
timeout-minutes: 55
strategy:
@@ -152,8 +126,8 @@ jobs:
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- - name: Build AndroidTest apps
- run: ./gradlew packageDemoDebug packageDemoDebugAndroidTest --daemon
+ - name: Build projects before running emulator
+ run: ./gradlew packageDemoDebug packageDemoDebugAndroidTest
- name: Run instrumentation tests
uses: reactivecircus/android-emulator-runner@v2
diff --git a/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/NavigationTest.kt b/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/NavigationTest.kt
index e1eab4796..5861cda58 100644
--- a/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/NavigationTest.kt
+++ b/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/NavigationTest.kt
@@ -42,7 +42,7 @@ import dagger.hilt.android.testing.BindValue
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import kotlinx.coroutines.flow.first
-import kotlinx.coroutines.test.runTest
+import kotlinx.coroutines.runBlocking
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@@ -265,12 +265,14 @@ class NavigationTest {
}
@Test
- fun navigationBar_multipleBackStackInterests() = runTest {
+ fun navigationBar_multipleBackStackInterests() {
composeTestRule.apply {
onNodeWithText(interests).performClick()
// Select the last topic
- val topic = topicsRepository.getTopics().first().sortedBy(Topic::name).last().name
+ val topic = runBlocking {
+ topicsRepository.getTopics().first().sortedBy(Topic::name).last().name
+ }
onNodeWithTag("interests:topics").performScrollToNode(hasText(topic))
onNodeWithText(topic).performClick()
diff --git a/gradle.properties b/gradle.properties
index c4159cfea..c0acfeb02 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -23,6 +23,10 @@ org.gradle.caching=true
# Enable configuration caching between builds.
org.gradle.configuration-cache=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.
+org.gradle.configuration-cache.problems=warn
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK