Skip to content

Commit 82cabbf

Browse files
ci/coverage: Generate a badge
1 parent 37c19f3 commit 82cabbf

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

.github/workflows/coverage.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,19 @@ jobs:
136136
mkdir -p coverage-baseline
137137
echo "$CURRENT_COVERAGE" > coverage-baseline/main-coverage.txt
138138
139+
# Generate coverage badge
140+
COVERAGE_INT=$(echo "$CURRENT_COVERAGE" | cut -d. -f1)
141+
if [ "$COVERAGE_INT" -ge 80 ]; then
142+
COLOR="brightgreen"
143+
elif [ "$COVERAGE_INT" -ge 60 ]; then
144+
COLOR="yellow"
145+
else
146+
COLOR="red"
147+
fi
148+
149+
# Create badge SVG using shields.io format
150+
curl -s "https://img.shields.io/badge/coverage-${CURRENT_COVERAGE}%25-${COLOR}" > site/coverage/badge.svg
151+
139152
- name: Upload baseline coverage
140153
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
141154
uses: actions/upload-artifact@v4

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# OO7
22

3-
[![docs](https://docs.rs/oo7/badge.svg)](https://docs.rs/oo7/) [![crates.io](https://img.shields.io/crates/v/oo7)](https://crates.io/crates/oo7) ![CI](https://github.com/bilelmoussaoui/oo7/workflows/CI/badge.svg)
3+
[![docs](https://docs.rs/oo7/badge.svg)](https://docs.rs/oo7/) [![crates.io](https://img.shields.io/crates/v/oo7)](https://crates.io/crates/oo7) ![CI](https://github.com/bilelmoussaoui/oo7/workflows/CI/badge.svg) [![Coverage](https://bilelmoussaoui.github.io/oo7/coverage/badge.svg)](https://bilelmoussaoui.github.io/oo7/coverage/)
44

55
James Bond went on a new mission and this time as a [Secret Service provider](https://specifications.freedesktop.org/secret-service-spec/latest/).
66

0 commit comments

Comments
 (0)