From fa935f89ab271bafd52eb87ff276e0521b5eb949 Mon Sep 17 00:00:00 2001 From: Stan Triepels <1939656+GDay@users.noreply.github.com> Date: Fri, 14 Aug 2026 17:26:55 +0200 Subject: [PATCH] Show test coverage in github pull request comment (#344) --- .github/workflows/test.yml | 39 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a9d859c..02fe26f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,6 +7,11 @@ on: branches: - master +# for code coverage comment +permissions: + contents: read + pull-requests: write + env: MONGO_HOST: "127.0.0.1" REDIS_HOST: "127.0.0.1" @@ -83,11 +88,6 @@ jobs: env: SERVICES: sqs MINISTACK_HOST: aws - # options: >- - # --health-cmd "wget -qO- http://localhost:4566/_ministack/ready || exit 1" - # --health-interval 2s - # --health-retries 15 - # --health-timeout 5s ports: - 4566:4566 steps: @@ -105,25 +105,12 @@ jobs: run: aws sqs create-queue --queue-name testing - name: Run Tests run: | - uv run pytest --cov=./django_q --cov-report=xml - - name: Upload to coveralls - run: | - python -m pip install coveralls - coveralls --service=github - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_FLAG_NAME: python-${{ matrix.python-version }}-django-${{ matrix.django }} - COVERALLS_PARALLEL: true + uv run pytest --cov=./django_q --cov-report=xml --junitxml=pytest.xml --cov-report=term-missing:skip-covered | tee pytest-coverage.txt - finish: - needs: test - runs-on: ubuntu-latest - container: python:3.11-bookworm - steps: - - name: Upload to coveralls - run: | - python -m pip install --upgrade pip - python -m pip install coveralls - coveralls --service=github --finish - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Coverage comment + if: matrix.python-version == '3.13' && matrix.django == '5.2' && github.event_name == 'pull_request' + uses: MishaKav/pytest-coverage-comment@v1 + with: + pytest-coverage-path: ./pytest-coverage.txt + junitxml-path: ./pytest.xml + report-only-changed-files: true