BLD: migrate package layout to src #1717
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
paths-ignore: | |
- README.md | |
schedule: | |
# run this once a week (wednesday) at 3 am UTC | |
- cron: 0 3 * * 3 | |
workflow_dispatch: | |
jobs: | |
tests: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-latest | |
python-version: | |
- '3.9' | |
- '3.10' | |
- '3.11' | |
- '3.12' | |
- '3.13' | |
include: | |
- os: ubuntu-20.04 | |
python-version: '3.9' | |
deps: minimal | |
install-args: --resolution=lowest-direct | |
- os: macos-latest | |
python-version: '3.13' | |
- os: windows-latest | |
python-version: '3.13' | |
runs-on: ${{ matrix.os }} | |
env: | |
TEST_REQ_FILE: ${{ matrix.deps == 'minimal' && 'requirements/tests_min.txt' || 'requirements/tests_all.txt' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
cache-dependency-glob: | | |
**/requirements/*.txt | |
**/pyproject.toml | |
- run: | | |
uv venv | |
uv pip install . ${{ matrix.install-args }} | |
- name: Install test dependencies (UNIX) | |
if: matrix.os != 'windows-latest' | |
run: uv pip install --requirement $TEST_REQ_FILE | |
- name: Install test dependencies (Windows) | |
if: matrix.os == 'windows-latest' | |
run: uv pip install --requirement $env:TEST_REQ_FILE | |
- run: uv pip list | |
- name: Run pytest (without coverage) | |
if: ${{ !startsWith(matrix.os, 'ubuntu') }} | |
run: uv run --no-project pytest --color=yes | |
- name: Run pytest (with coverage) | |
if: startsWith(matrix.os, 'ubuntu') | |
run: | | |
uv run --no-project coverage run --parallel-mode -m pytest --color=yes | |
- name: Upload coverage data | |
# only using reports from ubuntu because | |
# combining reports from multiple platforms is tricky (or impossible ?) | |
if: startsWith(matrix.os, 'ubuntu') | |
uses: actions/upload-artifact@v4 | |
with: | |
name: nonos_coverage_data-${{ matrix.os }}-${{ matrix.python-version }} | |
path: .coverage.* | |
if-no-files-found: ignore | |
include-hidden-files: true | |
type-check: | |
strategy: | |
matrix: | |
python-version: | |
- '3.9' | |
- '3.10' | |
- '3.11' | |
- '3.12' | |
- '3.13' | |
runs-on: ubuntu-latest | |
name: type-checking | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
cache-dependency-glob: | | |
**/requirements/typecheck.txt | |
**/pyproject.toml | |
- name: Run mypy | |
run: | | |
uvx --with-requirements=requirements/typecheck.txt --with . mypy src/nonos tests | |
image-tests: | |
name: Image tests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
cache-dependency-glob: | | |
**/requirements/tests_min.txt | |
**/pyproject.toml | |
- name: Build | |
run: | | |
uv sync | |
uv pip install --requirement requirements/tests_min.txt | |
- run: uv pip list | |
- name: Run Image Tests | |
run: | | |
uv run pytest --color=yes --mpl -m mpl_image_compare \ | |
--mpl-generate-summary=html \ | |
--mpl-results-path=nonos_pytest_mpl_results \ | |
--mpl-baseline-path=tests/pytest_mpl_baseline | |
- name: Generate new image baseline | |
if: failure() | |
run: | | |
uv run pytest --color=yes --mpl -m mpl_image_compare \ | |
--mpl-generate-path=nonos_pytest_mpl_new_baseline \ | |
--last-failed | |
# always attempt to upload artifacts, even | |
# (and especially) in case of failure. | |
- name: Upload pytest-mpl report | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: nonos_pytest_mpl_results | |
path: nonos_pytest_mpl_results/* | |
- name: Upload pytest-mpl baseline | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: nonos_pytest_mpl_new_baseline | |
path: nonos_pytest_mpl_new_baseline/* | |
if-no-files-found: ignore | |
coverage: | |
name: Combine coverage reports | |
runs-on: ubuntu-latest | |
needs: tests | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: astral-sh/setup-uv@v3 | |
# Use latest Python, so it understands all syntax. | |
- run: uv tool install --python 3.13 coverage | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: nonos_coverage_data-* | |
merge-multiple: true | |
- name: Check coverage | |
run: | | |
coverage combine | |
coverage html --skip-covered --skip-empty | |
coverage report --fail-under=80 | |
- name: Upload HTML report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: nonos_coverage_report | |
path: htmlcov | |
if: ${{ always() }} | |
docs: | |
runs-on: ubuntu-latest | |
name: docs | |
concurrency: | |
group: ${{ github.ref }}-docs | |
cancel-in-progress: true | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
cache-dependency-glob: | | |
**/requirements/docs.txt | |
**/pyproject.toml | |
- name: Build | |
run: | | |
uvx --with-requirements=requirements/docs.txt mkdocs build | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: site | |
path: site |