Skip to content

Commit b7f95ed

Browse files
committed
ci: drop Codecov upload, enforce coverage threshold locally instead
The tokenless OIDC upload failed with "Repository not found" - Codecov has never synced this repo, so upload requires activating it on codecov.io first. Rather than depend on that, run Monnify.Tests with coverage collection separately from the full test pass and fail the build below an 85% line floor by parsing the cobertura report coverlet already produces - no external account or token needed. Current baseline is ~95%.
1 parent 02ab11a commit b7f95ed

2 files changed

Lines changed: 29 additions & 33 deletions

File tree

.github/workflows/ci.yml

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77

88
permissions:
99
contents: read
10-
id-token: write # required for Codecov's tokenless upload via GitHub OIDC (public repo)
1110

1211
jobs:
1312
build-and-test:
@@ -41,17 +40,37 @@ jobs:
4140
# [SkippableFact] + Skip.IfNot(SandboxCredentials.IsAvailable, ...) (see
4241
# tests/Monnify.IntegrationTests/SandboxCredentials.cs) so they report as skipped here,
4342
# not failed - this runner has no MONNIFY_SANDBOX_API_KEY/SECRET_KEY configured on purpose.
44-
# Skipped tests contribute no coverage, so the uploaded report below reflects
45-
# Monnify.Tests (unit tests) only - that's the intended, reproducible signal.
4643
- name: Test
47-
run: dotnet test --configuration Release --no-build --collect:"XPlat Code Coverage" --results-directory ./coverage
44+
run: dotnet test --configuration Release --no-build
4845

49-
- name: Upload coverage to Codecov
50-
uses: codecov/codecov-action@v5
51-
with:
52-
directory: ./coverage
53-
use_oidc: true
54-
fail_ci_if_error: true
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
5574
5675
# Validates the package actually builds correctly across both target frameworks - this is
5776
# NOT a publish step, nothing here touches NuGet.org. No artifact is uploaded either, since

codecov.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)