Use pre-commit as a linter the CI suite #376
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: | |
| branches: | |
| - main | |
| pull_request: | |
| jobs: | |
| pre-commit: | |
| if: startsWith(github.head_ref, 'dependabot/') != true | |
| name: pre-commit | |
| runs-on: ubuntu-latest | |
| outputs: | |
| file-names: ${{ steps.diff.outputs.file-names }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - run: echo "file-names=$(git diff --name-only ${{ github.event.pull_request.base.sha }} HEAD | grep '\.py$' | tr '\n' ' ' || true)" >> "$GITHUB_OUTPUT" | |
| id: diff | |
| - uses: astral-sh/setup-uv@v7 | |
| - uses: actions/cache@v5 | |
| with: | |
| path: ~/.cache/pre-commit/ | |
| key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} | |
| - run: SKIP=$(yq '.ci.skip' -o csv .pre-commit-config.yaml) uvx pre-commit run --all-files --show-diff-on-failure | |
| dist: | |
| runs-on: ubuntu-latest | |
| needs: [pre-commit] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.x" | |
| cache: 'pip' | |
| cache-dependency-path: '**/pyproject.toml' | |
| - run: python -m pip install --upgrade pip build twine | |
| - run: python -m build --sdist --wheel | |
| - run: python -m twine check dist/* | |
| docs: | |
| runs-on: ubuntu-latest | |
| needs: [pre-commit] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: setup Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.10" | |
| cache: 'pip' | |
| cache-dependency-path: '**/pyproject.toml' | |
| - run: python -m pip install -e .[docs] | |
| - run: python -m sphinx -b html -W docs docs/_build | |
| PyTest: | |
| runs-on: ubuntu-latest | |
| needs: [pre-commit] | |
| strategy: | |
| matrix: | |
| python-version: | |
| - "3.9" | |
| - "3.10" | |
| - "3.11" | |
| - "3.12" | |
| - "3.13" | |
| django-version: | |
| - "4.2" | |
| - "5.2" | |
| exclude: | |
| - python-version: "3.9" | |
| django-version: "5.2" | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup Python version ${{ matrix.python-version }} | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: 'pip' | |
| cache-dependency-path: '**/pyproject.toml' | |
| - run: python -m pip install .[test] | |
| - run: python -m pip install Django~="${{ matrix.django-version }}.0" | |
| - run: python -m pytest | |
| - uses: codecov/codecov-action@v3 |