ref: implement peekable iterator and remove dependence on buffered line #99
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: Tests | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| pull_request: | |
| branches: | |
| - main | |
| - master | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Python 3.13 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.13" | |
| - name: Install uv | |
| run: | | |
| curl -LsSf https://astral.sh/uv/install.sh | sh | |
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
| - name: Cache dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/uv | |
| ~/.uv | |
| .venv | |
| key: ${{ runner.os }}-uv-${{ hashFiles('pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-uv- | |
| - name: Install dependencies | |
| run: uv sync | |
| - name: Run tests | |
| run: uv run pytest -v | |
| - name: generate coverage report | |
| id: coverage | |
| run: | | |
| set +e # disable exit on error temporarily | |
| report=$(uv run pytest --cov=retrocast --cov-report=term-missing) | |
| exit_code=$? | |
| set -e # re-enable exit on error | |
| # this is some bash magic to make the multiline report available to next steps | |
| echo "report<<EOF" >> $GITHUB_OUTPUT | |
| echo "$report" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| exit $exit_code # fail the step if tests failed | |
| - name: find changed files in src | |
| id: changed-src-files | |
| if: github.event_name == 'pull_request' | |
| uses: tj-actions/changed-files@v46 # check for the latest version, they update a lot | |
| with: | |
| files: src/** # or whatever your source directory is | |
| - name: print coverage report to logs | |
| run: | | |
| echo "${{ steps.coverage.outputs.report }}" | |
| - name: add coverage report as a pr comment | |
| if: github.event_name == 'pull_request' && steps.changed-src-files.outputs.any_changed == 'true' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const output = `### Pytest Coverage Report 🧪 | |
| \`\`\` | |
| ${{ steps.coverage.outputs.report }} | |
| \`\`\` | |
| `; | |
| github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: output | |
| }); |