Skip to content

Commit

Permalink
Fix #2444, Enforce keeping code coverage minimums up-to-date
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Mar 23, 2024
1 parent ed1faf4 commit e614d1e
Showing 1 changed file with 34 additions and 5 deletions.
39 changes: 34 additions & 5 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:
if: ${{ needs.check-for-duplicates.outputs.should_skip != 'true' }}
runs-on: ubuntu-20.04
timeout-minutes: 15
env:
MISSED_BRANCHES_ALLOWED: 47
MISSED_LINES_ALLOWED: 12

steps:
- name: Install coverage tools
Expand Down Expand Up @@ -104,17 +107,43 @@ jobs:
- name: Confirm Minimum Coverage
run: |
missed_branches=50
missed_lines=17
branch_nums=$(grep -A 3 "Overall coverage rate" lcov_out.txt | grep branches | grep -oP "[0-9]+[0-9]*")
line_nums=$(grep -A 3 "Overall coverage rate" lcov_out.txt | grep lines | grep -oP "[0-9]+[0-9]*")
branch_diff=$(echo $branch_nums | awk '{ print $4 - $3 }')
line_diff=$(echo $line_nums | awk '{ print $4 - $3 }')
if [ $branch_diff -gt $missed_branches ] || [ $line_diff -gt $missed_lines ]
if [ $branch_diff -gt $MISSED_BRANCHES_ALLOWED ] || [ $line_diff -gt $MISSED_LINES_ALLOWED ]
then
grep -A 3 "Overall coverage rate" lcov_out.txt
echo "$branch_diff branches missed, $missed_branches allowed"
echo "$line_diff lines missed, $missed_lines allowed"
echo "$branch_diff branches missed, $MISSED_BRANCHES_ALLOWED allowed"
echo "$line_diff lines missed, $MISSED_LINES_ALLOWED allowed"
exit -1
fi
- name: Check that Minimum Coverage Limits are Correctly Calibrated
run: |
branch_nums=$(grep -A 3 "Overall coverage rate" lcov_out.txt | grep branches | grep -oP "[0-9]+[0-9]*")
line_nums=$(grep -A 3 "Overall coverage rate" lcov_out.txt | grep lines | grep -oP "[0-9]+[0-9]*")
branch_diff=$(echo $branch_nums | awk '{ print $4 - $3 }')
line_diff=$(echo $line_nums | awk '{ print $4 - $3 }')
if [ $branch_diff -lt $MISSED_BRANCHES_ALLOWED ] || [ $line_diff -lt $MISSED_LINES_ALLOWED ]
then
grep -A 3 "Overall coverage rate" lcov_out.txt
echo ""
if [ $branch_diff -lt $MISSED_BRANCHES_ALLOWED ]
then
echo "$branch_diff branches were missed, which is *less* than the expected/allowed amount: $MISSED_BRANCHES_ALLOWED"
echo "Please update (lower) the MISSED_BRANCHES_ALLOWED variable in this workflow file to match the new coverage level."
echo ""
fi
if [ $line_diff -lt $MISSED_LINES_ALLOWED ]
then
echo "$line_diff lines were missed, which is *less* than the expected/allowed amount: $MISSED_LINES_ALLOWED"
echo "Please update (lower) the MISSED_LINES_ALLOWED variable in this workflow file to match the new coverage level."
echo ""
fi
exit -1
fi

0 comments on commit e614d1e

Please sign in to comment.