Skip to content
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

Add code coverage report to build #661

Merged
merged 12 commits into from
Oct 2, 2024
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,11 @@ jobs:
name: test-reports-jdk-${{ matrix.java_version }}
path: |
**/build/reports/tests/test

- name : Publish code coverage report
if: success()
uses : actions/upload-artifact@v4
with :
name : code-coverage-reports-jdk-${{ matrix.java_version }}
path : |
**/build/reports/jacoco/test
21 changes: 21 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ plugins {
id "io.micronaut.minimal.application" version "3.7.0"
id "com.google.cloud.tools.jib" version "3.4.2"
id 'org.asciidoctor.jvm.convert' version '3.3.2'
id 'jacoco'
}

String gitVersion() {
Expand Down Expand Up @@ -183,3 +184,23 @@ task buildInfo { doLast {
buildInfo.dependsOn processResources
compileGroovy.dependsOn buildInfo

jacoco {
toolVersion '0.8.12'
}
/**
* Code coverage with JaCoCo.
* See: https://www.jacoco.org/; https://docs.gradle.org/current/userguide/jacoco_plugin.html
*/
// Code coverage report is always generated after tests run
test { finalizedBy jacocoTestReport }
jacocoTestReport {
// Tests are required to run before generating the code coverage report
dependsOn test
// Remove closure classes from the report, as they are already covered by the enclosing class coverage stats adding only noise.
// See: https://stackoverflow.com/questions/39453696
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect { dir ->
fileTree(dir: dir, excludes: ['**/*$*_closure*'])
}))
}
}