Skip to content

Commit bf5df5e

Browse files
committed
ci: fix coverage badge
1 parent e0b5519 commit bf5df5e

2 files changed

Lines changed: 46 additions & 11 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Update Coverage Badge
2+
on:
3+
push:
4+
branches: [master]
5+
6+
permissions:
7+
contents: write
8+
9+
jobs:
10+
update-badge:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v6
14+
with:
15+
persist-credentials: false
16+
fetch-depth: 0
17+
18+
- name: Set up Python
19+
uses: astral-sh/setup-uv@v7
20+
with:
21+
python-version: 3.13
22+
23+
- name: Install Dependencies
24+
run: uv sync --all-extras
25+
26+
- name: Run Tests
27+
run: uv run pytest --slow --cov=. --cov-report=xml:coverage.xml
28+
29+
- name: Coverage comment
30+
id: coverage
31+
uses: MishaKav/pytest-coverage-comment@v1.2.0
32+
with:
33+
pytest-xml-coverage-path: ./coverage.xml
34+
junitxml-path: ./pytest.xml
35+
hide-comment: true
36+
37+
- name: Update README
38+
run: |
39+
sed -i '/<!-- Pytest Coverage Comment:Begin -->/,/<!-- Pytest Coverage Comment:End -->/c\<!-- Pytest Coverage Comment:Begin -->\n${{ steps.coverage.outputs.coverageHtml }}\n<!-- Pytest Coverage Comment:End -->' ./README.md
40+
41+
- name: Commit changes
42+
uses: stefanzweifel/git-auto-commit-action@v7
43+
with:
44+
commit_message: "docs: update coverage badge"
45+
file_pattern: README.md

.github/workflows/tests.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [master]
88

99
permissions:
10-
contents: write
10+
contents: read
1111
pull-requests: write
1212

1313
jobs:
@@ -47,13 +47,3 @@ jobs:
4747
junitxml-path: ./pytest.xml
4848
unique-id-for-comment: ${{ matrix.python-version }}-${{ matrix.config.os }}
4949
title: Coverage for Python ${{ matrix.python-version }} on ${{ matrix.config.os }}
50-
51-
- name: Update README
52-
run: |
53-
sed -i '/<!-- Pytest Coverage Comment:Begin -->/,/<!-- Pytest Coverage Comment:End -->/c\<!-- Pytest Coverage Comment:Begin -->\n${{ steps.coverage.outputs.coverageHtml }}\n<!-- Pytest Coverage Comment:End -->' ./README.md
54-
55-
- name: Commit changes
56-
uses: stefanzweifel/git-auto-commit-action@v7
57-
with:
58-
commit_message: "docs: update coverage badge"
59-
file_pattern: README.md

0 commit comments

Comments
 (0)