From 8def022d4c68ac928a22b4ab214b9e7df9eb279f Mon Sep 17 00:00:00 2001 From: David Perl Date: Mon, 3 Aug 2026 14:13:19 +0200 Subject: [PATCH] fix: add coverage comment --- .gitea/workflows/ci.yml | 67 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 405276b4..48adc9cd 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v5 + uses: https://github.com/actions/checkout@v5 with: fetch-depth: 0 @@ -38,7 +38,7 @@ jobs: ruff check - name: Checkout pyright diff plugin - uses: actions/checkout@v5 + uses: https://github.com/actions/checkout@v5 with: repository: mx/diff_quality_basedpyright path: diff_quality_basedpyright @@ -51,14 +51,13 @@ jobs: test: runs-on: ubuntu-latest - needs: "lint" strategy: matrix: python-version: ["3.11", "3.12", "3.13"] steps: - name: Checkout code - uses: actions/checkout@v5 + uses: https://github.com/actions/checkout@v5 - name: Setup uses: ./.gitea/actions/install @@ -77,14 +76,13 @@ jobs: test-with-beamline-plugins: runs-on: ubuntu-latest - needs: ["lint", "test"] strategy: matrix: plugin_repo: ["pxi_bec", "pxii_bec", "pxiii_bec"] steps: - name: Checkout code - uses: actions/checkout@v5 + uses: https://github.com/actions/checkout@v5 - name: Setup uses: ./.gitea/actions/install @@ -111,11 +109,10 @@ jobs: test-with-coverage: runs-on: ubuntu-latest - needs: ["lint", "test", "test-with-beamline-plugins"] steps: - name: Checkout code - uses: actions/checkout@v5 + uses: https://github.com/actions/checkout@v5 - name: Setup uses: ./.gitea/actions/install @@ -131,3 +128,57 @@ jobs: run: | source .venv/bin/activate pytest --cov=aare --cov-config=./pyproject.toml --cov-branch --cov-report=xml --no-cov-on-fail ./tests/unit + + - name: Build coverage summary + run: | + source .venv/bin/activate + { + echo "" + echo "### Coverage report" + echo + echo "**Total line + branch coverage: $(coverage report --format=total)%**" + echo + echo "
Per-file breakdown" + echo + coverage report --format=markdown + echo + echo "
" + } > coverage-summary.md + + # Only the rendered summary is uploaded. coverage.xml (~1 MB) is rejected + # with an HTML 403 by the proxy in front of gitea.psi.ch. + - name: Upload coverage + uses: https://github.com/actions/upload-artifact@v3 + with: + name: coverage + path: coverage-summary.md + if-no-files-found: error + + coverage-analysis: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + needs: ["test-with-coverage"] + if: github.event_name == 'pull_request' + steps: + - name: Download coverage + uses: https://github.com/actions/download-artifact@v3 + with: + name: coverage + + - name: Find Comment + uses: https://github.com/peter-evans/find-comment@v3 + id: fc + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: "github-actions[bot]" + body-includes: "" + + - name: Create or update comment + uses: https://github.com/peter-evans/create-or-update-comment@v5 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body-path: coverage-summary.md + edit-mode: replace