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 #2610, Enforce keeping coverage minimums up-to-date in Code Coverage CI workflow #2611

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
61 changes: 55 additions & 6 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ env:
ENABLE_UNIT_TESTS: true
OMIT_DEPRECATED: true
BUILDTYPE: debug

ALLOWED_MISSED_BRANCHES: 39
ALLOWED_MISSED_LINES: 17
ALLOWED_MISSED_FUNCTIONS: 0
jobs:

#Check for duplicate actions. Skips push actions if there is a matching or duplicate pull-request action.
Expand Down Expand Up @@ -105,17 +107,64 @@ jobs:

- name: Confirm Minimum Coverage
run: |
missed_branches=39
missed_lines=19
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]*")
function_nums=$(grep -A 3 "Overall coverage rate" lcov_out.txt | grep functions | grep -oP "[0-9]+[0-9]*")

branch_diff=$(echo $branch_nums | awk '{ print $4 - $3 }')
echo "branch_diff=$branch_diff" >> $GITHUB_ENV
line_diff=$(echo $line_nums | awk '{ print $4 - $3 }')
if [ $branch_diff -gt $missed_branches ] || [ $line_diff -gt $missed_lines ]
echo "line_diff=$line_diff" >> $GITHUB_ENV
function_diff=$(echo $function_nums | awk '{ print $4 - $3 }')
echo "function_diff=$function_diff" >> $GITHUB_ENV

if [ $branch_diff -gt ${{ env.ALLOWED_MISSED_BRANCHES }} ]
then
grep -A 3 "Overall coverage rate" lcov_out.txt
echo "::error::$branch_diff uncovered branch$([ $branch_diff -ne 1 ] && echo 'es') reported, but only ${{ env.ALLOWED_MISSED_BRANCHES }} ${{ env.ALLOWED_MISSED_BRANCHES == 1 && 'is' || 'are' }} allowed."
exit -1
fi

if [ $line_diff -gt ${{ env.ALLOWED_MISSED_LINES }} ]
then
grep -A 3 "Overall coverage rate" lcov_out.txt
echo "::error::$line_diff uncovered line$([ $line_diff -ne 1 ] && echo 's') reported, but only ${{ env.ALLOWED_MISSED_LINES }} ${{ env.ALLOWED_MISSED_LINES == 1 && 'is' || 'are' }} allowed."
exit -1
fi

if [ $function_diff -gt ${{ env.ALLOWED_MISSED_FUNCTIONS }} ]
then
grep -A 3 "Overall coverage rate" lcov_out.txt
echo "::error::$function_diff uncovered function$([ $function_diff -ne 1 ] && echo 's') reported, but only ${{ env.ALLOWED_MISSED_FUNCTIONS }} ${{ env.ALLOWED_MISSED_FUNCTIONS == 1 && 'is' || 'are' }} allowed."
exit -1
fi

- name: Enforce Keeping Branch Coverage Minimum Up-To-Date
run: |
if [ $branch_diff -lt ${{ env.ALLOWED_MISSED_BRANCHES }} ]
then
grep -A 3 "Overall coverage rate" lcov_out.txt
echo "::error::$branch_diff uncovered branch$([ $branch_diff -ne 1 ] && echo 'es') reported, but ${{ env.ALLOWED_MISSED_BRANCHES }} ${{ env.ALLOWED_MISSED_BRANCHES == 1 && 'is' || 'are' }} allowed."
echo "::error::Please update (lower) the 'ALLOWED_MISSED_BRANCHES' variable to $branch_diff in order to match the new coverage level."
exit -1
fi

- name: Enforce Keeping Line Coverage Minimum Up-To-Date
run: |
if [ $line_diff -lt ${{ env.ALLOWED_MISSED_LINES }} ]
then
grep -A 3 "Overall coverage rate" lcov_out.txt
echo "::error::$line_diff uncovered line$([ $line_diff -ne 1 ] && echo 's') reported, but ${{ env.ALLOWED_MISSED_LINES }} ${{ env.ALLOWED_MISSED_LINES == 1 && 'is' || 'are' }} allowed."
echo "::error::Please update (lower) the 'ALLOWED_MISSED_LINES' variable to $line_diff in order to match the new coverage level."
exit -1
fi

- name: Enforce Keeping Function Coverage Minimum Up-To-Date
run: |
if [ $function_diff -lt ${{ env.ALLOWED_MISSED_FUNCTIONS }} ]
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 "::error::$function_diff uncovered function$([ $function_diff -ne 1 ] && echo 's') reported, but ${{ env.ALLOWED_MISSED_FUNCTIONS }} ${{ env.ALLOWED_MISSED_FUNCTIONS == 1 && 'is' || 'are' }} allowed."
echo "::error::Please update (lower) the 'ALLOWED_MISSED_FUNCTIONS' variable to $function_diff in order to match the new coverage level."
exit -1
fi
Loading