Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

steps:
- uses: actions/checkout@v3
Expand All @@ -20,3 +23,42 @@ jobs:
cache: maven
- name: Build & test
run: mvn --batch-mode verify --file pom.xml

- name: Generate JaCoCo coverage summary
if: github.event_name == 'pull_request'
run: |
python3 - <<'PYEOF' > coverage-summary.md
import glob, xml.etree.ElementTree as ET

def pct(covered, missed):
total = covered + missed
return f"{100 * covered / total:.1f}%" if total else "—"

rows = []
tot_c = tot_m = 0
for path in sorted(glob.glob("**/target/site/jacoco/jacoco.xml", recursive=True)):
root = ET.parse(path).getroot()
name = root.get("name")
counters = {c.get("type"): (int(c.get("covered")), int(c.get("missed")))
for c in root.findall("counter")}
c, m = counters.get("INSTRUCTION", (0, 0))
rows.append((name, c, m))
tot_c += c
tot_m += m

print("## Coverage JaCoCo par module")
print()
print("| Module | Coverage |")
print("|---|---:|")
for name, c, m in rows:
print(f"| `{name}` | {pct(c, m)} |")
print(f"| **Total** | **{pct(tot_c, tot_m)}** |")
PYEOF
cat coverage-summary.md

- name: Post coverage comment
if: github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: jacoco-coverage
path: coverage-summary.md
3 changes: 3 additions & 0 deletions lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Make Lombok-generated code visible to tools (JaCoCo will auto-exclude
# methods annotated with @lombok.Generated from coverage reports).
lombok.addLombokGeneratedAnnotation = true
39 changes: 39 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,43 @@
</dependency>
</dependencies>
</dependencyManagement>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.13</version>
<configuration>
<excludes>
<!-- MapStruct-generated implementations -->
<exclude>**/*MapperImpl.class</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Loading