@@ -120,3 +120,48 @@ jobs:
120120 for test in sorted(skipped_tests):
121121 f.write(f"{test}\n")
122122 '
123+
124+ - name : 📈 Coverage Report
125+ if : always() && matrix.os == 'ubuntu-latest' && matrix.java-version == '21'
126+ run : |
127+ python3 -c '
128+ import csv, os
129+
130+ # Hardcoded path to the aggregated CSV
131+ csv_file = "tests/target/site/jacoco-aggregate/jacoco.csv"
132+ summary_file = os.environ.get("GITHUB_STEP_SUMMARY")
133+
134+ if not os.path.exists(csv_file):
135+ with open(summary_file, "a", encoding="utf-8") as f:
136+ f.write(f"\n⚠️ **Coverage report not found at {csv_file}.**\n")
137+ else:
138+ instr_missed, instr_covered = 0, 0
139+ branch_missed, branch_covered = 0, 0
140+ line_missed, line_covered = 0, 0
141+
142+ with open(csv_file, mode="r", encoding="utf-8") as file:
143+ reader = csv.DictReader(file)
144+ for row in reader:
145+ instr_missed += int(row["INSTRUCTION_MISSED"])
146+ instr_covered += int(row["INSTRUCTION_COVERED"])
147+ branch_missed += int(row["BRANCH_MISSED"])
148+ branch_covered += int(row["BRANCH_COVERED"])
149+ line_missed += int(row["LINE_MISSED"])
150+ line_covered += int(row["LINE_COVERED"])
151+
152+ def calc(covered, missed):
153+ total = covered + missed
154+ return (covered / total * 100) if total > 0 else 0
155+
156+ instr_pct = calc(instr_covered, instr_missed)
157+ line_pct = calc(line_covered, line_missed)
158+ branch_pct = calc(branch_covered, branch_missed)
159+
160+ with open(summary_file, "a", encoding="utf-8") as f:
161+ f.write("## 📈 Code Coverage\n")
162+ f.write("| Metric | Coverage |\n")
163+ f.write("|--------|----------|\n")
164+ f.write(f"| **Instruction (Overall)** | **{instr_pct:.2f}%** |\n")
165+ f.write(f"| **Line** | **{line_pct:.2f}%** |\n")
166+ f.write(f"| **Branch** | **{branch_pct:.2f}%** |\n\n")
167+ '
0 commit comments