Skip to content

Commit 9c368a8

Browse files
authored
Update GA to check branch instead of line coverage (#50)
* Update GA to check branch instead of line coverage * Add missing source to exclude as we are using sed to preprocess to source file
1 parent 9aa1539 commit 9c368a8

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,28 @@ jobs:
2828
- name: Run Coverage
2929
run: |
3030
make -C build/ coverage
31-
lcov --rc lcov_branch_coverage=1 --remove build/coverage.info '*test*' --output-file build/coverage.info
32-
lcov --rc lcov_branch_coverage=1 --remove build/coverage.info '*CMakeCCompilerId*' --output-file build/coverage.info
33-
lcov --rc lcov_branch_coverage=1 --remove build/coverage.info '*mocks*' --output-file build/coverage.info
34-
lcov --rc lcov_branch_coverage=1 --remove build/coverage.info '*source*' --output-file build/coverage.info
35-
lcov --list build/coverage.info
31+
declare -a EXCLUDE=("\*test\*" "\*CMakeCCompilerId\*" "\*mocks\*" "\*source\*")
32+
echo ${EXCLUDE[@]} | xargs lcov --rc lcov_branch_coverage=1 -r build/coverage.info -o build/coverage.info
33+
lcov --rc lcov_branch_coverage=1 --list build/coverage.info
3634
- name: Check Coverage
37-
uses: ChicagoFlutter/[email protected]
38-
with:
39-
path: "build/coverage.info"
40-
min_coverage: 100
41-
exclude: "**/*test*"
35+
env:
36+
MIN_COVERAGE: 100
37+
run: |
38+
LINE_COVERAGE=$(lcov --list build/coverage.info | tail -n 1 | cut -d '|' -f 2 | sed -n "s/\([^%]*\)%.*/\1/p")
39+
BRANCH_COVERAGE=$(lcov --rc lcov_branch_coverage=1 --list build/coverage.info | tail -n 1 | cut -d '|' -f 4 | sed -n "s/\([^%]*\)%.*/\1/p")
40+
RESULT=0
41+
echo "Required line and branch coverages: $MIN_COVERAGE"
42+
echo "Line coverage: $LINE_COVERAGE"
43+
if [[ $(echo "$LINE_COVERAGE < $MIN_COVERAGE" | bc) -ne 0 ]]; then
44+
echo "Line Coverage is too low."
45+
RESULT=1
46+
fi
47+
echo "Branch coverage: $BRANCH_COVERAGE"
48+
if [[ $(echo "$BRANCH_COVERAGE < $MIN_COVERAGE" | bc) -ne 0 ]]; then
49+
echo "Branch Coverage is too low."
50+
RESULT=1
51+
fi
52+
exit $RESULT
4253
complexity:
4354
runs-on: ubuntu-latest
4455
steps:

0 commit comments

Comments
 (0)