Skip to content

Commit ac52643

Browse files
committed
ci: add pytest coverage and post as PR comment
Extends the pull request build to run pytest with coverage reporting.
1 parent 32f7093 commit ac52643

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

.github/workflows/build-pull-request.yaml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,22 @@ jobs:
3232
run: |
3333
python -m pip install --upgrade pip
3434
pip install .
35-
pip install mypy types-requests
35+
pip install pytest pytest-cov mypy types-requests
3636
37-
- name: Type check with mypy
37+
- name: Check types
3838
run: |
3939
mypy src
40+
41+
- name: Run tests
42+
run: |
43+
pytest -v --cov=src --cov-report=term-missing | tee coverage.txt
44+
tail -n 10 coverage.txt > coverage_summary.txt
45+
46+
- name: Post test coverage as PR comment
47+
if: matrix.python-version == '3.14'
48+
run: |
49+
body=$(printf "### Test Coverage Summary\n\`\`\`\n%s\n\`\`\`" "$(cat coverage_summary.txt)")
50+
gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
51+
-f body="$body"
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)