Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1906, Enforce minimum code coverage #1938

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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