name: Test
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
workflow_dispatch:
workflow_call:
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: |
uv sync --extra dev
- name: Run linting
run: |
uv run ruff check .
uv run ruff format --check .
- name: Run type checking
run: |
uv run mypy src --ignore-missing-imports
- name: Run tests with coverage
run: |
uv run pytest tests/ --cov=src --cov-report=term --cov-report=xml --cov-report=html
- name: Upload coverage reports
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
- name: Check coverage threshold
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
run: |
uv run python -c "
import xml.etree.ElementTree as ET
tree = ET.parse('coverage.xml')
root = tree.getroot()
coverage = float(root.attrib['line-rate']) * 100
print(f'Coverage: {coverage:.2f}%')
if coverage < 70:
print(f'Coverage {coverage:.2f}% is below 70% threshold')
exit(1)
"