Skip to content

Commit

Permalink
TST: migrate to official astral-sh/setup-uv action
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Sep 7, 2024
1 parent 04d4029 commit f1c8642
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 96 deletions.
147 changes: 52 additions & 95 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,21 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true


jobs:

build-test:
runs-on: ubuntu-latest
steps:
- name: Checkout Source
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
- uses: astral-sh/setup-uv@v2
with:
python-version: 3.x
- uses: yezz123/setup-uv@v4
with:
uv-version: 0.2.33
uv-venv: .venv
- run: uv pip install check-manifest build
enable-cache: true
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Check build
run: |
python -m check_manifest
python -m build
uvx check-manifest
uv build
unit-tests:
name: ${{matrix.os}} x py${{matrix.python-version}} ${{matrix.marker}}
Expand All @@ -52,6 +46,7 @@ jobs:
- os: macos-latest
python-version: '3.12'
install-args: --no-build

- os: windows-latest
python-version: '3.12'
install-args: --no-build
Expand All @@ -60,8 +55,7 @@ jobs:
- marker: minimal
os: ubuntu-20.04
python-version: '3.11'
deps: minimal
install-args: --no-build
install-args: --no-build --resolution=lowest-direct

# test GPGI_PY_LIB
- marker: PY_LIB
Expand All @@ -72,7 +66,6 @@ jobs:
# add coverage for Python dev
- os: ubuntu-latest
python-version: 3.13-dev
install-args: # allow building dependencies for now

runs-on: ${{ matrix.os }}
steps:
Expand All @@ -82,31 +75,23 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- uses: yezz123/setup-uv@v4
- uses: astral-sh/setup-uv@v2
with:
uv-version: 0.2.33
uv-venv: .venv
enable-cache: true
github-token: ${{ secrets.GITHUB_TOKEN }}

- if: matrix.deps == 'minimal'
run: |
uv pip compile pyproject.toml --resolution=lowest-direct | uv pip install -r - --no-build
- run: echo $(pwd) # TODO: clean up (maybe use it on other archs first)
if: matrix.os == 'ubuntu-latest'

- name: Build library
- name: Test
env:
GPGI_PY_LIB: ${{ matrix.marker == 'PY_LIB' }}
# install in editable mode to allow coverage measurement
shell: bash # for windows-compat (using `\` as a line continuation)
# pinning [email protected] inline so it's up to date
# even with UV_RESOLUTION=lowest-direct
run: |
echo GPGI_PY_LIB=$GPGI_PY_LIB
uv pip install --editable . --no-build
- run: uv pip install --requirement requirements/tests.txt ${{matrix.install-args}}

- run: uv pip list

- name: Test
run: |
python -m coverage run --parallel-mode -m pytest --color=yes -ra
uvx --with-requirements=requirements/tests.txt ${{ matrix.install-args }} \
[email protected] run --parallel-mode -m pytest --color=yes -ra
- name: Upload coverage data
# only using reports from ubuntu because
Expand All @@ -124,34 +109,26 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x

- uses: yezz123/setup-uv@v4
- uses: astral-sh/setup-uv@v2
with:
uv-version: 0.2.33
uv-venv: .venv

- name: Build library
run: uv pip install . --only-binary numpy

- run: uv pip install --requirement requirements/tests.txt --no-build

enable-cache: true
github-token: ${{ secrets.GITHUB_TOKEN }}
- run: uv python install 3.12
- name: Run Image Tests
run: |
pytest --color=yes --mpl -m mpl_image_compare \
--mpl-generate-summary=html \
--mpl-results-path=gpgi_pytest_mpl_results \
--mpl-baseline-path=tests/pytest_mpl_baseline
uvx --with-requirements=requirements/tests.txt --no-build \
pytest --color=yes --mpl -m mpl_image_compare \
--mpl-generate-summary=html \
--mpl-results-path=gpgi_pytest_mpl_results \
--mpl-baseline-path=tests/pytest_mpl_baseline
- name: Generate new image baseline
if: failure()
run: |
pytest --color=yes --mpl -m mpl_image_compare \
--mpl-generate-path=gpgi_pytest_mpl_new_baseline \
--last-failed
uvx --with-requirements=requirements/tests.txt --no-build \
pytest --color=yes --mpl -m mpl_image_compare \
--mpl-generate-path=gpgi_pytest_mpl_new_baseline \
--last-failed
# always attempt to upload artifacts, even
# (and especially) in case of failure.
Expand All @@ -176,24 +153,15 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x

- uses: yezz123/setup-uv@v4
- uses: astral-sh/setup-uv@v2
with:
uv-version: 0.2.33
uv-venv: .venv

- name: Build library
run: uv pip install . --only-binary numpy

- run: uv pip install --requirement requirements/tests.txt --no-build

enable-cache: true
github-token: ${{ secrets.GITHUB_TOKEN }}
- run: uv python install 3.12
- name: Run Concurrency Tests
run: |
pytest --color=yes --count 500 tests/test_concurrent.py
uvx --with-requirements=requirements/tests.txt --no-build \
pytest --color=yes --count 500 tests/test_concurrent.py
coverage:
name: Combine & check coverage.
Expand All @@ -202,17 +170,11 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: astral-sh/setup-uv@v2
with:
# Use latest Python, so it understands all syntax.
python-version: 3.x

- uses: yezz123/setup-uv@v4
with:
uv-version: 0.2.33
uv-venv: .venv

- run: uv pip install coverage --no-build
enable-cache: true
github-token: ${{ secrets.GITHUB_TOKEN }}
- run: uv python install 3.12

- uses: actions/download-artifact@v4
with:
Expand All @@ -221,9 +183,11 @@ jobs:

- name: Check coverage
run: |
python -m coverage combine
python -m coverage html --skip-covered --skip-empty
python -m coverage report --fail-under=100
uv python install 3.12
uv tool install coverage
coverage combine
coverage html --skip-covered --skip-empty
coverage report --fail-under=100 # >> $GITHUB_STEP_SUMMARY
- name: Upload HTML report if check failed.
uses: actions/upload-artifact@v4
Expand All @@ -246,23 +210,16 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
- uses: astral-sh/setup-uv@v2
with:
python-version: ${{ matrix.python-version }}

- uses: yezz123/setup-uv@v4
with:
uv-version: 0.2.33
uv-venv: .venv

- name: Build
run: uv pip install --requirement requirements/typecheck.txt --no-build
enable-cache: true
github-token: ${{ secrets.GITHUB_TOKEN }}

- run: uv python install ${{ matrix.python-version }}
- name: Typecheck
run: |
uv pip freeze
mypy src/gpgi
uvx --with-requirements=requirements/typecheck.txt \
mypy src/gpgi
future:
Expand Down
3 changes: 2 additions & 1 deletion requirements/tests.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
coverage>=6.5
# using --editable install makes it drastically easier to combine coverage reports
--editable .
pytest>=7.0.0
pytest-mpl>=0.16.1
pytest-repeat>=0.9.3
Expand Down
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from importlib.metadata import version
from importlib.util import find_spec

import pytest
Expand Down Expand Up @@ -27,6 +28,7 @@ def pytest_runtest_setup(item):

def pytest_report_header(config, start_path):
return [
f"NumPy: {version('numpy')}",
f"{gpgi._IS_PY_LIB = }",
f"gpgi._lib loads from {find_spec('gpgi._lib').origin}",
]

0 comments on commit f1c8642

Please sign in to comment.