summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-04-04 16:10:32 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2022-04-04 16:37:29 +0200
commit527ae2230f5c2dd22f496f45d5d8e3bd4acdb854 (patch)
tree4fda128ee6b30018c1aa14c584cc53ade80e67f7
parentaac62bb0d95d469306bd586cedcc7ee01c888a6e (diff)
ci: Fix JaCoCo report aggregation
This change updates the build script to fix the aggregation step for the JaCoCo coverage reports that are submitted to Codecov. Previously, not all modules were properly included in the report.
-rw-r--r--.github/workflows/build.yml2
-rw-r--r--buildSrc/src/main/kotlin/jacoco-aggregation.gradle.kts34
-rw-r--r--opendc-web/opendc-web-api/build.gradle.kts3
3 files changed, 18 insertions, 21 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 83b6911a..bc30d584 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -55,7 +55,7 @@ jobs:
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
- files: ./build/reports/jacoco/report.xml
+ files: ./build/reports/jacoco/codeCoverageReport/codeCoverageReport.xml
build-ui:
name: Build UI (Node ${{ matrix.node }})
runs-on: ${{ matrix.os }}
diff --git a/buildSrc/src/main/kotlin/jacoco-aggregation.gradle.kts b/buildSrc/src/main/kotlin/jacoco-aggregation.gradle.kts
index 5afd3e0d..7ae42cd2 100644
--- a/buildSrc/src/main/kotlin/jacoco-aggregation.gradle.kts
+++ b/buildSrc/src/main/kotlin/jacoco-aggregation.gradle.kts
@@ -22,7 +22,8 @@
plugins {
- jacoco
+ base
+ id("jacoco-report-aggregation")
}
repositories {
@@ -30,25 +31,20 @@ repositories {
mavenCentral()
}
-tasks.register<JacocoReport>("codeCoverageReport") {
- group = "Coverage reports"
- description = "Generates an aggregate report based on all subprojects"
-
- reports {
- xml.required.set(true)
- xml.outputLocation.set(file("${buildDir}/reports/jacoco/report.xml"))
-
- html.required.set(true)
- }
-
+dependencies {
subprojects {
- this@subprojects.plugins.withType<JacocoPlugin>().configureEach {
- this@subprojects.tasks.matching {
- it.extensions.findByType<JacocoTaskExtension>() != null }
- .configureEach {
- sourceSets(this@subprojects.the<SourceSetContainer>().named("main").get())
- executionData(this)
- }
+ plugins.withType<JacocoPlugin>().configureEach {
+ jacocoAggregation(this@subprojects)
}
+
}
}
+
+@Suppress("UnstableApiUsage")
+val codeCoverageReport by reporting.reports.creating(JacocoCoverageReport::class) {
+ testType.set(TestSuiteType.UNIT_TEST)
+}
+
+tasks.check {
+ dependsOn(codeCoverageReport.reportTask)
+}
diff --git a/opendc-web/opendc-web-api/build.gradle.kts b/opendc-web/opendc-web-api/build.gradle.kts
index 488ce8af..853632a7 100644
--- a/opendc-web/opendc-web-api/build.gradle.kts
+++ b/opendc-web/opendc-web-api/build.gradle.kts
@@ -53,6 +53,7 @@ dependencies {
testImplementation(libs.quarkus.junit5.core)
testImplementation(libs.quarkus.junit5.mockk)
+ testImplementation(libs.quarkus.jacoco)
testImplementation(libs.restassured.core)
testImplementation(libs.restassured.kotlin)
testImplementation(libs.quarkus.test.security)
@@ -77,7 +78,7 @@ tasks.quarkusDev {
tasks.test {
extensions.configure(JacocoTaskExtension::class) {
excludeClassLoaders = listOf("*QuarkusClassLoader")
- destinationFile = layout.buildDirectory.file("jacoco-quarkus.exec").get().asFile
+ // destinationFile = layout.buildDirectory.file("jacoco-quarkus.exec").get().asFile
}
}