[CI] Better caching and fewer jobs run

* [CI] Runs build in macos to generate a cache for androidTest runs

* Build projects before running emulator

* Fixes flaky coroutines test

* Moves spotless up in local tests job

* Enables config cache by setting problems to warn. Fixes #1022
ja/no-op
Jose Alcérreca 8 months ago committed by GitHub
parent 5f5bd91a68
commit 3f22248cb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

@ -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()

@ -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

Loading…
Cancel
Save