Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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/review_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ jobs:
- name: Run Android Lint
run: ./gradlew lint

- name: Run unit tests and Jacoco
run: ./gradlew jacocoTestReport
- name: Run unit tests with Kover
run: ./gradlew koverXmlReportCustom

- name: Set up Ruby
uses: ruby/setup-ruby@v1
Expand Down
15 changes: 6 additions & 9 deletions Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ Dir[lint_dir].each do |file_name|
android_lint.lint(inline_mode: true)
end

# TODO: Update to support test coverage report from Jacoco for Coroutine Template
# Show Danger test coverage report from Jacoco for RxJavaTemplate
jacoco_dir = "RxJavaTemplate/**/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml"
markdown "## RxJavaTemplate Jacoco report:"
Dir[jacoco_dir].each do |file_name|
# Report coverage of modified files, warn if total project coverage is under 80%
# or if any modified file's coverage is under 95%
shroud.report file_name, 80, 95, false
end
# Show Danger test coverage report from Kover
# Report coverage of modified files, warn if total project coverage is under 80%
# or if any modified file's coverage is under 95%
kover_file = "app/build/reports/kover/reportCustom.xml"
markdown "## Kover report for Android Common Extensions"
shroud.reportKover moduleName: "Android Common Extensions Unit Tests", file: kover_file, totalProjectThreshold: 80, modifiedFileThreshold: 95, failIfUnderProjectThreshold: false, failIfUnderFileThreshold: false
15 changes: 15 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,18 @@ dependencies {
androidTestImplementation(libs.test.ext.junit)
androidTestImplementation(libs.test.espresso.core)
}

/*
* Kover configs
*/
dependencies {
kover(projects.commonKtx)
}

kover {
currentProject {
createVariant("custom") {
add("debug")
}
}
}
118 changes: 42 additions & 76 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import org.gradle.api.tasks.testing.Test
import kotlinx.kover.gradle.plugin.dsl.KoverProjectExtension

plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kover) apply false
alias(libs.plugins.detekt)
jacoco
}

dependencies {
Expand All @@ -31,81 +31,47 @@ detekt {
ignoredFlavors = listOf("production")
}

jacoco {
toolVersion = libs.versions.jacoco.get()
}

val fileGenerated = listOf(
"android/**/*.*",
"**/R.class",
"**/R\$*.class",
"**/*\$ViewBinder*.*",
"**/*\$InjectAdapter*.*",
"**/*Injector*.*",
"**/BuildConfig.*",
"**/Manifest*.*",
"**/*_ViewBinding*.*",
"**/*_Factory*.*",
"**/app/ui/screens/**/*DiffCallback*.*",
"**/*Test*.*",
// navigation component
"**/*FragmentArgs*",
"**/*FragmentDirections*",
"**/FragmentNavArgsLazy.kt",
"**/*Fragment*navArgs*",
"**/screens/common/StartFragment.*",
// kotlin enum Creator
"**/*\$Creator*"
)

val packagesExcluded = listOf(
"co/nimblehq/extensions/app/**",
"com/bumptech/glide"
)

val fileFilter = fileGenerated + packagesExcluded

tasks.register<JacocoReport>("jacocoTestReport") {
group = "Reporting"
description = "Generate Jacoco coverage reports for Debug build"

dependsOn(":app:testDebugUnitTest")
dependsOn(":common-ktx:testDebugUnitTest")

classDirectories.setFrom(
fileTree("${project.rootDir}/app/build/intermediates/javac/debug/classes") {
exclude(fileFilter)
},
fileTree("${project.rootDir}/common-ktx/build/intermediates/javac/debug/classes") {
exclude(fileFilter)
},
fileTree("${project.rootDir}/app/build/tmp/kotlin-classes/debug") {
exclude(fileFilter)
},
fileTree("${project.rootDir}/common-ktx/build/tmp/kotlin-classes/debug") {
exclude(fileFilter)
subprojects {
apply(plugin = "org.jetbrains.kotlinx.kover")
configure<KoverProjectExtension> {
reports {
filters {
excludes {
androidGeneratedClasses()
annotatedBy(
"androidx.annotation.VisibleForTesting"
)
classes(
// View Binding & Data Binding
"**/*_ViewBinding*",
"**/*_Factory*",
"**/*\$ViewBinder*",
"**/*\$InjectAdapter*",
"**/*Injector*",
"*.*_ComponentTreeDeps*",
"*.*_HiltComponents*",
"*.*_MembersInjector*",
"*\$InstanceHolder",
// Navigation Component
"**/*FragmentArgs*",
"**/*FragmentDirections*",
"**/FragmentNavArgsLazy*",
"**/*Fragment*navArgs*",
"**/screens/common/StartFragment*",
Comment on lines +56 to +60
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note: We will need to remove/update the exclusive files later on as there are many files out of dated.

// DiffCallback
"**/app/ui/screens/**/*DiffCallback*",
// Kotlin Enum Creator
"*.*\$Creator*",
// Test files
"**/*Test*"
)
packages(
"co.nimblehq.extensions.app",
"com.bumptech.glide"
)
}
}
}
)

sourceDirectories.setFrom(
files(
"${project.rootDir}/app/src/main/java",
"${project.rootDir}/common-ktx/src/main/java"
)
)

executionData.setFrom(
fileTree(project.rootDir) {
include(
"app/build/jacoco/testDebugUnitTest.exec",
"common-ktx/build/jacoco/testDebugUnitTest.exec"
)
}
)

reports {
xml.required.set(true)
html.required.set(true)
}
}

Expand Down
8 changes: 8 additions & 0 deletions common-ktx/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,11 @@ afterEvaluate {
}
}
}

kover {
currentProject {
createVariant("custom") {
add("debug")
}
}
}
3 changes: 2 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ detekt = "1.23.8"
gradle = "8.13.0"
gson = "2.8.9"
hamcrest = "1.3"
jacoco = "0.8.12"
kover = "0.9.3"
junit = "4.13.2"
kotlin = "2.2.21"
material = "1.4.0"
Expand Down Expand Up @@ -43,3 +43,4 @@ android-application = { id = "com.android.application", version.ref = "gradle" }
android-library = { id = "com.android.library", version.ref = "gradle" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
4 changes: 3 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ dependencyResolutionManagement {
}
}

rootProject.name = "Android Extensions"
rootProject.name = "AndroidExtensions"
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

include(":app")
include(":common-ktx")