Skip to content

Commit a9d0618

Browse files
committed
ci(coverage): update tests.yaml to run with coverage on ubunutu + add badge to README
1 parent c111102 commit a9d0618

2 files changed

Lines changed: 32 additions & 5 deletions

File tree

.github/workflows/tests.yaml

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ jobs:
3333
3434
# Run tests using matrix strategy
3535
tests:
36+
permissions:
37+
contents: write
3638
needs: setup-matrix
3739
runs-on: ${{ matrix.os }}
3840
strategy:
@@ -57,8 +59,33 @@ jobs:
5759
if: runner.os != 'Windows'
5860
run: pip install -r requirements.txt
5961

60-
- name: Run tests
61-
run: pytest
62+
- name: Run tests (with coverage for linux)
63+
run: |
64+
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
65+
pytest --cov --cov-report=xml
66+
else
67+
pytest
68+
fi
69+
shell: bash
70+
71+
- name: Generate coverage badge (for-the-badge style)
72+
if: matrix.os == 'ubuntu-latest'
73+
run: genbadge coverage -i coverage.xml -o images/coverage-badge.svg
6274

63-
- name: List the environment variables
64-
run: env
75+
- name: Upload coverage badge
76+
if: matrix.os == 'ubuntu-latest'
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: coverage-badge
80+
path: images/coverage-badge.svg
81+
82+
- name: Commit coverage badge
83+
if: matrix.os == 'ubuntu-latest'
84+
run: |
85+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
86+
git config --local user.name "github-actions[bot]"
87+
git add images/coverage-badge.svg
88+
git commit -m "ci(tests): update coverage badge" || echo "No changes to commit"
89+
git push
90+
env:
91+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.14622466.svg)](https://doi.org/10.5281/zenodo.14622466)
88
[![Tests](https://github.com/pythonhealthdatascience/pydesrap_mms/actions/workflows/tests.yaml/badge.svg)](https://github.com/pythonhealthdatascience/pydesrap_mms/actions/workflows/tests.yaml)
99
[![Linting](https://github.com/pythonhealthdatascience/pydesrap_mms/actions/workflows/lint.yaml/badge.svg)](https://github.com/pythonhealthdatascience/pydesrap_mms/actions/workflows/lint.yaml)
10-
[![ORCID](https://img.shields.io/badge/ORCID_Amy_Heather-0000--0002--6596--3479-A6CE39?&logo=orcid&logoColor=white)](https://orcid.org/0000-0002-6596-3479)
10+
[![Coverage](https://github.com/pythonhealthdatascience/pydesrap_mms/raw/main/images/coverage-badge.svg)](https://github.com/pythonhealthdatascience/pydesrap_mms/actions/workflows/tests.yaml)
1111
</div>
1212

1313
## Repository overview

0 commit comments

Comments
 (0)