Skip to content

Commit

Permalink
Update test-coverage.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
mrugama authored Feb 16, 2025
1 parent d557408 commit c4315da
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions .github/workflows/test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,32 @@ jobs:
TOTAL_COVERAGE=$(jq -r '.coveredLines / .executableLines * 100 | round / 1' coverage.json)
# Create badge for total coverage
COVERAGE_BADGE_URL="https://img.shields.io/badge/Test%20Coverage-${TOTAL_COVERAGE}%25-green?style=flat&logo=swift&logoColor=white"
COVERAGE_BADGE_URL="https://img.shields.io/badge/Total%20Test%20Coverage-${TOTAL_COVERAGE}%25-green?style=flat&logo=swift&logoColor=white"
# Generate coverage section content
echo "## Test Coverage" > coverage_section.md
echo "[![Test Coverage]($COVERAGE_BADGE_URL)](https://github.com/mrugama/Weather/actions)" >> coverage_section.md
echo "" >> coverage_section.md
echo "### 📊 General Coverage" >> coverage_section.md
echo "> **Total Test Coverage:** \`$TOTAL_COVERAGE%\`" >> coverage_section.md
echo "[![Test Coverage]($COVERAGE_BADGE_URL)](https://github.com/mrugama/Weather/actions)" >> coverage_section.md
echo "" >> coverage_section.md
echo "---" >> coverage_section.md
echo "### 📄 File-wise Coverage Breakdown" >> coverage_section.md
echo "| File | Covered Lines | Executable Lines | Coverage |" >> coverage_section.md
echo "|------|--------------|-----------------|----------|" >> coverage_section.md
echo "| File | Covered Lines | Executable Lines | Coverage | Badge |" >> coverage_section.md
echo "|------|--------------|-----------------|----------|-------|" >> coverage_section.md
# Loop through each file in coverage.json and add to table
jq -r '.targets[].files[] | "| \(.name) | \(.coveredLines) | \(.executableLines) | \((.lineCoverage * 100) | round)%"' coverage.json >> coverage_section.md
jq -r '.targets[].files[] |
[
.name,
.coveredLines,
.executableLines,
(.lineCoverage * 100 | round),
if (.lineCoverage * 100) < 25 then "![Need attention](https://img.shields.io/badge/Need%20attention-red)"
elif (.lineCoverage * 100) >= 25 and (.lineCoverage * 100) < 80 then "![Good job](https://img.shields.io/badge/Good%20job%21%2C%20keep%20working-yellow)"
else "![Excellent job](https://img.shields.io/badge/Excellent%20job%21%21%21-green)"
end
] |
"| \(.0) | \(.1) | \(.2) | \(.3)% | \(.4) |"' coverage.json >> coverage_section.md
echo "---" >> coverage_section.md
echo "" >> coverage_section.md
Expand Down

0 comments on commit c4315da

Please sign in to comment.