diff --git a/.github/workflows/test-coverage.yml b/.github/workflows/test-coverage.yml index a39cbb0..fbffac3 100644 --- a/.github/workflows/test-coverage.yml +++ b/.github/workflows/test-coverage.yml @@ -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