Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LD-161] Add coverage for components module and update excluded dirs. #203

Merged
merged 3 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,15 @@ 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' }}
id: jacoco
uses: madrapps/[email protected]
with:
paths: |
app/build/reports/jacoco/codeCoverage/codeCoverage.xml
*/build/reports/jacoco/codeCoverage/codeCoverage.xml
token: ${{ secrets.GITHUB_TOKEN }}

test-license-headers:
Expand Down
40 changes: 2 additions & 38 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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')

Expand Down
20 changes: 20 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}
}
}
}
}
9 changes: 9 additions & 0 deletions components/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ plugins {
alias(libs.plugins.kotlin.kapt)
}

apply from: '../module-jacoco.gradle'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
Expand Down Expand Up @@ -37,6 +39,13 @@ android {
arg("skipPrivatePreviews", "true")
}
}

buildTypes {
debug {
enableUnitTestCoverage true
testCoverageEnabled true
}
}
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
35 changes: 35 additions & 0 deletions module-jacoco.gradle
Original file line number Diff line number Diff line change
@@ -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"])
)
}
Loading