diff --git a/.github/workflows/local_unit_test.yml b/.github/workflows/local_unit_test.yml index 17da300b9..fe1bb4a81 100644 --- a/.github/workflows/local_unit_test.yml +++ b/.github/workflows/local_unit_test.yml @@ -31,7 +31,7 @@ jobs: - name: Calculate coverage run: make lcov | tee lcov_out.txt - + - name: Confirm 100% line coverage run: | if [[ `grep -A 3 "Overall coverage rate" lcov_out.txt | grep lines` != *"100.0%"* ]]; then @@ -39,3 +39,16 @@ jobs: echo "Lacks 100.0% line unit test coverage" exit -1 fi + + - name: Confirm absolute line coverage + run: | + 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 "More than $missed_branches branches missed" + exit -1 + fi