Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
cmleite committed Feb 28, 2025
1 parent a0fbdd6 commit ff04630
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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'
Expand Down

0 comments on commit ff04630

Please sign in to comment.