From 74bd39fcd36d21134eb4e4e32add06b3c3753c7e Mon Sep 17 00:00:00 2001 From: estebanthi Date: Sun, 4 Jan 2026 16:07:16 +0100 Subject: [PATCH] Add python uv ci workflow --- .github/workflows/python-uv-ci.yml | 87 ++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 .github/workflows/python-uv-ci.yml diff --git a/.github/workflows/python-uv-ci.yml b/.github/workflows/python-uv-ci.yml new file mode 100644 index 0000000..a1004fd --- /dev/null +++ b/.github/workflows/python-uv-ci.yml @@ -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 }}