Skip to content

Commit

Permalink
Update mc_dc_coverage.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbrown2 authored Dec 19, 2024
1 parent a84b2cb commit 507b692
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/mc_dc_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,19 @@ jobs:
gcovr --branches --xml-pretty --exclude-unreachable-branches -o coverage/coverage_report.xml
gcovr --branches --html --html-details -o coverage/coverage_report.html
LINE_COVERAGE=$(grep 'line-rate' coverage/coverage_report.xml | sed -n 's/.*line-rate="\(.*\)".*/\1/p')
BRANCH_COVERAGE=$(grep 'branch-rate' coverage/coverage_report.xml | sed -n 's/.*branch-rate="\(.*\)".*/\1/p')
# Extract overall coverage metrics from the root <coverage> tag
LINE_COVERAGE=$(grep -oP '(?<=<coverage line-rate=")[0-9.]+(?=")' coverage/coverage_report.xml | head -n 1)
BRANCH_COVERAGE=$(grep -oP '(?<=branch-rate=")[0-9.]+(?=")' coverage/coverage_report.xml | head -n 1)
# Convert to percentages
LINE_COVERAGE_PERCENT=$(printf "%.0f" $(echo "$LINE_COVERAGE * 100" | bc))
BRANCH_COVERAGE_PERCENT=$(printf "%.0f" $(echo "$BRANCH_COVERAGE * 100" | bc))
# Debug extracted values
echo "Line Coverage: $LINE_COVERAGE_PERCENT%"
echo "Branch Coverage: $BRANCH_COVERAGE_PERCENT%"
# Generate badges
curl -o coverage/line-coverage-badge.svg "https://img.shields.io/badge/line%20coverage-${LINE_COVERAGE_PERCENT}%25-brightgreen"
curl -o coverage/branch-coverage-badge.svg "https://img.shields.io/badge/branch%20coverage-${BRANCH_COVERAGE_PERCENT}%25-brightgreen"
Expand Down

0 comments on commit 507b692

Please sign in to comment.