diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml index c51034de7..e265e4794 100644 --- a/.github/workflows/run-test.yml +++ b/.github/workflows/run-test.yml @@ -181,7 +181,7 @@ jobs: with: name: coverage-report path: | - app/build/reports/jacoco/codeCoverage + */build/reports/jacoco/codeCoverage - name: Add coverage to PR if: ${{ github.event_name != 'schedule' }} @@ -189,7 +189,7 @@ jobs: uses: madrapps/jacoco-report@v1.6.1 with: paths: | - app/build/reports/jacoco/codeCoverage/codeCoverage.xml + */build/reports/jacoco/codeCoverage/codeCoverage.xml token: ${{ secrets.GITHUB_TOKEN }} test-license-headers: diff --git a/app/build.gradle b/app/build.gradle index 52a1bbdde..c0e64ff18 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,9 +4,10 @@ plugins { alias(libs.plugins.kotlin.android) alias(libs.plugins.ktlint.gradle) alias(libs.plugins.kotlin.serialization) - id 'jacoco' } +apply from: '../module-jacoco.gradle' + def fileName = "../app/google-services.json" if (project.file(fileName).exists()) { @@ -102,43 +103,6 @@ android { } } -tasks.register('codeCoverage', JacocoReport) { - - reports { - html.required.set(true) - xml.required.set(true) - } - - classDirectories.setFrom( - fileTree(project.buildDir) { - include("**/tmp/kotlin-classes/debug/**") - exclude( - '**/R.class', - '**/R$*.class', - '**/BuildConfig.*', - "**/*Application.*", - '**/Manifest*.*', - '**/*Test*.*', - '**/android/**/*.*', - '**/androidx/**/*.*', - '**/airbnb/**/*.*', - "**/di/**/*.*", - '**/*Dagger*.*', - "**/*Screen*" - ) - } - ) - - sourceDirectories.setFrom( - fileTree(dir: project.projectDir, includes: ["src/main/java/**", "src/main/kotlin/**"]) - ) - - executionData.setFrom( - fileTree(dir: "${buildDir}/test-results/instrumentation_results", includes: ['*.ec']), - fileTree(dir: "${buildDir}/outputs/unit_test_code_coverage", includes: ["**/*.exec", "**/*.ec"]) - ) -} - dependencies { api project(':components') diff --git a/app/src/main/java/com/appunite/loudius/network/model/error/DefaultErrorResponse.kt b/app/src/main/java/com/appunite/loudius/network/model/error/DefaultErrorResponse.kt deleted file mode 100644 index b9103af3d..000000000 --- a/app/src/main/java/com/appunite/loudius/network/model/error/DefaultErrorResponse.kt +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2023 AppUnite S.A. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.appunite.loudius.network.model.error - -data class DefaultErrorResponse( - val message: String?, - val documentationUrl: String? -) diff --git a/build.gradle b/build.gradle index 9a0989887..c4f9c95bf 100644 --- a/build.gradle +++ b/build.gradle @@ -7,3 +7,23 @@ plugins { alias(libs.plugins.kotlin.kapt) apply false alias(libs.plugins.google.services) apply false } + +subprojects { + plugins.withId("app.cash.paparazzi") { + // Defer until afterEvaluate so that testImplementation is created by Android plugin. + afterEvaluate { + dependencies.constraints { + add("testImplementation", "com.google.guava:guava") { + attributes { + attribute( + TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE, + objects.named(TargetJvmEnvironment, TargetJvmEnvironment.STANDARD_JVM) + ) + } + because("LayoutLib and sdk-common depend on Guava's -jre published variant." + + "See https://github.com/cashapp/paparazzi/issues/906.") + } + } + } + } +} diff --git a/components/build.gradle b/components/build.gradle index 1a090f3d4..957da85e7 100644 --- a/components/build.gradle +++ b/components/build.gradle @@ -6,6 +6,8 @@ plugins { alias(libs.plugins.kotlin.kapt) } +apply from: '../module-jacoco.gradle' + java { toolchain { languageVersion = JavaLanguageVersion.of(17) @@ -37,6 +39,13 @@ android { arg("skipPrivatePreviews", "true") } } + + buildTypes { + debug { + enableUnitTestCoverage true + testCoverageEnabled true + } + } } dependencies { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c4fc320b4..1df93c5df 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -42,7 +42,7 @@ androidLibrary = "8.1.2" kotlin = "1.9.0" kotlinSerialization = "1.9.0" ktlintGradle = "11.6.1" -paparazzi = "1.3.1" +paparazzi = "1.3.2" totp = "1.7.1" uiTestJunit4 = "1.5.4" diff --git a/module-jacoco.gradle b/module-jacoco.gradle new file mode 100644 index 000000000..7fda6af50 --- /dev/null +++ b/module-jacoco.gradle @@ -0,0 +1,35 @@ +apply plugin: 'jacoco' + +tasks.register('codeCoverage', JacocoReport) { + + reports { + html.required.set(true) + xml.required.set(true) + } + + classDirectories.setFrom( + fileTree(project.buildDir) { + include("**/tmp/kotlin-classes/debug/**") + exclude( + '**/R.class', + '**/R$*.class', + '**/BuildConfig.*', + '**/Manifest*.*', + '**/airbnb/**/*.*', + "**/*Screen*", + "**/Showkase*", + "**/theme/Theme*", + "**/theme/Type*", + ) + } + ) + + sourceDirectories.setFrom( + fileTree(dir: project.projectDir, includes: ["src/main/java/**", "src/main/kotlin/**"]) + ) + + executionData.setFrom( + fileTree(dir: "${buildDir}/test-results/instrumentation_results", includes: ['*.ec']), + fileTree(dir: "${buildDir}/outputs/unit_test_code_coverage", includes: ["**/*.exec", "**/*.ec"]) + ) +}