Skip to content

Try using uv for unit test workflow #266

Try using uv for unit test workflow

Try using uv for unit test workflow #266

Workflow file for this run

name: unit tests
on:
push:
branches:
- "**"
paths:
- 'undate/**'
- 'tests/**'
pull_request:
branches:
- "**"
env:
# python version used to calculate and submit code coverage
COV_PYTHON_VERSION: "3.12"
jobs:
python-unit:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
defaults:
run:
working-directory: .
steps:
- uses: actions/checkout@v4
# use github python action instead of uv to take advantage of caching
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Install package with dev and test dependencies
run: uv sync --extra test
# for all versions but the one we use for code coverage, run normally
- name: Run unit tests normally
run: uv run pytest
if: ${{ matrix.python != env.COV_PYTHON_VERSION }}
# run code coverage in one version only
- name: Run unit tests with code coverage reporting
run: uv run pytest --cov=undate
if: ${{ matrix.python == env.COV_PYTHON_VERSION }}
- name: Upload test coverage to Codecov
uses: codecov/codecov-action@v3
if: ${{ matrix.python == env.COV_PYTHON_VERSION }}