From 14694d1e38d322e843a0bbf2c893a15f80358025 Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Thu, 1 Feb 2024 12:30:10 +0100 Subject: [PATCH] #317 Add JaCoCo reporting --- .github/workflows/gradle-build.yml | 10 +++++++++- build.gradle | 11 ++++++++++- htmlSanityCheck-gradle-plugin/build.gradle | 5 +++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gradle-build.yml b/.github/workflows/gradle-build.yml index 8757e60d..e0cb3c2e 100644 --- a/.github/workflows/gradle-build.yml +++ b/.github/workflows/gradle-build.yml @@ -26,4 +26,12 @@ jobs: if: always() with: files: | - **/build/test-results/**/*.xml \ No newline at end of file + **/build/test-results/**/*.xml + + - name: JaCoCo Test Coverage Report + uses: PavanMudigonda/jacoco-reporter@v4.9 + with: + coverage_results_path: "htmlSanityCheck-gradle-plugin/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml" + coverage_report_name: Coverage + coverage_report_title: JaCoCo + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/build.gradle b/build.gradle index dad5682f..d70651ac 100644 --- a/build.gradle +++ b/build.gradle @@ -42,6 +42,8 @@ configure(subprojects) { apply plugin: 'groovy' apply plugin: 'maven-publish' + apply plugin: 'jacoco' + description "${rootProject.description} - Module ${project.name}" dependencies { @@ -66,7 +68,7 @@ configure(subprojects) { maven { name = 'myLocalRepositoryForFullIntegrationTests' //noinspection GrDeprecatedAPIUsage - url = new File (project.parent.buildDir, "maven-repo") + url = new File(project.parent.buildDir, "maven-repo") } mavenLocal() } @@ -76,6 +78,13 @@ configure(subprojects) { useJUnitPlatform() } + check { + finalizedBy jacocoTestReport // report is always generated after tests run + } + jacocoTestReport { + dependsOn check // tests are required to run before generating the report + } + // The CodeNarc plugin performs quality checks on your project’s // Groovy source files using CodeNarc and generates reports from these checks. // apply plugin: 'codenarc' diff --git a/htmlSanityCheck-gradle-plugin/build.gradle b/htmlSanityCheck-gradle-plugin/build.gradle index cf0323b9..77f63390 100755 --- a/htmlSanityCheck-gradle-plugin/build.gradle +++ b/htmlSanityCheck-gradle-plugin/build.gradle @@ -1,5 +1,10 @@ plugins { id 'java-gradle-plugin' + id 'jacoco-report-aggregation' +} + +tasks.named('check') { + dependsOn tasks.named('testCodeCoverageReport', JacocoReport) } gradlePlugin {