Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Add Kover Code Coverage (#2794)
Browse files Browse the repository at this point in the history
* build : add kover code coverage gradle plugin

* ci : add kover gradle task in github action
  • Loading branch information
SURAJ2600 authored Oct 19, 2023
1 parent c166a17 commit 9fe7ff9
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 2 deletions.
33 changes: 32 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,35 @@ jobs:
${{ runner.os }}-gradle-
- name: Run unit tests
run: ./gradlew testDebugUnitTest
run: ./gradlew testDebugUnitTest

code_coverage:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout GIT
uses: actions/checkout@v4

- name: Setup Java SDK
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '18'

- name: Enable Gradle Wrapper caching (optimization)
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Code Coverage
run: ./gradlew koverHtmlReport

- name: Upload Code Coverage Report
uses: actions/upload-artifact@v2
with:
name: code-coverage-report
path: app/build/artifacts/reports/kover/coverageResults/index.html
43 changes: 43 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,46 @@ dependencies {

lintChecks(libs.slack.lint.compose)
}

dependencies {
koverReport {
defaults {
mergeWith("debug")
html {
onCheck = false
setReportDir(layout.buildDirectory.dir("artifacts/reports/kover/coverageResults"))
}
}
}

kover(projects.ivyBase)
kover(projects.ivyData)
kover(projects.ivyDomain)
kover(projects.ivyNavigation)
kover(projects.ivyResources)
kover(projects.ivyWidgetBase)
kover(projects.screenAttributions)
kover(projects.screenBalance)
kover(projects.screenBudgets)
kover(projects.screenCategories)
kover(projects.screenContributors)
kover(projects.screenExchangeRates)
kover(projects.screenFeatures)
kover(projects.screenHome)
kover(projects.screenImportData)
kover(projects.screenLoans)
kover(projects.screenMain)
kover(projects.screenOnboarding)
kover(projects.screenPiechart)
kover(projects.screenPlannedPayments)
kover(projects.screenReleases)
kover(projects.screenReports)
kover(projects.screenSearch)
kover(projects.screenSettings)
kover(projects.screenTransaction)
kover(projects.screenTransactions)
kover(projects.tempLegacyCode)
kover(projects.tempOldDesign)
kover(projects.widgetAddTransaction)
kover(projects.widgetBalance)
}
22 changes: 22 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,28 @@ plugins {
id("ivy.detekt")

alias(libs.plugins.gradleWrapperUpgrade)

alias(libs.plugins.koverPlugin)
}

subprojects {
apply(plugin = "org.jetbrains.kotlinx.kover")
koverReport {
// filters for all report types of all build variants
filters {
excludes {
classes(
"*Activity",
"*Activity\$*",
"*.BuildConfig",
"dagger.hilt.*",
"hilt_aggregated_deps.*",
"*.Hilt_*"
)
annotatedBy("@Composable")
}
}
}
}

wrapperUpgrade {
Expand Down
3 changes: 2 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,5 @@ opencsv = [
]

[plugins]
gradleWrapperUpgrade = { id = "org.gradle.wrapper-upgrade", version = "0.11.4" }
gradleWrapperUpgrade = { id = "org.gradle.wrapper-upgrade", version = "0.11.4" }
koverPlugin = { id = "org.jetbrains.kotlinx.kover", version = "0.7.4" }

0 comments on commit 9fe7ff9

Please sign in to comment.