Skip to content

Commit

Permalink
Merge pull request #286 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 8, 2024
2 parents aac8328 + 119374c commit be283b6
Show file tree
Hide file tree
Showing 4 changed files with 666 additions and 51 deletions.
97 changes: 51 additions & 46 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,18 @@ jobs:
steps:
- name: Checkout Source
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:
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-dependency-glob: |
**/pyproject.toml

- name: Test
env:
GPGI_PY_LIB: ${{ matrix.marker == 'PY_LIB' }}
shell: bash # for windows-compat (using `\` as a line continuation)
# TODO: add --no-editable
run: |
uv sync --only-group test --only-group covcheck --no-build ${{ matrix.install-args }}
uv run ${{ matrix.install-args }} \
uv run --frozen --group covcheck ${{ matrix.install-args }} \
coverage run --parallel-mode -m pytest --color=yes -ra
- name: Upload coverage data
Expand All @@ -100,14 +95,11 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4.2.0
with:
python-version: '3.13'
enable-cache: true
cache-dependency-glob: |
**/pyproject.toml
- run: uv python install 3.13
- name: Run Image Tests
run: |
uv sync --only-group test --no-build
uv run \
uv run --frozen --no-editable --group test \
pytest --color=yes --mpl -m mpl_image_compare \
--mpl-generate-summary=html \
--mpl-results-path=gpgi_pytest_mpl_results \
Expand All @@ -116,8 +108,7 @@ jobs:
- name: Generate new image baseline
if: failure()
run: |
uv sync --only-group test --no-build
uv run \
uv run --frozen --no-editable --group test \
pytest --color=yes --mpl -m mpl_image_compare \
--mpl-generate-path=gpgi_pytest_mpl_new_baseline \
--last-failed
Expand Down Expand Up @@ -147,14 +138,11 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4.2.0
with:
python-version: '3.13'
enable-cache: true
cache-dependency-glob: |
**/pyproject.toml
- run: uv python install 3.13
- name: Run Concurrency Tests
run: |
uv sync --only-group test --only-group concurrency --no-build
uv run \
uv run --frozen --no-editable --group concurrency \
pytest --color=yes --count 500 tests/test_concurrent.py
coverage:
Expand All @@ -165,7 +153,8 @@ jobs:
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4.2.0
- run: uv python install 3.13
with:
python-version: '3.13'

- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
Expand Down Expand Up @@ -203,50 +192,66 @@ jobs:

- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4.2.0
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-dependency-glob: |
**/pyproject.toml

- run: uv python install ${{ matrix.python-version }}
- name: Typecheck
run: |
uv sync --only-group typecheck --no-build
uv run mypy src/gpgi
uv run --frozen --no-editable --group typecheck mypy src/gpgi
future:
name: free-threading Python 3.13
name: py${{ matrix.python-version }}
runs-on: ubuntu-latest
timeout-minutes: 20

strategy:
fail-fast: false
matrix:
python-version:
#- 3.14-dev
- 3.13t

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: deadsnakes/action@e640ac8743173a67cca4d7d77cd837e514bf98e8 # v3.2.0
with:
python-version: 3.13
nogil: true

# TODO: ditch Quansight-Labs/setup-python when either condition is met
# - setup-uv support Python pre-releases
# - actions/setup-python support free-threaded versions
# see https://github.com/actions/setup-python/issues/771
- uses: Quansight-Labs/setup-python@b9ab292c751a42bcd2bb465b7fa202ea2c3f5796 # v5.3.1
with:
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4.2.0
- name: Configure uv
run: |
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: Set PYTHON_GIL
if: ${{ endswith( matrix.python-version , 't' ) }}
run: |
echo "PYTHON_GIL=0" >> $GITHUB_ENV
echo
- name: Build
# not using uv here because it doesn't currently (0.2.33) detect python3.13t as
# the active interpreter, and may instead see 3.10, which is not supported in gpgi
run: |
python -m pip install -U pip
python -m pip install --pre setuptools wheel
python -m pip install --pre numpy Cython \
--only-binary ':all:' \
--extra-index-url \
https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
python -m pip install . --no-build-isolation --no-deps
uv venv
uv lock --upgrade --prerelease=allow --no-build
uv pip install setuptools numpy Cython
uv pip install --no-build-isolation --no-deps .
- name: Install minimal test env
run: python -m pip install --pre pytest pytest-repeat
- run: uv pip list

- run: python -m pip list
- name: Unit Tests
run: |
uv run --no-editable --group test pytest --color=yes -ra
- name: Tests
- name: Concurrency tests
run: |
pytest --color=yes
pytest --color=yes --count 500 tests/test_concurrent.py
uv run --no-editable --group concurrency \
pytest --color=yes -ra --count 500 tests/test_concurrent.py
create-issue:
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ exclude src/gpgi/_lib.py
recursive-exclude tests *
exclude .pre-commit-config.yaml
exclude _typos.toml
exclude uv.lock
12 changes: 7 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,19 @@ Homepage = "https://github.com/neutrinoceros/gpgi"
Changelog = "https://github.com/neutrinoceros/gpgi/blob/main/CHANGELOG.md"

[dependency-groups]
test = [
"matplotlib>=3.6.0",
"pytest-mpl>=0.16.1",
"pytest>=7.0.0",
]
covcheck = [
{include-group = "test"},
"coverage>=7.6.1",
]
concurrency = [
{include-group = "test"},
"pytest-repeat>=0.9.3",
]
test = [
"matplotlib>=3.6.0",
"pytest-mpl>=0.16.1",
"pytest>=7.0.0",
]
typecheck = [
"mypy>=1.13.0",
]
Expand Down
Loading

0 comments on commit be283b6

Please sign in to comment.