Skip to content

Commit 4a57bdc

Browse files
authored
Merge pull request #21 from Monnify/dev
ci: add Codecov coverage reporting with an enforced minimum threshold
2 parents 7eb1007 + b7f95ed commit 4a57bdc

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,35 @@ jobs:
4343
- name: Test
4444
run: dotnet test --configuration Release --no-build
4545

46+
# Coverage is collected from Monnify.Tests only (run separately from the line above) -
47+
# IntegrationTests' skipped tests never execute SUT code, so including that project's
48+
# report would just dilute the denominator with the same assembly's line count again.
49+
- name: Test with coverage
50+
run: dotnet test tests/Monnify.Tests/Monnify.Tests.csproj --configuration Release --no-build --collect:"XPlat Code Coverage" --results-directory ./coverage
51+
52+
# No external service required - just parses the cobertura report coverlet already
53+
# produces and fails the build below a fixed line-coverage floor. Current baseline is
54+
# ~95%; 85% leaves headroom for routine work while still catching a real regression.
55+
- name: Check coverage threshold
56+
run: |
57+
python3 - <<'PY'
58+
import glob, sys, xml.etree.ElementTree as ET
59+
60+
THRESHOLD = 85.0
61+
files = glob.glob("./coverage/**/coverage.cobertura.xml", recursive=True)
62+
if not files:
63+
sys.exit("No coverage report found")
64+
65+
root = ET.parse(files[0]).getroot()
66+
covered = int(root.get("lines-covered"))
67+
valid = int(root.get("lines-valid"))
68+
pct = 100 * covered / valid if valid else 0
69+
70+
print(f"Line coverage: {pct:.2f}% ({covered}/{valid})")
71+
if pct < THRESHOLD:
72+
sys.exit(f"Coverage {pct:.2f}% is below the {THRESHOLD}% threshold")
73+
PY
74+
4675
# Validates the package actually builds correctly across both target frameworks - this is
4776
# NOT a publish step, nothing here touches NuGet.org. No artifact is uploaded either, since
4877
# this is only a packaging sanity check, not a release.

0 commit comments

Comments
 (0)