diff --git a/.github/workflows/coverage b/.github/workflows/coverage deleted file mode 100644 index d31da75..0000000 --- a/.github/workflows/coverage +++ /dev/null @@ -1,48 +0,0 @@ -name: My Pytest Coverage Comment -on: - pull_request: - -permissions: - contents: read - pull-requests: write - -jobs: - live-test: - name: Live Test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Pytest coverage comment - id: coverageComment - uses: MishaKav/pytest-coverage-comment@main - with: - pytest-coverage-path: ./data/pytest-coverage_4.txt - junitxml-path: ./data/pytest_1.xml - - - name: Check the output coverage - run: | - echo "Coverage Percantage - ${{ steps.coverageComment.outputs.coverage }}" - echo "Coverage Color - ${{ steps.coverageComment.outputs.color }}" - echo "Coverage Html - ${{ steps.coverageComment.outputs.coverageHtml }}" - - echo "Coverage Warnings - ${{ steps.coverageComment.outputs.warnings }}" - - echo "Coverage Errors - ${{ steps.coverageComment.outputs.errors }}" - echo "Coverage Failures - ${{ steps.coverageComment.outputs.failures }}" - echo "Coverage Skipped - ${{ steps.coverageComment.outputs.skipped }}" - echo "Coverage Tests - ${{ steps.coverageComment.outputs.tests }}" - echo "Coverage Time - ${{ steps.coverageComment.outputs.time }}" - - echo "Not Success Test Info - ${{ steps.coverageComment.outputs.notSuccessTestInfo }}" - - - name: Create the Badge - uses: schneegans/dynamic-badges-action@v1.6.0 - with: - auth: ${{ secrets.PYTEST_COVERAGE_COMMENT }} - gistID: 5e90d640f8c212ab7bbac38f72323f80 - filename: pytest-coverage-comment__main.json - label: Coverage Report - message: ${{ steps.coverageComment.outputs.coverage }} - color: ${{ steps.coverageComment.outputs.color }} - namedLogo: python diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml new file mode 100644 index 0000000..928d8b3 --- /dev/null +++ b/.github/workflows/coverage.yaml @@ -0,0 +1,92 @@ +# Run tests + +name: "Test Suite" + +on: + push: + pull_request: + +defaults: + run: + shell: bash + +jobs: + tests: + name: "Python ${{ matrix.python-version }} on ${{ matrix.os }}" + runs-on: "${{ matrix.os }}" + + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - macos-latest + - windows-latest + python-version: + - "3.10" + + steps: + - name: "Check out the repo" + uses: "actions/checkout@v2" + + - name: "Set up Python" + uses: "actions/setup-python@v2" + with: + python-version: "${{ matrix.python-version }}" + + - name: "Install dependencies" + run: | + python -m pip install tox tox-gh-actions + pip install . + pip install coverage + + - name: "Run coverage" + run: | + coverage run -m pytest + - name: "Upload coverage data" + uses: actions/upload-artifact@v3 + with: + name: covdata + path: .coverage.* + + coverage: + name: Coverage + needs: tests + runs-on: ubuntu-latest + steps: + - name: "Check out the repo" + uses: "actions/checkout@v2" + + - name: "Set up Python" + uses: "actions/setup-python@v2" + with: + python-version: "3.10" + + - name: "Install dependencies" + run: | + python -m pip install tox tox-gh-actions + + - name: "Download coverage data" + uses: actions/download-artifact@v3 + with: + name: covdata + + - name: "Combine" + run: | + python -m tox -e coverage + export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])") + echo "total=$TOTAL" >> $GITHUB_ENV + echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY + + - name: "Make badge" + uses: schneegans/dynamic-badges-action@v1.4.0 + with: + # GIST_TOKEN is a GitHub personal access token with scope "gist". + auth: ${{ secrets.GIST_TOKEN }} + gistID: 123abc456def789 # replace with your real Gist id. + filename: covbadge.json + label: Coverage + message: ${{ env.total }}% + minColorRange: 50 + maxColorRange: 90 + valColorRange: ${{ env.total }}