-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
cmleite
committed
Feb 28, 2025
1 parent
a0fbdd6
commit ff04630
Showing
1 changed file
with
11 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,16 +33,11 @@ jobs: | |
# Run tests with coverage | ||
- name: Run Unit Tests with Coverage | ||
run: | | ||
dotnet test Cmf.CustomerPortal.Sdk.sln --no-build --no-restore --configuration Release \ | ||
--collect:"XPlat Code Coverage" \ | ||
--logger trx \ | ||
--results-directory TestResults | ||
dotnet test Cmf.CustomerPortal.Sdk.sln --no-build --no-restore --configuration Release --collect:"XPlat Code Coverage" --logger trx --results-directory TestResults | ||
- name: Merge Coverage Reports | ||
run: | | ||
dotnet tool install --global dotnet-reportgenerator-globaltool | ||
reportgenerator -reports:TestResults/**/coverage.cobertura.xml \ | ||
-targetdir:TestResults/MergedCoverage \ | ||
-reporttypes:Cobertura | ||
reportgenerator -reports:TestResults/**/coverage.cobertura.xml -targetdir:TestResults/MergedCoverage -reporttypes:Cobertura | ||
- name: Code Coverage Report | ||
uses: irongut/[email protected] | ||
with: | ||
|
@@ -63,6 +58,15 @@ jobs: | |
path: code-coverage-results.md | ||
- name: Write to Job Summary | ||
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY | ||
- name: Fail Build if Coverage < 10% | ||
run: | | ||
COVERAGE=$(xmllint --xpath "string(//coverage/@line-rate)" TestResults/MergedCoverage/Cobertura.xml) | ||
COVERAGE_PERCENT=$(echo "$COVERAGE * 100" | bc) | ||
echo "Detected Coverage: $COVERAGE_PERCENT%" | ||
if (( $(echo "$COVERAGE_PERCENT < 10" | bc -l) )); then | ||
echo "❌ Code coverage is below 10%, failing the build." | ||
exit 1 | ||
fi | ||
# Run build | ||
- name: Build Windows | ||
if: github.ref_name == 'main' | ||
|