Skip to content

Test

Test #1972

Workflow file for this run

name: Test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: "0 5 * * *"
concurrency: # Cancel previous runs that have not completed
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
pytest:
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
python:
# llvmlite (thus numba, thus sparse) usually lags the latest Python
# release. Only test SparseDataArray where possible.
# Earliest version supported by genno = earliest Python that has not
# reached EOL
- {version: "3.9", extras: ".[sparse]"}
- {version: "3.10", extras: ".[sparse]"}
- {version: "3.11", extras: ".[sparse]"}
- {version: "3.12", extras: ".[sparse]"}
# Latest release / latest supported by genno / testable on GHA
- {version: "3.13", extras: '"Pint > 0.24"'}
# For fresh releases and development versions of Python, compiled binary
# wheels are not available for some dependencies, e.g. numpy, pandas.
# Compiling these on the job runner requires a more elaborate build
# environment, currently out of scope for genno. Exclude these versions
# from CI.
# - {version: "3.14.0-beta.1", extras: ""} # Development version
fail-fast: false
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }}-py${{ matrix.python.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: ${{ env.depth }}
- name: Set up uv, Python
uses: astral-sh/setup-uv@v5
with:
cache-dependency-glob: "**/pyproject.toml"
python-version: ${{ matrix.python.version }}
- uses: ts-graphviz/setup-graphviz@v2
with:
macos-skip-brew-update: true
- name: Install the package and dependencies
run: uv pip install .[tests] ${{ matrix.python.extras }}
- name: Run tests
run: |
uv run --no-sync \
pytest \
--trace-config --color=yes --durations=20 -ra --verbose \
--cov-report=xml --cov-report=term \
--numprocesses=auto
shell: bash
- name: Upload test coverage to Codecov.io
uses: codecov/codecov-action@v5
pre-commit:
name: Code quality
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
cache-dependency-glob: "**/pyproject.toml"
python-version: "3.12" # TEMPORARY work around https://github.com/python/mypy/issues/18216
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
lookup-only: ${{ github.event_name == 'schedule' }} # Set 'true' to recreate cache
- run: uvx pre-commit run --all-files --color=always --show-diff-on-failure