TST: rewrite testing workflows around uv.lock #1840
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' | |
install-args: --resolution=lowest-direct | |
- os: ubuntu-latest | |
python-version: '3.13' | |
install-args: --all-extras | |
- os: macos-latest | |
python-version: '3.13' | |
- os: windows-latest | |
python-version: '3.13' | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4.2.0 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Run pytest | |
shell: bash | |
# could in principle be done through uv run coverage | |
# but env resolution appears buggy as of uv 0.4.20 | |
run: | | |
uv run --no-editable --group covcheck ${{ matrix.install-args }} \ | |
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@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4.2.0 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Typecheck | |
run: | | |
uv run --frozen --no-editable --group typecheck mypy nonos tests | |
image-tests: | |
name: Image tests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4.2.0 | |
with: | |
python-version: '3.13' | |
- name: Run Image Tests | |
run: | | |
uv run --frozen --no-editable --group test \ | |
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 --frozen --no-editable --group test \ | |
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@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
with: | |
name: nonos_pytest_mpl_results | |
path: nonos_pytest_mpl_results/* | |
- name: Upload pytest-mpl baseline | |
if: always() | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4.2.0 | |
with: | |
# Use latest Python, so it understands all syntax. | |
python-version: '3.13' | |
- run: uv tool install coverage | |
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | |
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@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4.2.0 | |
- name: Build | |
run: | | |
uvx --with-requirements=docs/requirements.txt mkdocs build | |
- name: Upload artifacts | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
with: | |
name: site | |
path: site |