ci: mobile-friendly test results via GitHub Actions

Workflow upgrades:
- permissions: checks: write + pull-requests: write (required for annotations)
- pytest now outputs --junitxml=reports/junit.xml and --cov-report=xml
- EnricoMi/publish-unit-test-result-action@v2: posts a "pytest results"
  check annotation AND a PR comment showing pass/fail counts with
  per-test breakdown — both visible in the GitHub mobile app
- actions/upload-artifact@v4: uploads coverage.xml (14-day retention)
  browsable from the Actions tab on mobile

README:
- Live test badge at the top (green/red, links to Actions run history)

.gitignore:
- Add reports/ so generated junit.xml + coverage.xml are never committed

https://claude.ai/code/session_01M4L3R98N5fgXFZRvV8X9b6
This commit is contained in:
Claude
2026-02-19 19:41:01 +00:00
parent a84225b25a
commit 7829536952
3 changed files with 36 additions and 1 deletions

View File

@@ -10,6 +10,12 @@ jobs:
test:
runs-on: ubuntu-latest
# Required for publish-unit-test-result-action to post check runs and PR comments
permissions:
contents: read
checks: write
pull-requests: write
steps:
- uses: actions/checkout@v4
@@ -22,4 +28,30 @@ jobs:
run: pip install -e ".[dev]"
- name: Run tests
run: pytest --cov=src --cov-report=term-missing
run: |
pytest \
--tb=short \
--cov=src \
--cov-report=term-missing \
--cov-report=xml:reports/coverage.xml \
--junitxml=reports/junit.xml
# Posts a check annotation + PR comment showing pass/fail counts.
# Visible in the GitHub mobile app under Checks and in PR conversations.
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: reports/junit.xml
check_name: "pytest results"
comment_title: "Test Results"
report_individual_runs: true
# Coverage report available as a downloadable artifact in the Actions tab
- name: Upload coverage report
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
path: reports/coverage.xml
retention-days: 14