17
17
steps :
18
18
- uses : actions/checkout@v4
19
19
20
+ # Install dependencies and setup environment
20
21
- name : Install Dependencies
21
22
env :
22
23
DEBIAN_FRONTEND : noninteractive
@@ -34,22 +35,27 @@ jobs:
34
35
cd /tmp/libgcrypt-1.11.0 && ./configure && make install
35
36
ldconfig
36
37
37
- # Build with coverage instrumentation
38
+ # Build the project with coverage flags
38
39
- name : Internal Build Script
39
- run : bash ${GITHUB_WORKSPACE}/support/scripts/build_internal.sh
40
+ run : |
41
+ export CFLAGS="-fprofile-arcs -ftest-coverage -g"
42
+ bash ${GITHUB_WORKSPACE}/support/scripts/build_internal.sh
40
43
41
44
# Generate consolidated coverage report and badges
42
45
- name : Generate Coverage Report and Badges
43
46
run : |
44
47
mkdir -p coverage
48
+ # Generate coverage report
45
49
gcovr --branches --xml-pretty --exclude-unreachable-branches -o coverage/coverage_report.xml
46
50
gcovr --branches --html --html-details -o coverage/coverage_report.html
47
51
48
52
# Extract coverage metrics
49
53
LINE_COVERAGE=$(grep 'line-rate' coverage/coverage_report.xml | sed -n 's/.*line-rate="\(.*\)".*/\1/p')
50
54
BRANCH_COVERAGE=$(grep 'branch-rate' coverage/coverage_report.xml | sed -n 's/.*branch-rate="\(.*\)".*/\1/p')
51
- LINE_COVERAGE_PERCENT=$(awk "BEGIN {print int($LINE_COVERAGE * 100)}")
52
- BRANCH_COVERAGE_PERCENT=$(awk "BEGIN {print int($BRANCH_COVERAGE * 100)}")
55
+
56
+ # Convert to percentages using printf and bc
57
+ LINE_COVERAGE_PERCENT=$(printf "%.0f" $(echo "$LINE_COVERAGE * 100" | bc))
58
+ BRANCH_COVERAGE_PERCENT=$(printf "%.0f" $(echo "$BRANCH_COVERAGE * 100" | bc))
53
59
54
60
# Generate badges
55
61
curl -o coverage/line-coverage-badge.svg "https://img.shields.io/badge/line%20coverage-${LINE_COVERAGE_PERCENT}%25-brightgreen"
73
79
with :
74
80
name : coverage-report
75
81
path : coverage
76
-
0 commit comments