From 3ddaf5e6de840effcfa89c47dc69d29a94d0256c Mon Sep 17 00:00:00 2001 From: "Michael A. Neilson" Date: Tue, 28 Apr 2026 19:15:30 +0000 Subject: [PATCH 1/4] WIP coverage. --- .github/actions/badge/action.yml | 4 +-- .github/workflows/build.yml | 27 ++++++++++++++++--- build.gradle | 4 +++ .../main/groovy/cda.deps-conventions.gradle | 2 +- .../main/groovy/cda.java-conventions.gradle | 2 +- cwms-data-api/build.gradle | 26 ++++++++++++++++++ .../src/main/resources/psw4j.properties | 2 +- 7 files changed, 58 insertions(+), 9 deletions(-) diff --git a/.github/actions/badge/action.yml b/.github/actions/badge/action.yml index b1f0c30a78..1fb6a30ff1 100644 --- a/.github/actions/badge/action.yml +++ b/.github/actions/badge/action.yml @@ -54,5 +54,5 @@ runs: uses: actions/upload-artifact@v4 with: name: badges_${{ inputs.run_id }}_${{ steps.vars.outputs.safe_file }} - path: badges/**/*.svg - overwrite: true \ No newline at end of file + path: badges/**/${{inputs.file}} + overwrite: true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0321d83175..db8eeb73f5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,10 +20,10 @@ jobs: schema: - env: latest image: "ghcr.io/hydrologicengineeringcenter/cwms-database/cwms/database-ready-ora-23.5:latest-dev" - - env: release - image: "ghcr.io/hydrologicengineeringcenter/cwms-database/cwms/database-ready-ora-23.5:25.07.01" - - env: next-release - image: "ghcr.io/hydrologicengineeringcenter/cwms-database/cwms/database-ready-ora-23.5:26.02.17-RC01" + # - env: release + # image: "ghcr.io/hydrologicengineeringcenter/cwms-database/cwms/database-ready-ora-23.5:25.07.01" + # - env: next-release + # image: "ghcr.io/hydrologicengineeringcenter/cwms-database/cwms/database-ready-ora-23.5:26.02.17-RC01" # - env: previous # image: "ghcr.io/hydrologicengineeringcenter/cwms-database/cwms/database-ready-ora-23.5:25.07.01" name: build and test (jdk ${{matrix.jdk}}, schema ${{matrix.schema.env}}) @@ -57,6 +57,25 @@ jobs: status: ${{ job.status == 'success' && 'Pass' || 'Fail' }} file: ${{ matrix.jdk }}/${{ matrix.schema.env }}.svg run_id: ${{ github.run_id }} + - name: Install xmllint + run: sudo apt-get update && sudo apt-get install -y libxml2-utils + - name: coverage + id: coverage + run: | + ./gradlew codeCoverageReport --info --init-script init.gradle -PCDA.oracle.database.image=${{matrix.schema.image}} + MISSED_LINES=`xmllint --xpath "string(/report/counter[@type='COMPLEXITY']/@missed)" cwms-data-api/build/reports/jacoco-composite.xml` + COVERED_LIENS=`xmllint --xpath "string(/report/counter[@type='COMPLEXITY']/@covered)" cwms-data-api/build/reports/jacoco-composite.xml` + PERCENT=`printf "%.0f %%" $(( (COVERED_LINES /(COVERED_LIENS + MISSED_LINES)) * 100 ))` + echo "Coverage from missed $MISSED_LINES and covered $COVERED_LINES is $PRECENT" + echo "coverage=$PERCENT" >> $GITHUB_OUTPUT + - name: Create matrix coverage badge + if: success() || failure() # always run even if the previous step fails + uses: ./.github/actions/badge + with: + label: 'Coverage' + status: ${{ steps.coverage.outputs.coverage }} + file: ${{ matrix.jdk }}/${{ matrix.schema.env }}-coverage.svg + run_id: ${{ github.run_id }} # - name: Publish Test Report # uses: mikepenz/action-junit-report@v5 # if: success() || failure() # always run even if the previous step fails diff --git a/build.gradle b/build.gradle index 11ab2dac1e..1e0140dcfb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,7 @@ buildscript { repositories { gradlePluginPortal() + mavenCentral() } } @@ -9,6 +10,7 @@ plugins { id 'eclipse' id 'idea' id "com.palantir.git-version" version "3.1.0" + // id 'jacoco' } def static versionLabel(gitInfo) { @@ -24,3 +26,5 @@ allprojects { group = 'mil.army.usace.hec.cwms' version = project.findProperty("versionOverride") ?: versionLabel(versionDetails()) } + + diff --git a/buildSrc/src/main/groovy/cda.deps-conventions.gradle b/buildSrc/src/main/groovy/cda.deps-conventions.gradle index ed2729b3c9..5000be0534 100644 --- a/buildSrc/src/main/groovy/cda.deps-conventions.gradle +++ b/buildSrc/src/main/groovy/cda.deps-conventions.gradle @@ -13,7 +13,7 @@ repositories { maven { url = uri('https://repo.maven.apache.org/maven2') } - + gradlePluginPortal() } diff --git a/buildSrc/src/main/groovy/cda.java-conventions.gradle b/buildSrc/src/main/groovy/cda.java-conventions.gradle index c81cb116b4..7622261c3c 100644 --- a/buildSrc/src/main/groovy/cda.java-conventions.gradle +++ b/buildSrc/src/main/groovy/cda.java-conventions.gradle @@ -30,7 +30,7 @@ checkstyle { } jacoco { - toolVersion = "0.8.9" + toolVersion = "0.8.14" //"0.8.9" } jacocoTestReport { diff --git a/cwms-data-api/build.gradle b/cwms-data-api/build.gradle index 130f69ac8f..b1669b7024 100644 --- a/cwms-data-api/build.gradle +++ b/cwms-data-api/build.gradle @@ -464,3 +464,29 @@ tasks.register('shadeCodegenLatest', com.github.jengelman.gradle.plugins.shadow. } tasks.compileJava.dependsOn(tasks.shadeCodegenLegacy) tasks.compileJava.dependsOn(tasks.shadeCodegenLatest) + + + +tasks.register("codeCoverageReport", JacocoReport) { jr -> + tasks.matching({t -> t.extensions.findByType(JacocoTaskExtension)}).each { testTask -> + if(testTask.extensions.getByType(JacocoTaskExtension).isEnabled()) { + System.out.print(testTask.getName()) + //jr.sourceSets subproject.sourceSets.main + //jr.sourceDirectories.setFrom(subproject.sourceSets.main.allSource.srcDirs) + //jr.classDirectories.setFrom(subproject.sourceSets.main.output) + jr.executionData(testTask) + } + } + + + // enable the different report types (html, xml, csv) + reports { + xml.required = true + html.required = true + xml.outputLocation = layout.buildDirectory.file('reports/jacoco-composite.xml') + html.outputLocation = layout.buildDirectory.dir('jacocoHtmlComposite') + } + + jr.sourceDirectories.setFrom(fileTree(dir: "${rootDir}", include: "**/src/**/main/java/**", exclude: "build/**/codeCoverageReport.xml")) + jr.classDirectories.setFrom(fileTree(dir: "${rootDir}", include: "**/build/**/classes/**")) +} \ No newline at end of file diff --git a/cwms-data-api/src/main/resources/psw4j.properties b/cwms-data-api/src/main/resources/psw4j.properties index 47bfd16a6f..4b50179a7c 100644 --- a/cwms-data-api/src/main/resources/psw4j.properties +++ b/cwms-data-api/src/main/resources/psw4j.properties @@ -4,4 +4,4 @@ hash.argon2.memory=19456 hash.argon2.iterations=2 hash.argon2.parallelism=1 hash.argon2.length=32 -global.salt.length=16 \ No newline at end of file +global.salt.length=16 From 3c0d68d8454619932148179e46a879901f6e7232 Mon Sep 17 00:00:00 2001 From: "Michael A. Neilson" Date: Tue, 26 May 2026 15:50:35 +0000 Subject: [PATCH 2/4] Correct math setup. --- .github/workflows/build.yml | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index db8eeb73f5..a547d29844 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -62,12 +62,14 @@ jobs: - name: coverage id: coverage run: | + # combine the test and integration test reports. ./gradlew codeCoverageReport --info --init-script init.gradle -PCDA.oracle.database.image=${{matrix.schema.image}} - MISSED_LINES=`xmllint --xpath "string(/report/counter[@type='COMPLEXITY']/@missed)" cwms-data-api/build/reports/jacoco-composite.xml` - COVERED_LIENS=`xmllint --xpath "string(/report/counter[@type='COMPLEXITY']/@covered)" cwms-data-api/build/reports/jacoco-composite.xml` - PERCENT=`printf "%.0f %%" $(( (COVERED_LINES /(COVERED_LIENS + MISSED_LINES)) * 100 ))` + # calculate coverage percentage + MISSED_LINES=`xmllint --xpath "string(/report/counter[@type='COMPLEXITY']/@missed)" cwms-data-api/build/reports/jacoco-composite.xml` + COVERED_LINES=`xmllint --xpath "string(/report/counter[@type='COMPLEXITY']/@covered)" cwms-data-api/build/reports/jacoco-composite.xml` + PERCENT=`echo "scale=1; (${COVERED_LINES} / (${COVERED_LINES} + ${MISSED_LINES})) * 100" | bc` echo "Coverage from missed $MISSED_LINES and covered $COVERED_LINES is $PRECENT" - echo "coverage=$PERCENT" >> $GITHUB_OUTPUT + echo "coverage=$PERCENT %" >> $GITHUB_OUTPUT - name: Create matrix coverage badge if: success() || failure() # always run even if the previous step fails uses: ./.github/actions/badge @@ -76,13 +78,14 @@ jobs: status: ${{ steps.coverage.outputs.coverage }} file: ${{ matrix.jdk }}/${{ matrix.schema.env }}-coverage.svg run_id: ${{ github.run_id }} - # - name: Publish Test Report - # uses: mikepenz/action-junit-report@v5 - # if: success() || failure() # always run even if the previous step fails - # with: - # annotate_only: true - # include_passed: true - # report_paths: '**/TEST-*.xml' + - name: Publish Test Report + uses: mikepenz/action-junit-report@v6.4.1 + if: always() + with: + annotate_only: true + include_passed: true + report_paths: '**/TEST-*.xml' + detailed_summary: true open-api-static-analysis: name: OpenApi Static Analysis Tests runs-on: ubuntu-latest @@ -101,7 +104,7 @@ jobs: id: thebuild run: ./gradlew clean :cwms-data-api:test --tests "cwms.cda.api.OpenApiDocTest" --info --init-script init.gradle - name: Publish Test Report - uses: mikepenz/action-junit-report@v5 + uses: mikepenz/action-junit-report@v6.4.1 if: always() with: annotate_only: true From a9c9b4f1477f4bf28b8c2725bb16c4c7218e7650 Mon Sep 17 00:00:00 2001 From: "Michael A. Neilson" Date: Tue, 26 May 2026 15:54:03 +0000 Subject: [PATCH 3/4] Add coverage per build to README.md. --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 76776e6941..32833f9c9f 100644 --- a/README.md +++ b/README.md @@ -27,24 +27,29 @@ CWMS Database Schema target Status + Coverage Latest - Latest Status, Svg + Latest Status, Svg + Latest Coverage, Svg Current Release - Current Status, Svg + Current Status, Svg + Current Coverage, Svg Next Release - Next Status, Svg + Next Status, Svg + Next Coverage, Svg Previous Release - NOTE: Not applicable yet - Previous Status, Svg + Previous Status, Svg + Previous Status, Svg From f35aed932827c2339fb10ce78b94dd7d6aa0d878 Mon Sep 17 00:00:00 2001 From: Mike Neilson Date: Wed, 27 May 2026 14:17:13 -0700 Subject: [PATCH 4/4] remove comment about old version Co-authored-by: Karl Tarbet --- buildSrc/src/main/groovy/cda.java-conventions.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/groovy/cda.java-conventions.gradle b/buildSrc/src/main/groovy/cda.java-conventions.gradle index 7622261c3c..9214350e13 100644 --- a/buildSrc/src/main/groovy/cda.java-conventions.gradle +++ b/buildSrc/src/main/groovy/cda.java-conventions.gradle @@ -30,7 +30,7 @@ checkstyle { } jacoco { - toolVersion = "0.8.14" //"0.8.9" + toolVersion = "0.8.14" } jacocoTestReport {