Skip to content

Commit 866c125

Browse files
authored
Enable code coverage measurements (#2388)
Signed-off-by: Lars Geyer-Blaumeiser <lars.blaumeiser@cofinity-x.com>
1 parent 8b36f72 commit 866c125

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

.github/workflows/verify.yaml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,45 @@ jobs:
7575
- uses: ./.github/actions/setup-java
7676

7777
- name: Run Unit tests
78-
run: ./gradlew test
78+
run: ./gradlew test testCodeCoverage
7979
env:
8080
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_API_TOKEN }}
8181

82+
# uploads the jacoco report as artifact
83+
- name: Upload JaCoCo Coverage Report
84+
uses: actions/upload-artifact@v4
85+
with:
86+
name: JaCoCo coverage-report
87+
path: build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml
88+
retention-days: 1
89+
90+
# generates coverage-report.md
91+
- name: JaCoCo Code Coverage Report
92+
id: jacoco_reporter
93+
uses: PavanMudigonda/jacoco-reporter@v5.0
94+
with:
95+
coverage_results_path: build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml
96+
skip_check_run: true
97+
github_token: ${{ secrets.GITHUB_TOKEN }}
98+
99+
# Publish Coverage Job Summary
100+
- name: Output KPIs from JaCoCo report
101+
run: |
102+
echo "| Outcome | Value |" >> $GITHUB_STEP_SUMMARY
103+
echo "| --- | --- |" >> $GITHUB_STEP_SUMMARY
104+
echo "| Code Coverage % | ${{ steps.jacoco_reporter.outputs.coverage_percentage }} |" >> $GITHUB_STEP_SUMMARY
105+
echo "| :heavy_check_mark: Number of Lines Covered | ${{ steps.jacoco_reporter.outputs.covered_lines }} |" >> $GITHUB_STEP_SUMMARY
106+
echo "| :x: Number of Lines Missed | ${{ steps.jacoco_reporter.outputs.missed_lines }} |" >> $GITHUB_STEP_SUMMARY
107+
echo "| Total Number of Lines | ${{ steps.jacoco_reporter.outputs.total_lines }} |" >> $GITHUB_STEP_SUMMARY
108+
109+
# uploads the coverage-report.md artifact
110+
- name: Upload Code Coverage Markdown Report
111+
uses: actions/upload-artifact@v4
112+
with:
113+
name: code-coverage-report-markdown
114+
path: "*/coverage-results.md"
115+
retention-days: 1
116+
82117
integration-tests:
83118
runs-on: ubuntu-latest
84119
steps:

build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ plugins {
2525
checkstyle
2626
`java-library`
2727
`maven-publish`
28+
jacoco
2829
`jacoco-report-aggregation`
2930
`java-test-fixtures`
3031
alias(libs.plugins.shadow)
@@ -61,6 +62,7 @@ val edcBuildId = libs.plugins.edc.build.get().pluginId
6162
allprojects {
6263
apply(plugin = edcBuildId)
6364
apply(plugin = "org.eclipse.edc.autodoc")
65+
apply(plugin = "jacoco")
6466

6567
dependencies {
6668

0 commit comments

Comments
 (0)