Skip to content

Upgraded Kover version to 0.7.0-Beta #3734

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

Merged
merged 4 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ buildscript {
classpath "com.github.node-gradle:gradle-node-plugin:$gradle_node_version"
classpath "org.jetbrains.kotlinx:binary-compatibility-validator:$binary_compatibility_validator_version"
classpath "ru.vyarus:gradle-animalsniffer-plugin:1.5.4" // Android API check
classpath "org.jetbrains.kotlinx:kover:$kover_version"
classpath "org.jetbrains.kotlin:atomicfu:$kotlin_version"
classpath "org.jetbrains.kotlinx:kover-gradle-plugin:$kover_version"

// JMH plugins
classpath "gradle.plugin.com.github.johnrengelman:shadow:7.1.2"
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ dependencies {
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
}
implementation("ru.vyarus:gradle-animalsniffer-plugin:1.5.3") // Android API check
implementation("org.jetbrains.kotlinx:kover:${version("kover")}") {
implementation("org.jetbrains.kotlinx:kover-gradle-plugin:${version("kover")}") {
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk7")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
Expand Down
70 changes: 47 additions & 23 deletions buildSrc/src/main/kotlin/kover-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import kotlinx.kover.api.*
import kotlinx.kover.tasks.*
import kotlinx.kover.gradle.plugin.dsl.*

/*
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
plugins {
id("org.jetbrains.kotlinx.kover")
}

val notCovered = sourceless + internal + unpublished

Expand All @@ -16,38 +18,60 @@ val expectedCoverage = mutableMapOf(
"kotlinx-coroutines-reactor" to 75
)

val conventionProject = project

subprojects {
val projectName = name
if (projectName in notCovered) return@subprojects
apply(plugin = "kover")

extensions.configure<KoverProjectConfig> {
project.apply(plugin = "org.jetbrains.kotlinx.kover")
conventionProject.dependencies.add("kover", this)

extensions.configure<KoverProjectExtension>("kover") {
/*
* Is explicitly enabled on TC in a separate build step.
* Examples:
* ./gradlew :p:check -- doesn't verify coverage
* ./gradlew :p:check -Pkover.enabled=true -- verifies coverage
* ./gradlew :p:koverReport -Pkover.enabled=true -- generates report
*/
isDisabled.set(!(properties["kover.enabled"]?.toString()?.toBoolean() ?: false))
* Is explicitly enabled on TC in a separate build step.
* Examples:
* ./gradlew :p:check -- doesn't verify coverage
* ./gradlew :p:check -Pkover.enabled=true -- verifies coverage
* ./gradlew :p:koverHtmlReport -Pkover.enabled=true -- generates HTML report
*/
if (properties["kover.enabled"]?.toString()?.toBoolean() != true) {
disable()
}
}

verify {
rule {
bound {
extensions.configure<KoverReportExtension>("koverReport") {
defaults {
html {
setReportDir(conventionProject.layout.buildDirectory.dir("kover/${project.name}/html"))
}

verify {
rule {
/*
* 85 is our baseline that we aim to raise to 90+.
* Missing coverage is typically due to bugs in the agent
* (e.g. signatures deprecated with an error are counted),
* sometimes it's various diagnostic `toString` or `catch` for OOMs/VerificationErrors,
* but some places are definitely worth visiting.
*/
minValue = expectedCoverage[projectName] ?: 85 // COVERED_LINES_PERCENTAGE
* 85 is our baseline that we aim to raise to 90+.
* Missing coverage is typically due to bugs in the agent
* (e.g. signatures deprecated with an error are counted),
* sometimes it's various diagnostic `toString` or `catch` for OOMs/VerificationErrors,
* but some places are definitely worth visiting.
*/
minBound(expectedCoverage[projectName] ?: 85) // COVERED_LINES_PERCENTAGE
}
}
}
}
}

htmlReport {
reportDir.set(file(rootProject.buildDir.toString() + "/kover/" + project.name + "/html"))
koverReport {
defaults {
verify {
rule {
minBound(85) // COVERED_LINES_PERCENTAGE
}
}
}
}

conventionProject.tasks.register("koverReport") {
dependsOn(conventionProject.tasks.named("koverHtmlReport"))
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ rxjava3_version=3.0.2
javafx_version=17.0.2
javafx_plugin_version=0.0.8
binary_compatibility_validator_version=0.12.0
kover_version=0.6.1
kover_version=0.7.0-Beta
blockhound_version=1.0.2.RELEASE
jna_version=5.9.0

Expand Down
26 changes: 22 additions & 4 deletions kotlinx-coroutines-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

apply plugin: 'org.jetbrains.kotlin.multiplatform'
apply plugin: 'org.jetbrains.dokka'

// apply plugin to use autocomplete for Kover DSL
apply plugin: 'org.jetbrains.kotlinx.kover'

apply from: rootProject.file("gradle/compile-jvm-multiplatform.gradle")
apply from: rootProject.file("gradle/compile-common.gradle")

Expand Down Expand Up @@ -320,12 +324,26 @@ def commonKoverExcludes =
]

kover {
instrumentation {
excludeTasks.add("jvmLincheckTest") // Always disabled, lincheck doesn't really support coverage
excludeTests {
// Always disabled, lincheck doesn't really support coverage
tasks("jvmLincheckTest")
}

excludeInstrumentation {
// lincheck has NPE error on `ManagedStrategyStateHolder` class
classes("org.jetbrains.kotlinx.lincheck.*")
}
}

koverReport {
filters {
classes {
excludes.addAll(commonKoverExcludes)
excludes {
classes(
"kotlinx.coroutines.debug.*", // Tested by debug module
"kotlinx.coroutines.channels.ChannelsKt__DeprecatedKt.*", // Deprecated
"kotlinx.coroutines.scheduling.LimitingDispatcher", // Deprecated
"kotlinx.coroutines.scheduling.ExperimentalCoroutineDispatcher" // Deprecated
)
}
}
}
Expand Down
20 changes: 10 additions & 10 deletions kotlinx-coroutines-debug/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

apply plugin: "com.github.johnrengelman.shadow"

// apply plugin to use autocomplete for Kover DSL
apply plugin: 'org.jetbrains.kotlinx.kover'

configurations {
shadowDeps // shaded dependencies, not included into the resulting .pom file
compileOnly.extendsFrom(shadowDeps)
Expand Down Expand Up @@ -53,14 +56,11 @@ configurations {
}
}

def commonKoverExcludes =
// Never used, safety mechanism
["kotlinx.coroutines.debug.internal.NoOpProbesKt"]

tasks.koverHtmlReport {
excludes = commonKoverExcludes
}

tasks.koverVerify {
excludes = commonKoverExcludes
koverReport {
filters {
excludes {
// Never used, safety mechanism
classes("kotlinx.coroutines.debug.internal.NoOpProbesKt")
}
}
}
23 changes: 14 additions & 9 deletions reactive/kotlinx-coroutines-reactive/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import kotlinx.kover.gradle.plugin.dsl.*

/*
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

plugins {
// apply plugin to use autocomplete for Kover DSL
id("org.jetbrains.kotlinx.kover")
}

val reactiveStreamsVersion = property("reactive_streams_version")

dependencies {
Expand Down Expand Up @@ -35,16 +42,14 @@ externalDocumentationLink(
url = "https://www.reactive-streams.org/reactive-streams-$reactiveStreamsVersion-javadoc/"
)

val commonKoverExcludes = listOf(
"kotlinx.coroutines.reactive.FlowKt", // Deprecated
"kotlinx.coroutines.reactive.FlowKt__MigrationKt", // Deprecated
"kotlinx.coroutines.reactive.ConvertKt" // Deprecated
)

kover {
koverReport {
filters {
classes {
excludes += commonKoverExcludes
excludes {
classes(
"kotlinx.coroutines.reactive.FlowKt", // Deprecated
"kotlinx.coroutines.reactive.FlowKt__MigrationKt", // Deprecated
"kotlinx.coroutines.reactive.ConvertKt" // Deprecated
)
}
}
}
18 changes: 11 additions & 7 deletions reactive/kotlinx-coroutines-reactor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

plugins {
// apply plugin to use autocomplete for Kover DSL
id("org.jetbrains.kotlinx.kover")
}

val reactorVersion = version("reactor")

dependencies {
Expand All @@ -28,15 +33,14 @@ externalDocumentationLink(
url = "https://projectreactor.io/docs/core/$reactorVersion/api/"
)

val commonKoverExcludes = listOf(
"kotlinx.coroutines.reactor.FlowKt", // Deprecated
"kotlinx.coroutines.reactor.ConvertKt\$asFlux$1" // Deprecated
)

kover {
koverReport {
filters {
classes {
excludes += commonKoverExcludes
excludes {
classes(
"kotlinx.coroutines.reactor.FlowKt", // Deprecated
"kotlinx.coroutines.reactor.ConvertKt\$asFlux$1" // Deprecated
)
}
}
}
6 changes: 0 additions & 6 deletions ui/kotlinx-coroutines-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,3 @@ open class RunR8 : JavaExec() {
super.exec()
}
}

tasks.withType<Test> {
extensions.configure<KoverTaskExtension> {
excludes.addAll(listOf("com.android.*", "android.*")) // Exclude robolectric-generated classes
}
}