CI step to add test coverage as comment to PR
Code Quality Pipeline / code-quality (pull_request) Successful in 16s
Test Python Package / test (pull_request) Failing after 10s

This commit is contained in:
Brian Bjarke Jensen
2025-09-14 17:20:33 +02:00
parent 2ea75f23ee
commit c8891f2571
+17 -2
View File
@@ -26,7 +26,22 @@ jobs:
UV_LINK_MODE: copy UV_LINK_MODE: copy
run: uv sync run: uv sync
- name: Run pytest - name: Run pytest with coverage report
env: env:
PYTHONPATH: . PYTHONPATH: .
run: uv run pytest run: uv run pytest --cov=python_utils --cov-report=term-missing > coverage.txt
- name: Post coverage summary to PR
env:
BASEPAGE_URL: ${{ secrets.BASEPAGE_URL }}
REPO_OWNER: ${{ github.repository_owner }}
REPO_NAME: ${{ github.event.repository.name }}
PR_NUMBER: ${{ github.event.pull_request.number }}
CI_RUNNER_TOKEN: ${{ secrets.CI_RUNNER_TOKEN }}
run: |
COVERAGE=$(cat coverage.txt)
COMMENT_BODY="**Test Coverage Report:**\n\`\`\`\n$COVERAGE\n\`\`\`"
curl -s -X POST "$BASEPAGE_URL/repos/$REPO_OWNER/$REPO_NAME/issues/$PR_NUMBER/comments" \
-H "Authorization: token $CI_RUNNER_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"body\": \"$COMMENT_BODY\"}"