Skip to content

Commit

Permalink
#217: JaCoCo Report workflow is not checking server module coverage
Browse files Browse the repository at this point in the history
* added check on server coverage
* added optional check on overall coverage of modules
* rename of some variables
  • Loading branch information
benedeki committed Jun 27, 2024
1 parent f5ac426 commit ca0ef8a
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions .github/workflows/jacoco_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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'
Expand Down

0 comments on commit ca0ef8a

Please sign in to comment.