Skip to content

Commit db74ced

Browse files
nir0sclaude
andcommitted
Generate coverage badge in CI without Codecov
Add a Coverage workflow that runs on pushes to master, generates a coverage report via tox, builds an SVG badge with genbadge, and force-pushes it to an orphan coverage-badge branch. README links the raw badge file. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 432080b commit db74ced

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

.github/workflows/coverage.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Coverage
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
coverage:
13+
name: Generate coverage badge
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v5
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v6
21+
with:
22+
python-version: "3.12"
23+
24+
- name: Install tox and genbadge
25+
run: python -m pip install tox "genbadge[coverage]"
26+
27+
- name: Run tests with coverage
28+
run: tox -e py -- --cov-report xml
29+
30+
- name: Generate coverage badge
31+
run: genbadge coverage -i coverage.xml -o coverage.svg
32+
33+
- name: Publish badge to coverage-badge branch
34+
run: |
35+
cp coverage.svg "${RUNNER_TEMP}/coverage.svg"
36+
git config user.name "github-actions[bot]"
37+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
38+
git checkout --orphan coverage-badge
39+
git rm -rf . > /dev/null 2>&1 || true
40+
cp "${RUNNER_TEMP}/coverage.svg" coverage.svg
41+
git add coverage.svg
42+
git commit -m "Update coverage badge"
43+
git push --force origin coverage-badge

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Distro - an OS platform information API
44
[![CI Status](https://github.com/python-distro/distro/workflows/CI/badge.svg)](https://github.com/python-distro/distro/actions/workflows/ci.yaml)
55
[![PyPI version](http://img.shields.io/pypi/v/distro.svg)](https://pypi.python.org/pypi/distro)
66
[![Supported Python Versions](https://img.shields.io/pypi/pyversions/distro.svg)](https://img.shields.io/pypi/pyversions/distro.svg)
7+
[![Code Coverage](https://raw.githubusercontent.com/python-distro/distro/coverage-badge/coverage.svg)](https://github.com/python-distro/distro/actions/workflows/coverage.yaml)
78
[![Is Wheel](https://img.shields.io/pypi/wheel/distro.svg?style=flat)](https://pypi.python.org/pypi/distro)
89
[![Latest Github Release](https://readthedocs.org/projects/distro/badge/?version=stable)](http://distro.readthedocs.io/en/latest/)
910

0 commit comments

Comments
 (0)