From 0e65f476d6d0073d3aa1965727464a6c5387978e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Mu=C3=B1oz?= Date: Tue, 7 May 2024 17:03:56 -0400 Subject: [PATCH] add coverage badge --- .github/workflows/tests.yml | 25 ++++++++++++++++++++++--- README.md | 3 +++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index bea666c..f3439b5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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: @@ -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 '//,//c\\n\${{ steps.coverageComment.outputs.coverageHtml }}\n' ./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: diff --git a/README.md b/README.md index bc8377c..95a7237 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ + + + # Python-Library-Template This is a template for a Python library. It includes a README.md file,