Skip to content

ci: fix invalid YAML — replace PowerShell here-string with Add-Content #53

ci: fix invalid YAML — replace PowerShell here-string with Add-Content

ci: fix invalid YAML — replace PowerShell here-string with Add-Content #53

Workflow file for this run

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). Comment
# body assembled with line-by-line ``Add-Content`` to keep the
# script readable inside the YAML literal block and avoid a
# PowerShell here-string whose interior indentation would
# collide with the YAML block-scalar indent.
run: |
$fence = '```'
$sha = '${{ github.sha }}'
New-Item -ItemType File -Path comment.md -Force | Out-Null
Add-Content comment.md "### CI test failure (windows-2022 / Python 3.13)"
Add-Content comment.md ""
Add-Content comment.md "Commit: $sha"
Add-Content comment.md ""
Add-Content comment.md "Last 80 lines of pytest output:"
Add-Content comment.md ""
Add-Content comment.md $fence
Get-Content pytest.log -Tail 80 | Add-Content comment.md
Add-Content comment.md $fence
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
}