Test Python projects using ruff, mypy, and pytest. Supports both UV and Poetry — auto-detected from your lock file.
- Installs Python
- Detects package manager (UV or Poetry) from lock file
- Installs the package manager and syncs dependencies (with caching)
- Runs
ruff formaton source directories (auto-fixes in place) - Runs
ruff check --fixon source directories (auto-fixes in place) - If checks fail and
repair-tokenis set, commits and pushes fixes - Runs
mypyon source directories - Runs
pytest
| Input | Description | Required | Default |
|---|---|---|---|
python-version |
Python version to use | No | 3.14 |
package-manager |
auto, uv, or poetry |
No | auto |
uv-version |
UV version to install | No | 0.11.2 |
poetry-version |
Poetry version to install | No | 2.3.3 |
src-dirs |
Source directories for linting (space-separated) | No | . |
working-directory |
Directory containing pyproject.toml | No | . |
run-pytest |
Whether to run pytest | No | true |
repair-token |
Token for git push. Enables auto-repair on failure. | No | "" |
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Test
uses: CVector-Energy/python-test@mainsteps:
- name: Checkout
uses: actions/checkout@v6
- name: Test
uses: CVector-Energy/python-test@main
with:
python-version: "3.12"jobs:
test:
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Test
uses: CVector-Energy/python-test@main
with:
python-version: ${{ matrix.python-version }}When checks fail, the repair step runs ruff check --fix and ruff format, then commits and pushes the fixes. Use a GitHub App token so the push triggers a new workflow run.
jobs:
test:
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- name: Create GitHub App Token
id: app
if: github.event_name == 'pull_request'
uses: actions/create-github-app-token@v2
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ github.head_ref }}
token: ${{ steps.app.outputs.token || github.token }}
- name: Test
uses: CVector-Energy/python-test@main
with:
repair-token: ${{ steps.app.outputs.token }}Your project must have:
pyproject.tomlwith[project]section andrequires-pythonuv.lock(for UV) orpoetry.lock(for Poetry)