From 7853bf147387eb8476856edd0ca246c682c7de62 Mon Sep 17 00:00:00 2001 From: Erik Eelde Date: Fri, 3 May 2024 11:57:36 +0200 Subject: [PATCH] Run tests on emulator --- .github/workflows/pull-request.yml | 42 +++++++++++++++++++++ build-logic/conventions/settings.gradle.kts | 2 +- gradle/libs.versions.toml | 14 ++++--- gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle.kts | 2 +- toggles-app/build.gradle.kts | 21 +++++++++++ toggles-core/settings.gradle.kts | 2 +- toggles-flow-noop/settings.gradle.kts | 2 +- toggles-flow/settings.gradle.kts | 2 +- toggles-prefs-noop/settings.gradle.kts | 2 +- toggles-prefs/settings.gradle.kts | 2 +- 11 files changed, 79 insertions(+), 14 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index e3014cce..8562a9dd 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -55,3 +55,45 @@ jobs: name: Reports path: '**/build/reports/*' retention-days: 2 + + + emulator-tests: + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: '0' + + - name: Check out java + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: 17 + + - name: Copy CI gradle.properties + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + + - name: Enable KVM group perms + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + + - name: run tests + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 30 + script: ./gradlew :toggles-app:pixel2api30DebugAndroidTest + + - name: "Upload reports" + uses: actions/upload-artifact@v4 + if: failure() + with: + name: "Android test results" + path: '**/build/reports/*' + retention-days: 2 \ No newline at end of file diff --git a/build-logic/conventions/settings.gradle.kts b/build-logic/conventions/settings.gradle.kts index 427ea61f..ccaf1d0e 100644 --- a/build-logic/conventions/settings.gradle.kts +++ b/build-logic/conventions/settings.gradle.kts @@ -23,6 +23,6 @@ dependencyResolutionManagement { } plugins { - id("com.gradle.enterprise") version "3.16.1" + id("com.gradle.develocity") version "3.17.2" id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0") } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 847daf37..f0106919 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,11 +1,11 @@ [versions] -agp = "8.2.1" +agp = "8.4.0" androidx-activity = "1.7.1" androidx-appcompat = "1.6.1" androidx-arch-core = "2.2.0" androidx-collection = "1.1.0" -androidx-compose-bom = "2023.10.01" -androidx-compose-compiler = "1.5.8" +androidx-compose-bom = "2024.05.00" +androidx-compose-compiler = "1.5.13" androidx-core = "1.10.0" androidx-hilt = "1.0.0" androidx-lifecycle = "2.6.1" @@ -20,7 +20,8 @@ com-squareup-moshi = "1.15.0" dokka = "1.9.0" espresso-core = "3.5.1" junit = "4.13.2" -kotlin = "1.9.22" +kotlin = "1.9.23" +orchestrator = "1.4.2" org-jetbrains-kotlinx = "1.6.4" [libraries] @@ -80,6 +81,7 @@ androidx-navigation-navigation-common-ktx = { module = "androidx.navigation:navi androidx-navigation-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "androidx-navigation" } androidx-navigation-navigation-runtime = { module = "androidx.navigation:navigation-runtime", version.ref = "androidx-navigation" } androidx-navigation-navigation-runtime-ktx = { module = "androidx.navigation:navigation-runtime-ktx", version.ref = "androidx-navigation" } +androidx-test-orchestrator = { module = "androidx.test:orchestrator", version.ref = "orchestrator" } androidx-room-room-compiler = { module = "androidx.room:room-compiler", version.ref = "androidx-room" } androidx-room-room-ktx = { module = "androidx.room:room-ktx", version.ref = "androidx-room" } androidx-room-room-runtime = { module = "androidx.room:room-runtime", version.ref = "androidx-room" } @@ -99,7 +101,7 @@ androidx-vectordrawable-vectordrawable-animated = { module = "androidx.vectordra androidx-versionedparcelable = "androidx.versionedparcelable:versionedparcelable:1.1.1" androidx-viewpager = "androidx.viewpager:viewpager:1.0.0" app-cash-licensee-licensee-gradle-plugin = "app.cash.licensee:licensee-gradle-plugin:1.8.0" -com-android-tools-build-gradle = "com.android.tools.build:gradle:8.2.1" +com-android-tools-build-gradle = "com.android.tools.build:gradle:8.4.0" com-google-code-findbugs-jsr305 = "com.google.code.findbugs:jsr305:3.0.2" com-google-dagger = { module = "com.google.dagger:dagger", version.ref = "com-google-dagger" } com-google-dagger-dagger-compiler = { module = "com.google.dagger:dagger-compiler", version.ref = "com-google-dagger" } @@ -140,7 +142,7 @@ com-autonomousapps-dependency-analysis = "com.autonomousapps.dependency-analysis com-github-ben-manes-versions = "com.github.ben-manes.versions:0.50.0" com-github-triplet-play = "com.github.triplet.play:3.8.4" com-google-dagger-hilt-android = { id = "com.google.dagger.hilt.android", version.ref = "com-google-dagger" } -com-google-devtools-ksp = "com.google.devtools.ksp:1.9.22-1.0.16" +com-google-devtools-ksp = "com.google.devtools.ksp:1.9.23-1.0.20" com-google-firebase-crashlytics = "com.google.firebase.crashlytics:2.9.8" com-google-gms-google-services = "com.google.gms.google-services:4.3.15" com-vanniktech-maven-publish = "com.vanniktech.maven.publish:0.27.0" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1af9e093..b82aa23a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle.kts b/settings.gradle.kts index d596e8c9..58542d55 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -10,7 +10,7 @@ pluginManagement { } plugins { - id("com.gradle.enterprise") version "3.16.1" + id("com.gradle.develocity") version "3.17.2" id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0") } diff --git a/toggles-app/build.gradle.kts b/toggles-app/build.gradle.kts index 01730a1b..91c47b18 100644 --- a/toggles-app/build.gradle.kts +++ b/toggles-app/build.gradle.kts @@ -96,6 +96,26 @@ android { versionNameSuffix = " debug" } } + testOptions { + animationsDisabled = true + execution = "ANDROIDX_TEST_ORCHESTRATOR" + unitTests { + isReturnDefaultValues = true + isIncludeAndroidResources = true + } + managedDevices { + devices { + maybeCreate("pixel2api30").apply { + // Use device profiles you typically see in Android Studio. + device = "Pixel 2" + // Use only API levels 30 and higher. + apiLevel = 30 + // To include Google services, use "google". + systemImageSource = "aosp" + } + } + } + } } dependencies { @@ -167,4 +187,5 @@ dependencies { androidTestImplementation(libs.androidx.test.ext.junit) androidTestImplementation(platform(libs.androidx.compose.bom)) androidTestImplementation(libs.androidx.compose.ui.ui.test.junit4) + androidTestUtil(libs.androidx.test.orchestrator) } diff --git a/toggles-core/settings.gradle.kts b/toggles-core/settings.gradle.kts index af96acbd..37bb79c8 100644 --- a/toggles-core/settings.gradle.kts +++ b/toggles-core/settings.gradle.kts @@ -23,7 +23,7 @@ pluginManagement { } plugins { - id("com.gradle.enterprise") version "3.16.1" + id("com.gradle.develocity") version "3.17.2" id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0") } diff --git a/toggles-flow-noop/settings.gradle.kts b/toggles-flow-noop/settings.gradle.kts index 441fef75..ea369170 100644 --- a/toggles-flow-noop/settings.gradle.kts +++ b/toggles-flow-noop/settings.gradle.kts @@ -23,7 +23,7 @@ pluginManagement { } plugins { - id("com.gradle.enterprise") version "3.16.1" + id("com.gradle.develocity") version "3.17.2" id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0") } diff --git a/toggles-flow/settings.gradle.kts b/toggles-flow/settings.gradle.kts index a10920c2..27045de3 100644 --- a/toggles-flow/settings.gradle.kts +++ b/toggles-flow/settings.gradle.kts @@ -23,7 +23,7 @@ pluginManagement { } plugins { - id("com.gradle.enterprise") version "3.16.1" + id("com.gradle.develocity") version "3.17.2" id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0") } diff --git a/toggles-prefs-noop/settings.gradle.kts b/toggles-prefs-noop/settings.gradle.kts index a51331da..fde910b2 100644 --- a/toggles-prefs-noop/settings.gradle.kts +++ b/toggles-prefs-noop/settings.gradle.kts @@ -23,7 +23,7 @@ pluginManagement { } plugins { - id("com.gradle.enterprise") version "3.16.1" + id("com.gradle.develocity") version "3.17.2" id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0") } diff --git a/toggles-prefs/settings.gradle.kts b/toggles-prefs/settings.gradle.kts index fdd6a980..149465de 100644 --- a/toggles-prefs/settings.gradle.kts +++ b/toggles-prefs/settings.gradle.kts @@ -23,7 +23,7 @@ pluginManagement { } plugins { - id("com.gradle.enterprise") version "3.16.1" + id("com.gradle.develocity") version "3.17.2" id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0") }