Skip to content

Commit

Permalink
Merge pull request #390 from neutrinoceros/tst/dep_locking
Browse files Browse the repository at this point in the history
TST: rewrite testing workflows around uv.lock
  • Loading branch information
neutrinoceros authored Dec 16, 2024
2 parents c5ef2e7 + 2d422af commit cdac623
Show file tree
Hide file tree
Showing 12 changed files with 1,549 additions and 112 deletions.
9 changes: 0 additions & 9 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@

version: 2
updates:
- package-ecosystem: pip
directory: /requirements
schedule:
interval: monthly
groups:
actions:
patterns:
- '*'

- package-ecosystem: github-actions
directory: /.github/workflows
schedule:
Expand Down
24 changes: 8 additions & 16 deletions .github/workflows/bleeding-edge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,15 @@ jobs:
with:
python-version: 3.13-dev
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4.2.0
with:
enable-cache: true
cache-dependency-glob: |
**/requirements/test_all.txt
**/pyproject.toml
- name: Build
- name: Configure uv
run: |
uv venv
uv pip install numpy matplotlib scipy --pre --no-build --extra-index-url \
https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
uv pip install .
uv pip install --requirement requirements/tests_all.txt
- run: uv pip list
echo "UV_PYTHON_PREFERENCE=only-system" >> $GITHUB_ENV
pin=${{ matrix.python-version }}
echo "UV_PYTHON=${pin%-dev}" >> $GITHUB_ENV
echo "UV_PRERELEASE=allow" >> $GITHUB_ENV
echo "UV_EXTRA_INDEX_URL=https://pypi.anaconda.org/scientific-python-nightly-wheels/simple" >> $GITHUB_ENV
- name: Run pytest
run: |
source .venv/bin/activate
pytest --color=yes -ra
uv run --no-editable --all-extras --group test \
pytest --color=yes
107 changes: 33 additions & 74 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,68 +27,49 @@ jobs:
- '3.11'
- '3.12'
- '3.13'
venv-loc: [bin]
label: ['']
include:
- os: ubuntu-20.04
python-version: '3.9'
venv-loc: bin
deps: minimal
label: (oldest deps, mininmal)
install-args: --resolution=lowest-direct
- os: ubuntu-20.04
python-version: '3.9'
label: (oldest deps, full)
install-args: --resolution=lowest-direct --all-extras --compile-bytecode
- os: ubuntu-latest
python-version: '3.13'
install-args: --all-extras
label: (full)
- os: macos-latest
python-version: '3.13'
venv-loc: bin
- os: windows-latest
python-version: '3.13'
venv-loc: Scripts

name: ${{ matrix.os }}-py${{ matrix.python-version }} ${{ matrix.label }}
runs-on: ${{ matrix.os }}
env:
TEST_REQ_FILE: ${{ matrix.deps == 'minimal' && 'requirements/tests_min.txt' || 'requirements/tests_all.txt' }}

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4.2.0
with:
enable-cache: true
cache-dependency-glob: |
**/requirements/*.txt
**/pyproject.toml
# could in principle be done through uv sync but
# env resolution appears buggy as of uv 0.4.20
- 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
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: |
source .venv/${{matrix.venv-loc}}/activate
coverage run --parallel-mode -m pytest --color=yes
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 }}
name: nonos_coverage_data-${{ matrix.os }}-${{ matrix.python-version }}${{ matrix.label }}
path: .coverage.*
if-no-files-found: ignore
include-hidden-files: true
Expand All @@ -108,57 +89,39 @@ jobs:

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4.2.0
with:
enable-cache: true
cache-dependency-glob: |
**/requirements/typecheck.txt
**/pyproject.toml
python-version: ${{ matrix.python-version }}

- name: Run mypy
- name: Typecheck
run: |
uvx --with-requirements=requirements/typecheck.txt --with . mypy nonos tests
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
- name: Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: 3.x
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4.2.0
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
python-version: '3.13'

- 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
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 pytest --color=yes --mpl -m mpl_image_compare \
--mpl-generate-path=nonos_pytest_mpl_new_baseline \
--last-failed
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.
Expand All @@ -185,9 +148,11 @@ jobs:
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'

# Use latest Python, so it understands all syntax.
- run: uv tool install --python 3.13 coverage
- run: uv tool install coverage

- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
Expand Down Expand Up @@ -218,15 +183,9 @@ jobs:
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4.2.0
with:
enable-cache: true
cache-dependency-glob: |
**/requirements/docs.txt
**/pyproject.toml
- name: Build
run: |
uvx --with-requirements=requirements/docs.txt mkdocs build
uvx --with-requirements=docs/requirements.txt mkdocs build
- name: Upload artifacts
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
Expand Down
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ repos:
- id: end-of-file-fixer
- id: check-toml

- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.5.8
hooks:
- id: uv-lock

- repo: https://github.com/crate-ci/typos
rev: v1.26.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ mkdocs:
# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: requirements/docs.txt
- requirements: docs/requirements.txt
File renamed without changes.
109 changes: 109 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# This file was autogenerated by uv via the following command:
# uv pip compile docs/requirements.in
babel==2.16.0
# via mkdocs-material
bracex==2.5.post1
# via wcmatch
certifi==2024.12.14
# via requests
charset-normalizer==3.4.0
# via requests
click==8.1.7
# via
# mkdocs
# mkdocstrings
colorama==0.4.6
# via
# griffe
# mkdocs-material
ghp-import==2.1.0
# via mkdocs
griffe==1.5.1
# via mkdocstrings-python
idna==3.10
# via requests
jinja2==3.1.4
# via
# mkdocs
# mkdocs-material
# mkdocstrings
markdown==3.7
# via
# mkdocs
# mkdocs-autorefs
# mkdocs-material
# mkdocstrings
# pymdown-extensions
markupsafe==3.0.2
# via
# jinja2
# mkdocs
# mkdocs-autorefs
# mkdocstrings
mergedeep==1.3.4
# via
# mkdocs
# mkdocs-get-deps
mkdocs==1.6.1
# via
# -r docs/requirements.in
# mkdocs-autorefs
# mkdocs-include-markdown-plugin
# mkdocs-material
# mkdocstrings
mkdocs-autorefs==1.2.0
# via
# mkdocstrings
# mkdocstrings-python
mkdocs-get-deps==0.2.0
# via mkdocs
mkdocs-include-markdown-plugin==7.1.2
# via -r docs/requirements.in
mkdocs-material==9.5.47
# via -r docs/requirements.in
mkdocs-material-extensions==1.3.1
# via mkdocs-material
mkdocstrings==0.27.0
# via
# -r docs/requirements.in
# mkdocstrings-python
mkdocstrings-python==1.12.2
# via mkdocstrings
packaging==24.2
# via mkdocs
paginate==0.5.7
# via mkdocs-material
pathspec==0.12.1
# via mkdocs
platformdirs==4.3.6
# via
# mkdocs-get-deps
# mkdocstrings
pygments==2.18.0
# via mkdocs-material
pymdown-extensions==10.12
# via
# mkdocs-material
# mkdocstrings
python-dateutil==2.9.0.post0
# via ghp-import
pyyaml==6.0.2
# via
# mkdocs
# mkdocs-get-deps
# pymdown-extensions
# pyyaml-env-tag
pyyaml-env-tag==0.1
# via mkdocs
regex==2024.11.6
# via mkdocs-material
requests==2.32.3
# via mkdocs-material
six==1.17.0
# via python-dateutil
urllib3==2.2.3
# via requests
watchdog==6.0.0
# via mkdocs
wcmatch==10.0
# via mkdocs-include-markdown-plugin
Loading

0 comments on commit cdac623

Please sign in to comment.