Skip to content

Commit 1fc9de2

Browse files
authored
[#258] Cleanup CI and Test Badge Creation
1 parent 9fd0a25 commit 1fc9de2

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

.github/workflows/mc_dc_coverage.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ on:
44
push:
55
branches:
66
- 258-cyclomatic-complexity-and-mcdc-in-ci
7+
paths-ignore:
8+
- 'coverage/line-coverage-badge.svg'
9+
- 'coverage/branch-coverage-badge.svg'
710
pull_request:
811
branches:
912
- 258-cyclomatic-complexity-and-mcdc-in-ci
1013

1114
jobs:
1215
coverage:
13-
if: "!contains(github.event.head_commit.message, 'Update coverage badges')" && github.actor != 'github-actions[bot]'
1416
runs-on: ubuntu-latest
1517
container:
1618
image: ivvitc/cryptolib:20240814
@@ -44,9 +46,7 @@ jobs:
4446
4547
# Step 4: Fix Detached HEAD State
4648
- name: Fix Detached HEAD State
47-
run: |
48-
git checkout -B ${GITHUB_REF##*/}
49-
working-directory: ${{ github.workspace }}
49+
run: git checkout -B ${GITHUB_REF##*/}
5050

5151
# Step 5: Build with Coverage Flags
5252
- name: Build with Coverage Flags
@@ -61,21 +61,17 @@ jobs:
6161
gcovr --branches --xml-pretty --exclude-unreachable-branches -o coverage/coverage_report.xml
6262
gcovr --branches --html --html-details -o coverage/coverage_report.html
6363
64-
# Extract coverage metrics
6564
LINE_COVERAGE=$(grep 'line-rate' coverage/coverage_report.xml | sed -n 's/.*line-rate="\(.*\)".*/\1/p')
6665
BRANCH_COVERAGE=$(grep 'branch-rate' coverage/coverage_report.xml | sed -n 's/.*branch-rate="\(.*\)".*/\1/p')
6766
68-
# Convert to percentages
6967
LINE_COVERAGE_PERCENT=$(printf "%.0f" $(echo "$LINE_COVERAGE * 100" | bc))
7068
BRANCH_COVERAGE_PERCENT=$(printf "%.0f" $(echo "$BRANCH_COVERAGE * 100" | bc))
7169
72-
# Generate badges
7370
curl -o coverage/line-coverage-badge.svg "https://img.shields.io/badge/line%20coverage-${LINE_COVERAGE_PERCENT}%25-brightgreen"
7471
curl -o coverage/branch-coverage-badge.svg "https://img.shields.io/badge/branch%20coverage-${BRANCH_COVERAGE_PERCENT}%25-brightgreen"
7572
7673
# Step 7: Commit Badges to the Current Branch
7774
- name: Commit Coverage Badges
78-
working-directory: ${{ github.workspace }}
7975
run: |
8076
git config user.name "github-actions"
8177
git config user.email "actions@github.com"

0 commit comments

Comments
 (0)