diff --git a/.github/workflows/local_unit_test.yml b/.github/workflows/local_unit_test.yml index 17da300b9..06f45f4c0 100644 --- a/.github/workflows/local_unit_test.yml +++ b/.github/workflows/local_unit_test.yml @@ -32,10 +32,15 @@ jobs: - name: Calculate coverage run: make lcov | tee lcov_out.txt - - name: Confirm 100% line coverage + - name: Confirm absolute line coverage run: | - if [[ `grep -A 3 "Overall coverage rate" lcov_out.txt | grep lines` != *"100.0%"* ]]; then + missed_branches=4 + coverage_nums=$(grep -A 3 "Overall coverage rate" lcov_out.txt | grep branches | grep -oP "[1-9]+[0-9]*") + + diff=$(echo $coverage_nums | awk '{ print $4 - $3 }') + if [ $(($diff > $missed_branches)) == 1 ] + then grep -A 3 "Overall coverage rate" lcov_out.txt - echo "Lacks 100.0% line unit test coverage" + echo "More than $missed_branches branches missed" exit -1 fi