A GitHub Action that validates if your uv.lock file and optionally
requirements.txt files are in sync with your pyproject.toml file.
- Validates
uv.lockfile againstpyproject.toml - Optionally validates
requirements.txtfiles - Supports custom paths for all files
- Supports custom uv commands for requirements generation
- Automatically detects Python version from
pyproject.toml
name: Check Dependencies
on:
pull_request:
paths:
- 'pyproject.toml'
- 'uv.lock'
- 'requirements.txt'
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hbelmiro/uv-lock-check@v1- uses: hbelmiro/uv-lock-check@v1
with:
pyproject-path: 'path/to/pyproject.toml'
requirements-path: 'path/to/requirements.txt'- uses: hbelmiro/uv-lock-check@v1
with:
command: 'uv pip compile --python-platform=linux pyproject.toml -o requirements-linux.txt'
requirements-path: 'requirements-linux.txt'| Input | Description | Required | Default |
|---|---|---|---|
pyproject-path |
Path to the pyproject.toml file | No | pyproject.toml |
requirements-path |
Path to the requirements.txt file. If empty, will look for requirements.txt in the same directory as pyproject.toml | No | '' |
command |
uv command to run for validation | No | uv sync |
show-diff |
Show git diff output when files are out of sync | No | false |
diff-max-lines |
Maximum number of diff lines to display when show-diff is enabled |
No | 200 |
- The action reads the Python version from your
pyproject.tomlfile - It runs the specified command (defaults to
uv sync) to check if theuv.lockfile is in sync - If a
requirements.txtfile is specified:- It generates a new requirements file using the provided command
- Compares it with the existing one
- Fails if they don't match
- uses: hbelmiro/uv-lock-check@v1
with:
command: 'uv pip compile --python-platform=linux pyproject.toml -o requirements-linux.txt'
requirements-path: 'requirements-linux.txt'- uses: hbelmiro/uv-lock-check@v1
with:
show-diff: 'true'
diff-max-lines: '500'- name: Check Linux Requirements
uses: hbelmiro/uv-lock-check@v1
with:
command: 'uv pip compile --python-platform=linux pyproject.toml -o requirements-linux.txt'
requirements-path: 'requirements-linux.txt'
- name: Check Windows Requirements
uses: hbelmiro/uv-lock-check@v1
with:
command: 'uv pip compile --python-platform=windows pyproject.toml -o requirements-win.txt'
requirements-path: 'requirements-win.txt'uv sync --group devRun unit tests:
uv run pytest -vRun with coverage:
uv run pytest --cov --cov-report=term-missinguv run ruff check .
uv run ty checkuv run pre-commit run --all-filesApache License 2.0 - see LICENSE for details