ci: pre-commit workflow (#567) #586
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: Run tests | |
| on: [push, pull_request] | |
| jobs: | |
| pre-commit: | |
| name: pre-commit | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Install uv and set the Python version | |
| uses: astral-sh/setup-uv@v10.0.0 | |
| with: | |
| # Matches default_language_version in .pre-commit-config.yaml. | |
| python-version: "3.10" | |
| enable-cache: true | |
| version: "latest-known" | |
| - name: Install dependencies | |
| run: uv sync --locked --dev | |
| - name: Cache pre-commit environments | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pre-commit | |
| key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} | |
| # Fails the job on any hook finding, including hooks that "only" rewrite a | |
| # file (ruff-format, end-of-file-fixer, ...). --show-diff-on-failure prints | |
| # the exact edit that would have been applied. | |
| - name: Run pre-commit | |
| run: uv run pre-commit run --all-files --show-diff-on-failure --color=always | |
| tests: | |
| name: Test Python ${{ matrix.python-version }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.15", "3.14", "3.13", "3.12", "3.11", "3.10"] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Install uv and set the Python version | |
| uses: astral-sh/setup-uv@v10.0.0 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| enable-cache: true | |
| version: "latest-known" | |
| - name: Install dependencies | |
| run: uv sync --locked --dev | |
| - name: Run tests | |
| run: uv run pytest |