ci: use PowerShell Tee-Object for test output capture on Windows #52
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | ||
| on: [push, pull_request] | ||
| env: | ||
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true' | ||
| jobs: | ||
| lint: | ||
| runs-on: windows-2022 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: astral-sh/setup-uv@v3 | ||
| - run: uv python install 3.13 | ||
| - run: uv sync --all-extras | ||
| - name: Lint | ||
| run: uv run ruff check | ||
| - name: Type check | ||
| run: uv run mypy src | ||
| test: | ||
| runs-on: windows-2022 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: astral-sh/setup-uv@v3 | ||
| - run: uv python install 3.13 | ||
| - run: uv sync --all-extras | ||
| - name: Test | ||
| id: test | ||
| # ``-rfE`` prints short tracebacks for failures and errors at the | ||
| # end of the run so a CI failure surfaces the actual assertion or | ||
| # exception in the log without needing to download artefacts. | ||
| # ``--tb=short`` keeps each entry compact (one line per frame) so | ||
| # the summary stays readable even when several tests fail at once. | ||
| # ``Tee-Object`` captures the stream while still surfacing it in | ||
| # the live log; PowerShell is the default Windows shell here so | ||
| # no ``shell:`` override is needed (the bash + tee combination | ||
| # deadlocked intermittently on git-bash for Windows). | ||
| run: | | ||
| uv run pytest -rfE --tb=short 2>&1 | Tee-Object -FilePath pytest.log | ||
| exit $LASTEXITCODE | ||
| - name: Surface failure summary to PR | ||
| if: failure() && github.event_name == 'pull_request' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| # Trim to the last 80 lines so a multi-failure run still fits in | ||
| # one PR comment (GitHub's per-comment cap is 65 KB). | ||
| run: | | ||
| $tail = Get-Content pytest.log -Tail 80 | Out-String | ||
| $body = @" | ||
| ### CI test failure (windows-2022 / Python 3.13) | ||
| Commit: ${{ github.sha }} | ||
| Last 80 lines of pytest output: | ||
| `````` | ||
| $tail | ||
| `````` | ||
| "@ | ||
| $body | Out-File -FilePath comment.md -Encoding utf8 | ||
| gh pr comment "${{ github.event.pull_request.number }}" --body-file comment.md | ||
| if ($LASTEXITCODE -ne 0) { | ||
| Write-Host "::warning::Could not post PR comment (push event with no PR?)" | ||
| exit 0 | ||
| } | ||