Skip to content

Commit

Permalink
Merge pull request #1938 from skliper/fix1906-enforce_coverage
Browse files Browse the repository at this point in the history
Fix #1906, Enforce minimum code coverage
  • Loading branch information
astrogeco authored Sep 7, 2021
2 parents ebfb30c + a4a5bdc commit 3300b43
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,21 @@ jobs:
run: |
lcov --capture --rc lcov_branch_coverage=1 --directory build --output-file coverage_test.info
lcov --rc lcov_branch_coverage=1 --add-tracefile coverage_base.info --add-tracefile coverage_test.info --output-file coverage_total.info
genhtml coverage_total.info --branch-coverage --output-directory lcov
genhtml coverage_total.info --branch-coverage --output-directory lcov | tee lcov_out.txt
- name: Confirm Minimum Coverage
run: |
missed_branches=76
missed_lines=33
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 ]
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"
exit -1
fi

0 comments on commit 3300b43

Please sign in to comment.