Add python uv ci workflow
This commit is contained in:
87
.github/workflows/python-uv-ci.yml
vendored
Normal file
87
.github/workflows/python-uv-ci.yml
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
name: Python UV Quality
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
python_version:
|
||||
type: string
|
||||
default: "3.13"
|
||||
uv_version:
|
||||
type: string
|
||||
default: "latest"
|
||||
working_directory:
|
||||
type: string
|
||||
default: "."
|
||||
cache_dependency_path:
|
||||
type: string
|
||||
default: "uv.lock"
|
||||
uv_sync_args:
|
||||
type: string
|
||||
default: "--frozen --dev"
|
||||
format_command:
|
||||
type: string
|
||||
default: "uv run ruff format --check ."
|
||||
lint_command:
|
||||
type: string
|
||||
default: "uv run ruff check ."
|
||||
typecheck_command:
|
||||
type: string
|
||||
default: "uv run mypy ."
|
||||
test_command:
|
||||
type: string
|
||||
default: "uv run pytest"
|
||||
|
||||
jobs:
|
||||
quality:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ${{ inputs.working_directory }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ inputs.python_version }}
|
||||
|
||||
- name: Install uv
|
||||
env:
|
||||
UV_VERSION: ${{ inputs.uv_version }}
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
if [ -z "$UV_VERSION" ] || [ "$UV_VERSION" = "latest" ]; then
|
||||
python -m pip install uv
|
||||
else
|
||||
python -m pip install "uv==$UV_VERSION"
|
||||
fi
|
||||
|
||||
- name: Cache uv downloads
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/uv
|
||||
key: uv-${{ runner.os }}-${{ hashFiles(inputs.cache_dependency_path) }}
|
||||
restore-keys: |
|
||||
uv-${{ runner.os }}-
|
||||
|
||||
- name: Sync dependencies
|
||||
run: uv sync ${{ inputs.uv_sync_args }}
|
||||
|
||||
- name: Run format check
|
||||
if: ${{ inputs.format_command != '' }}
|
||||
run: ${{ inputs.format_command }}
|
||||
|
||||
- name: Run lint
|
||||
if: ${{ inputs.lint_command != '' }}
|
||||
run: ${{ inputs.lint_command }}
|
||||
|
||||
- name: Run typecheck
|
||||
if: ${{ inputs.typecheck_command != '' }}
|
||||
run: ${{ inputs.typecheck_command }}
|
||||
|
||||
- name: Run tests
|
||||
if: ${{ inputs.test_command != '' }}
|
||||
run: ${{ inputs.test_command }}
|
||||
Reference in New Issue
Block a user