diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e9df103..0fb3375 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -115,6 +115,7 @@ jobs: path: | **/build/test-results/**/*.xml test-report-aggregation/build/reports/tests/test/aggregated-results/** + test-report-aggregation/build/reports/jacoco/testCodeCoverageReport/** retention-days: 7 docs: diff --git a/.github/workflows/test-reporting.yml b/.github/workflows/test-reporting.yml index 5325379..85ab1ec 100644 --- a/.github/workflows/test-reporting.yml +++ b/.github/workflows/test-reporting.yml @@ -49,6 +49,21 @@ jobs: run-id: ${{ github.event.workflow_run.id }} github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Publish JaCoCo report as PR comment + id: jacoco + uses: madrapps/jacoco-report@50d3aff4548aa991e6753342d9ba291084e63848 # 1.7.2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + paths: build-reports-artifacts/**/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml + update-comment: true + title: "# :java_duke: JaCoCo coverage report" + min-coverage-overall: 50 + min-coverage-changed-files: 60 + comment-type: both + pr-number: ${{ needs.get-pr-info.outputs.pr_number}} + pass-emoji: ':green_circle:' + fail-emoji: ':red_circle:' + - name: Publish JUnit test report (PR comment with collapsed failures) uses: mikepenz/action-junit-report@e08919a3b1fb83a78393dfb775a9c37f17d8eea6 # v6.0.1 env: diff --git a/buildSrc/src/main/kotlin/docling-java-shared.gradle.kts b/buildSrc/src/main/kotlin/docling-java-shared.gradle.kts index 74d1049..1ec6d95 100644 --- a/buildSrc/src/main/kotlin/docling-java-shared.gradle.kts +++ b/buildSrc/src/main/kotlin/docling-java-shared.gradle.kts @@ -1,6 +1,7 @@ plugins { id("docling-shared") `java-library` + `jacoco` } repositories { @@ -36,10 +37,16 @@ testing { } } +jacoco { + toolVersion = libs.findVersion("jacoco").get().toString() +} + tasks.withType { // Use JUnit Platform for unit tests. useJUnitPlatform() + finalizedBy(tasks.named("jacocoTestReport")) + testLogging { events("PASSED", "FAILED", "SKIPPED", "STANDARD_OUT", "STANDARD_ERROR") showStandardStreams = true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 55ba0c0..368b23d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,6 +2,7 @@ assertj = "3.27.6" jackson2 = "2.20.1" jackson3 = "3.0.3" +jacoco = "0.8.14" jreleaser = "1.20.0" jspecify = "1.0.0" junit = "6.0.1" diff --git a/test-report-aggregation/build.gradle.kts b/test-report-aggregation/build.gradle.kts index 1287686..52a2b47 100644 --- a/test-report-aggregation/build.gradle.kts +++ b/test-report-aggregation/build.gradle.kts @@ -2,6 +2,7 @@ plugins { id("docling-shared") `java-library` `test-report-aggregation` + `jacoco-report-aggregation` } repositories { @@ -9,11 +10,18 @@ repositories { } dependencies { + testReportAggregation(project(":docling-core")) testReportAggregation(project(":docling-serve-api")) testReportAggregation(project(":docling-serve-client")) testReportAggregation(project(":docling-testcontainers")) testReportAggregation(project(":docling-version-tests")) + jacocoAggregation(project(":docling-core")) + jacocoAggregation(project(":docling-serve-api")) + jacocoAggregation(project(":docling-serve-client")) + jacocoAggregation(project(":docling-testcontainers")) + jacocoAggregation(project(":docling-version-tests")) + api(platform(libs.testcontainers.bom)) api(platform(libs.jackson.bom)) @@ -24,5 +32,8 @@ dependencies { } tasks.named("check") { - dependsOn(tasks.named("testAggregateTestReport")) + dependsOn( + tasks.named("testAggregateTestReport"), + tasks.named("testCodeCoverageReport") + ) }