From dcefb8c874dcdaa1b7047d8b4c9b3bc099cbd933 Mon Sep 17 00:00:00 2001 From: David Benedeki <14905969+benedeki@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:12:19 +0200 Subject: [PATCH] #217: JaCoCo Report workflow is not checking server module coverage (#218) * added check on server coverage * added optional check on overall coverage of modules * rename of some variables --- .github/workflows/jacoco_report.yml | 38 ++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/.github/workflows/jacoco_report.yml b/.github/workflows/jacoco_report.yml index 003ec5506..59caf09e2 100644 --- a/.github/workflows/jacoco_report.yml +++ b/.github/workflows/jacoco_report.yml @@ -24,8 +24,9 @@ on: env: scalaLong: 2.13.11 scalaShort: "2.13" - overall: 60.0 - changed: 80.0 + coverage-overall: 60.0 + coverage-changed-files: 80.0 + check-overall-coverages: true jobs: build-test-and-measure: @@ -66,8 +67,8 @@ jobs: with: paths: ${{ github.workspace }}/model/target/jvm-${{ env.scalaShort }}/jacoco/report/jacoco.xml token: ${{ secrets.GITHUB_TOKEN }} - min-coverage-overall: ${{ env.overall }} - min-coverage-changed-files: ${{ env.changed }} + min-coverage-overall: ${{ env.coverage-overall }} + min-coverage-changed-files: ${{ env.coverage-changed-files }} title: JaCoCo model module code coverage report - scala ${{ env.scalaLong }} update-comment: true - name: Add coverage to PR (agent) @@ -77,8 +78,8 @@ jobs: with: paths: ${{ github.workspace }}/agent/target/spark3-jvm-${{ env.scalaShort }}/jacoco/report/jacoco.xml token: ${{ secrets.GITHUB_TOKEN }} - min-coverage-overall: ${{ env.overall }} - min-coverage-changed-files: ${{ env.changed }} + min-coverage-overall: ${{ env.coverage-overall }} + min-coverage-changed-files: ${{ env.coverage-changed-files }} title: JaCoCo agent module code coverage report - scala ${{ env.scalaLong }} update-comment: true - name: Add coverage to PR (server) @@ -88,8 +89,8 @@ jobs: with: paths: ${{ github.workspace }}/server/target/jvm-${{ env.scalaShort }}/jacoco/report/jacoco.xml token: ${{ secrets.GITHUB_TOKEN }} - min-coverage-overall: ${{env.overall }} - min-coverage-changed-files: ${{ env.changed }} + min-coverage-overall: ${{env.coverage-overall }} + min-coverage-changed-files: ${{ env.coverage-changed-files }} title: JaCoCo server module code coverage report - scala ${{ env.scalaLong }} update-comment: true - name: Get the Coverage info @@ -101,16 +102,29 @@ jobs: echo "Changed Files coverage ${{ steps.jacoco-model.outputs.coverage-changed-files }}" echo "Total server module coverage ${{ steps.jacoco-server.outputs.coverage-overall }}" echo "Changed Files coverage ${{ steps.jacoco-server.outputs.coverage-changed-files }}" - - name: Fail PR if changed files coverage is less than ${{ env.changed }}% + - name: Fail PR if changed files coverage is less than ${{ env.coverage-changed-files }}% if: steps.jacocorun.outcome == 'success' uses: actions/github-script@v6 with: script: | const coverageCheckFailed = - Number('${{ steps.jacoco-agent.outputs.coverage-changed-files }}') < Number('${{ env.changed }}') || - Number('${{ steps.jacoco-model.outputs.coverage-changed-files }}') < Number('${{ env.changed }}'); + Number('${{ steps.jacoco-agent.outputs.coverage-changed-files }}') < Number('${{ env.coverage-changed-files }}') || + Number('${{ steps.jacoco-server.outputs.coverage-changed-files }}') < Number('${{ env.coverage-changed-files }}') || + Number('${{ steps.jacoco-model.outputs.coverage-changed-files }}') < Number('${{ env.coverage-changed-files }}'); if (coverageCheckFailed) { - core.setFailed('Changed files coverage is less than ${{ env.changed }}%!'); + core.setFailed('Changed files coverage is less than ${{ env.coverage-changed-files }}%!'); + } + - name: Fail PR if overall files coverage is less than ${{ env.coverage-overall }}% + if: ${{ (steps.jacocorun.outcome == 'success') && (env.check-overall-coverages == 'true') }} + uses: actions/github-script@v6 + with: + script: | + const coverageCheckFailed = + Number('${{ steps.jacoco-agent.outputs.coverage-overall }}') < Number('${{ env.coverage-overall }}') || + Number('${{ steps.jacoco-server.outputs.coverage-overall }}') < Number('${{ env.coverage-overall }}') || + Number('${{ steps.jacoco-model.outputs.coverage-overall }}') < Number('${{ env.coverage-overall }}'); + if (coverageCheckFailed) { + core.setFailed('Overall coverage is less than ${{ env.coverage-overall }}%!'); } - name: Edit JaCoCo comments on build failure if: steps.jacocorun.outcome != 'success'