Skip to content

Commit 12a03de

Browse files
committed
ci: post failure summary as PR comment when Windows test job fails
CI runs on windows-2022 with Python 3.13. Failures are only visible to people who can authenticate against GitHub Actions logs; remote contributors and tools that can read PR comments but not Action logs end up blind. The new ``Surface failure summary to PR`` step: - Runs only when the prior test step failed AND the workflow was triggered by a PR event (push-only workflows are unaffected, and there's no PR to attach the comment to anyway). - Tail-trims the captured pytest output to 80 lines so even a multi-failure run fits inside GitHub's 65 KB per-comment cap. - Uses ``GITHUB_TOKEN`` (already in scope for any PR workflow) so no additional secrets are required. The Test step itself is unchanged in command and meaning; it just pipes through ``tee pytest.log`` so the on-failure step has the output to read. ``pipefail`` keeps the original exit code through the tee.
1 parent 56fd488 commit 12a03de

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

‎.github/workflows/ci.yml‎

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,37 @@ jobs:
2525
- run: uv python install 3.13
2626
- run: uv sync --all-extras
2727
- name: Test
28+
id: test
2829
# ``-rfE`` prints short tracebacks for failures and errors at the
2930
# end of the run so a CI failure surfaces the actual assertion or
3031
# exception in the log without needing to download artefacts.
3132
# ``--tb=short`` keeps each entry compact (one line per frame) so
3233
# the summary stays readable even when several tests fail at once.
33-
run: uv run pytest -rfE --tb=short
34+
# Tee'd to ``pytest.log`` so the on-failure step below can post the
35+
# tail to the PR as a comment — Windows-only failures are otherwise
36+
# invisible to anyone without GitHub Actions log access.
37+
shell: bash
38+
run: |
39+
set -o pipefail
40+
uv run pytest -rfE --tb=short 2>&1 | tee pytest.log
41+
42+
- name: Surface failure summary to PR
43+
if: failure() && github.event_name == 'pull_request'
44+
shell: bash
45+
env:
46+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
run: |
48+
# Trim to the last 80 lines so a multi-failure run still fits in
49+
# one PR comment (GitHub's per-comment cap is 65 KB).
50+
{
51+
echo "### CI test failure (windows-2022 / Python 3.13)"
52+
echo ""
53+
echo "Commit: ${{ github.sha }}"
54+
echo ""
55+
echo "Last 80 lines of pytest output:"
56+
echo ""
57+
echo '```'
58+
tail -n 80 pytest.log || true
59+
echo '```'
60+
} > comment.md
61+
gh pr comment "${{ github.event.pull_request.number }}" --body-file comment.md

0 commit comments

Comments
 (0)