Skip to content

Commit

Permalink
add coverage badge
Browse files Browse the repository at this point in the history
  • Loading branch information
Francisco Muñoz committed May 7, 2024
1 parent 71fa0fe commit 0e65f47
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
25 changes: 22 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
Expand All @@ -42,13 +45,29 @@ jobs:
thresholdAll: 0.8
thresholdNew: 0.9
token: ${{ secrets.GITHUB_TOKEN }}

# This does not works :(
- name: Upload badge
if: ${{ matrix.python-version == '3.12' }}
- name: Pytest coverage comment
if: ${{ matrix.python-version == '3.12' && github.ref == 'refs/heads/main'}}
id: coverageComment
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: ./pytest-coverage.txt
pytest-xml-coverage-path: ./reports/coverage/coverage.xml
hide-comment: true
# hide-badge: true
# hide-report: true

- name: Update Readme with Coverage Html
if: ${{ github.ref == 'refs/heads/main' }}
run: |
sed -i '/<!-- Pytest Coverage Comment:Begin -->/,/<!-- Pytest Coverage Comment:End -->/c\<!-- Pytest Coverage Comment:Begin -->\n\${{ steps.coverageComment.outputs.coverageHtml }}\n<!-- Pytest Coverage Comment:End -->' ./README.md
- name: Commit & Push changes to Readme
if: ${{ github.ref == 'refs/heads/main' }}
uses: actions-js/push@master
with:
message: Update coverage on Readme
github_token: ${{ secrets.GITHUB_TOKEN }}


macos:
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<!-- Pytest Coverage Comment:Begin -->
<!-- Pytest Coverage Comment:End -->

# Python-Library-Template

This is a template for a Python library. It includes a README.md file,
Expand Down

0 comments on commit 0e65f47

Please sign in to comment.