Skip to content

Commit ec631f8

Browse files
authored
[#258] Cleanup CI and Test Badge Creation
1 parent 4f619cd commit ec631f8

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

.github/workflows/mc_dc_coverage.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v4
1919

20+
# Install dependencies and setup environment
2021
- name: Install Dependencies
2122
env:
2223
DEBIAN_FRONTEND: noninteractive
@@ -34,22 +35,27 @@ jobs:
3435
cd /tmp/libgcrypt-1.11.0 && ./configure && make install
3536
ldconfig
3637
37-
# Build with coverage instrumentation
38+
# Build the project with coverage flags
3839
- 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
4043
4144
# Generate consolidated coverage report and badges
4245
- name: Generate Coverage Report and Badges
4346
run: |
4447
mkdir -p coverage
48+
# Generate coverage report
4549
gcovr --branches --xml-pretty --exclude-unreachable-branches -o coverage/coverage_report.xml
4650
gcovr --branches --html --html-details -o coverage/coverage_report.html
4751
4852
# Extract coverage metrics
4953
LINE_COVERAGE=$(grep 'line-rate' coverage/coverage_report.xml | sed -n 's/.*line-rate="\(.*\)".*/\1/p')
5054
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))
5359
5460
# Generate badges
5561
curl -o coverage/line-coverage-badge.svg "https://img.shields.io/badge/line%20coverage-${LINE_COVERAGE_PERCENT}%25-brightgreen"
@@ -73,4 +79,3 @@ jobs:
7379
with:
7480
name: coverage-report
7581
path: coverage
76-

0 commit comments

Comments
 (0)