Skip to content

Commit

Permalink
Fix #1906, Enforce minimum code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
skliper committed Sep 7, 2021
1 parent e5d4ed9 commit a4a5bdc
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 a4a5bdc

Please sign in to comment.