-
Notifications
You must be signed in to change notification settings - Fork 217
55 lines (43 loc) · 1.51 KB
/
local_unit_test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: "Local Unit Test"
on:
push:
pull_request:
jobs:
Local-Unit-Test:
runs-on: ubuntu-18.04
timeout-minutes: 15
steps:
- name: Install coverage tools
run: sudo apt-get install lcov -y
- name: Checkout submodule
uses: actions/checkout@v2
- name: Set up for build
run: |
cp Makefile.sample Makefile
make ENABLE_UNIT_TESTS=true PERMISSIVE_MODE=true prep
- name: Build the code
run: make -j
# Baseline lcov and run all tests
- name: Test
run: make test
- 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
grep -A 3 "Overall coverage rate" lcov_out.txt
echo "Lacks 100.0% line unit test coverage"
exit -1
fi
- name: Confirm absolute line coverage
run: |
# Current best possible branch coverage is all but 4, with associated issues for each missing case
missed_branches=4
coverage_nums=$(grep -A 3 "Overall coverage rate" lcov_out.txt | grep branches | grep -oP "[0-9]+[0-9]*")
diff=$(echo $coverage_nums | awk '{ print $4 - $3 }')
if [ $diff -gt $missed_branches ]
then
grep -A 3 "Overall coverage rate" lcov_out.txt
echo "More than $missed_branches branches missed"
exit -1
fi