Skip to content

Switching project tooling fully to uv #2132

Switching project tooling fully to uv

Switching project tooling fully to uv #2132

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python lint and tests
on:
push:
pull_request:
branches: ["*"]
jobs:
lint:
runs-on: ubuntu-latest
env:
UV_LOCKED: true
UV_COMPILE_BYTECODE: true
UV_NO_EDITABLE: true
UV_NO_PROGRESS: true
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Install uv and set the python version
id: setup-uv
uses: astral-sh/setup-uv@v7
with:
# https://docs.astral.sh/uv/guides/integration/github/#using-uv-in-github-actions
# It is considered best practice to pin to a specific uv version
version: "0.9.5"
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#enable-caching
enable-cache: true
cache-dependency-glob: uv.lock
- name: Do something if the cache was restored
if: steps.setup-uv.outputs.cache-hit == 'true'
run: echo "uv cache was restored"
- uses: actions/cache@v4
id: pre-commit-cache
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}-${{ hashFiles('uv.lock') }}
- name: Do something if the cache was restored
if: steps.pre-commit-cache.outputs.cache-hit == 'true'
run: echo "pre-commit cache was restored"
- name: Run pre-commit hooks
run: >
uv run
--verbose
pre-commit run
--all-files
--show-diff-on-failure --color=always
test:
needs: lint
runs-on: ubuntu-latest
env:
UV_LOCKED: true
UV_COMPILE_BYTECODE: true
UV_NO_EDITABLE: true
UV_NO_PROGRESS: true
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Install uv and set the python version
id: setup-uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
# https://docs.astral.sh/uv/guides/integration/github/#using-uv-in-github-actions
# It is considered best practice to pin to a specific uv version
version: "0.9.5"
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#enable-caching
enable-cache: true
cache-dependency-glob: uv.lock
- name: Do something if the cache was restored
if: steps.setup-uv.outputs.cache-hit == 'true'
run: echo "Cache was restored"
- name: Run tests
# For example, using `pytest`
run: uv run --verbose pytest -m ci