-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathkover-conventions.gradle.kts
78 lines (66 loc) · 2.51 KB
/
kover-conventions.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import kotlinx.kover.gradle.plugin.dsl.*
plugins {
id("org.jetbrains.kotlinx.kover")
}
val notCovered = sourceless + unpublished
val expectedCoverage = mutableMapOf(
// These have lower coverage in general, it can be eventually fixed
"kotlinx-coroutines-swing" to 70, // awaitFrame is not tested
"kotlinx-coroutines-javafx" to 35, // JavaFx is not tested on TC because its graphic subsystem cannot be initialized in headless mode
// Reactor has lower coverage in general due to various fatal error handling features
"kotlinx-coroutines-reactor" to 75
)
val conventionProject = project
subprojects {
val projectName = name
if (projectName in notCovered) return@subprojects
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:koverHtmlReport -Pkover.enabled=true -- generates HTML report
*/
if (properties["kover.enabled"]?.toString()?.toBoolean() != true) {
disable()
}
}
extensions.configure<KoverProjectExtension>("kover") {
reports {
total {
html {
htmlDir = 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.
*/
minBound(expectedCoverage[projectName] ?: 85) // COVERED_LINES_PERCENTAGE
}
}
}
}
}
}
kover {
reports {
total {
verify {
rule {
minBound(85) // COVERED_LINES_PERCENTAGE
}
}
}
}
}
conventionProject.tasks.register("koverReport") {
dependsOn(conventionProject.tasks.named("koverHtmlReport"))
}