Skip to content

Commit e64ad2e

Browse files
author
Gunther Klessinger
committed
simpler cov
1 parent 40c63c7 commit e64ad2e

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,18 @@ jobs:
146146
- name: Extract coverage percentage
147147
id: coverage
148148
run: |
149-
COVERAGE=$(grep "TOTAL" coverage_report.txt | awk '{print $4}' | sed 's/%//')
149+
COVERAGE=$(grep "TOTAL" coverage_report.txt | awk '{print $4}' | sed 's/%//' | head -1)
150+
echo "Coverage: $COVERAGE%"
150151
echo "percentage=$COVERAGE" >> $GITHUB_OUTPUT
151152
152153
- name: Create coverage badge
153-
uses: schneegans/dynamic-badges-action@v1.7.0
154-
with:
155-
auth: ${{ secrets.GITHUB_TOKEN }}
156-
gistID: ${{ vars.COVERAGE_GIST_ID }} # Set this in repository variables
157-
filename: docutools-coverage.json
158-
label: Coverage
159-
message: ${{ steps.coverage.outputs.percentage }}%
160-
color: ${{ steps.coverage.outputs.percentage > 80 && 'green' || steps.coverage.outputs.percentage > 60 && 'yellow' || 'red' }}
154+
run: |
155+
COVERAGE=$(grep "TOTAL" coverage_report.txt | awk '{print $4}' | sed 's/%//' | head -1)
156+
echo "Coverage: $COVERAGE%"
157+
COLOR="red"
158+
if (( $(echo "$COVERAGE > 80" | bc -l) )); then COLOR="brightgreen"; fi
159+
if (( $(echo "$COVERAGE > 60 && $COVERAGE <= 80" | bc -l) )); then COLOR="yellow"; fi
160+
161+
# Create a simple coverage badge URL for README
162+
echo "Add this to your README:"
163+
echo "[![Coverage](https://img.shields.io/badge/coverage-${COVERAGE}%25-${COLOR})](https://github.com/axiros/docutools/actions/workflows/ci.yml)"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[gh-ci]: https://github.com/axiros/docutools/actions/workflows/ci.yml
99
[gh-ci_img]: https://github.com/axiros/docutools/actions/workflows/ci.yml/badge.svg
1010
[coverage]: https://github.com/axiros/docutools/actions/workflows/ci.yml
11-
[coverage_img]: https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/YOUR_USERNAME/YOUR_GIST_ID/raw/docutools-coverage.json
11+
[coverage_img]: https://img.shields.io/badge/dynamic/xml?color=brightgreen&label=coverage&query=%2F%2F%40line-rate&suffix=%25&url=https%3A%2F%2Fraw.githubusercontent.com%2Faxiros%2Fdocutools%2Fmain%2Fcoverage.xml
1212
[pkg]: https://pypi.org/project/docutools/2022.04.11/
1313
[pkg_img]: https://axiros.github.io/docutools/img/badge_pypi.svg
1414
[code_style]: https://github.com/astral-sh/ruff

0 commit comments

Comments
 (0)