Skip to content

Commit

Permalink
Add kover and gh action for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
turchenkoalex committed Jul 9, 2024
1 parent c9e2e0a commit 99a86fa
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 9 deletions.
35 changes: 31 additions & 4 deletions .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:

env:
JDK_VERSION: 21
GRADLE_OPTS: -Dorg.gradle.daemon=false

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand All @@ -16,8 +17,6 @@ jobs:
permissions:
contents: read
checks: write
env:
GRADLE_OPTS: -Dorg.gradle.daemon=false
steps:
- name: Checkout Code
uses: actions/checkout@v4
Expand All @@ -44,8 +43,6 @@ jobs:
# only required for workflows in private repositories
actions: read
contents: read
env:
GRADLE_OPTS: -Dorg.gradle.daemon=false
steps:
- name: Checkout Code
uses: actions/checkout@v4
Expand All @@ -62,3 +59,33 @@ jobs:
if: success() || failure() # always run even if the previous step fails
with:
path: 'build/reports/detekt/merge.xml'
coverage:
name: Coverage
runs-on: ubuntu-latest
permissions:
# required for all workflows
pull-requests: write
# only required for workflows in private repositories
actions: read
contents: read
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up JDK ${{ env.JDK_VERSION }}
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '${{ env.JDK_VERSION }}'
cache: 'gradle'
- name: Run Kover
run: ./gradlew koverXmlReport
- name: Publish Kover Report
uses: madrapps/[email protected]
if: success() || failure() # always run even if the previous step fails
with:
paths: |
${{ github.workspace }}/build/reports/kover/report.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 40
min-coverage-changed-files: 60
debug-mode: 'true'
46 changes: 42 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ plugins {
kotlin("jvm") version libs.versions.kotlin.get() apply false
kotlin("plugin.serialization") version libs.versions.kotlin.get() apply false
id("io.gitlab.arturbosch.detekt") version libs.versions.detekt.get()
id("org.jetbrains.kotlinx.kover") version libs.versions.kover.get()
}

// register task before using in subprojects
val reportMerge by tasks.registering(ReportMergeTask::class) {
output.set(rootProject.layout.buildDirectory.file("reports/detekt/merge.xml"))
}

// Detekt configuration
subprojects {
repositories {
mavenCentral()
}

apply(plugin = "io.gitlab.arturbosch.detekt")

detekt {
Expand Down Expand Up @@ -47,3 +45,43 @@ subprojects {
)
}
}

// Kover - coverage
allprojects {
apply(plugin = "org.jetbrains.kotlinx.kover")
}

kover {
reports {
filters {
excludes {
projects.add("sample")
}
}
total {
// configuring report tasks
verify {
rule {
minBound(90)
}
}
}

verify {
rule {
minBound(50)
}
}
}
}


dependencies {
kover(project(":core"))
kover(project(":cors"))
kover(project(":json"))
kover(project(":jwt"))
kover(project(":metrics"))
kover(project(":tracing"))
kover(project(":typesafe"))
}
7 changes: 6 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ include("tracing")
include("typesafe")

dependencyResolutionManagement {
repositories {
mavenCentral()
}

versionCatalogs {
create("libs") {
version("kotlin", "2.0.0")
version("detekt", "1.23.6")
version("kover", "0.8.2")

version("jakarta", "6.1.0")
library("jakarta-api", "jakarta.servlet", "jakarta.servlet-api").versionRef("jakarta")
Expand Down Expand Up @@ -74,4 +79,4 @@ dependencyResolutionManagement {
library("mockk", "io.mockk", "mockk").versionRef("mockk")
}
}
}
}

0 comments on commit 99a86fa

Please sign in to comment.