From a6f3326924adaffb55f766d8c92274c8240ef4ac Mon Sep 17 00:00:00 2001 From: David Stansby Date: Mon, 4 Aug 2025 16:43:34 +0100 Subject: [PATCH 1/2] Fix test coverage --- pyproject.toml | 68 ++++++++++++++++++++------------------------------ 1 file changed, 27 insertions(+), 41 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e36d636b0c..7bbf6cc2a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -150,6 +150,12 @@ dependencies = [ ] features = ["test"] +[tool.hatch.envs.test.env-vars] +# Required to test with a pytest plugin; see https://pytest-cov.readthedocs.io/en/latest/plugins.html +COV_CORE_SOURCE = "src" +COV_CORE_CONFIG = ".coveragerc" +COV_CORE_DATAFILE = ".coverage.eager" + [[tool.hatch.envs.test.matrix]] python = ["3.11", "3.12", "3.13"] numpy = ["1.26", "2.2"] @@ -161,8 +167,9 @@ matrix.deps.dependencies = [ ] [tool.hatch.envs.test.scripts] -run-coverage = "pytest --cov-config=pyproject.toml --cov=pkg --cov-report xml --cov=src --junitxml=junit.xml -o junit_family=legacy" -run-coverage-html = "pytest --cov-config=pyproject.toml --cov=pkg --cov-report html --cov=src" +run-coverage = "pytest --cov-config=pyproject.toml --cov=src --cov-append --cov-report xml --junitxml=junit.xml -o junit_family=legacy" +run-coverage-html = "pytest --cov-config=pyproject.toml --cov=src --cov-append --cov-report html" +run-coverage-gpu = "pip install cupy-cuda12x && pytest -m gpu --cov-config=pyproject.toml --cov=src --cov-append --cov-report xml --junitxml=junit.xml -o junit_family=legacy" run = "run-coverage --no-cov" run-pytest = "run" run-verbose = "run-coverage --verbose" @@ -170,16 +177,8 @@ run-mypy = "mypy src" run-hypothesis = "run-coverage -nauto --run-slow-hypothesis tests/test_properties.py tests/test_store/test_stateful*" list-env = "pip list" -[tool.hatch.envs.doctest] -features = ["test", "optional", "remote", "remote_tests"] -description = "Test environment for doctests" - -[tool.hatch.envs.doctest.scripts] -run = "rm -r data/; pytest docs/user-guide --doctest-glob='*.rst'" -fix = "rm -r data/; pytest docs/user-guide --doctest-glob='*.rst' --accept" -list-env = "pip list" - [tool.hatch.envs.gputest] +template = "test" dependencies = [ "numpy~={matrix:numpy}", "universal_pathlib", @@ -191,22 +190,8 @@ python = ["3.11", "3.12", "3.13"] numpy = ["1.26", "2.2"] version = ["minimal"] -[tool.hatch.envs.gputest.scripts] -run-coverage = "pytest -m gpu --cov-config=pyproject.toml --cov=pkg --cov-report xml --cov=src --junitxml=junit.xml -o junit_family=legacy" -run = "run-coverage --no-cov" -run-verbose = "run-coverage --verbose" -run-mypy = "mypy src" -run-hypothesis = "run-coverage --hypothesis-profile ci --run-slow-hypothesis tests/test_properties.py tests/test_store/test_stateful*" -list-env = "pip list" - -[tool.hatch.envs.docs] -features = ['docs'] - -[tool.hatch.envs.docs.scripts] -build = "cd docs && make html" -serve = "sphinx-autobuild docs docs/_build --host 0.0.0.0" - [tool.hatch.envs.upstream] +template = 'test' python = "3.13" dependencies = [ 'packaging @ git+https://github.com/pypa/packaging', @@ -226,20 +211,12 @@ PIP_INDEX_URL = "https://pypi.anaconda.org/scientific-python-nightly-wheels/simp PIP_EXTRA_INDEX_URL = "https://pypi.org/simple/" PIP_PRE = "1" -[tool.hatch.envs.upstream.scripts] -run = "pytest --verbose" -run-mypy = "mypy src" -run-hypothesis = "pytest --hypothesis-profile ci tests/test_properties.py tests/test_store/test_stateful*" -run-coverage = "pytest --cov-config=pyproject.toml --cov=pkg --cov-report xml --cov=src --junitxml=junit.xml -o junit_family=legacy" -run-coverage-gpu = "pip install cupy-cuda12x && pytest -m gpu --cov-config=pyproject.toml --cov=pkg --cov-report xml --cov=src --junitxml=junit.xml -o junit_family=legacy" -run-coverage-html = "pytest --cov-config=pyproject.toml --cov=pkg --cov-report html --cov=src" -list-env = "pip list" - [tool.hatch.envs.min_deps] description = """Test environment for minimum supported dependencies See Spec 0000 for details and drop schedule: https://scientific-python.org/specs/spec-0000/ """ +template = "test" python = "3.11" dependencies = [ 'zarr[remote]', @@ -257,13 +234,22 @@ dependencies = [ 'zarr[remote_tests]', ] -[tool.hatch.envs.min_deps.scripts] -run = "pytest --verbose" -run-hypothesis = "pytest --hypothesis-profile ci tests/test_properties.py tests/test_store/test_stateful*" + +[tool.hatch.envs.doctest] +features = ["test", "optional", "remote", "remote_tests"] +description = "Test environment for doctests" + +[tool.hatch.envs.doctest.scripts] +run = "rm -r data/; pytest docs/user-guide --doctest-glob='*.rst'" +fix = "rm -r data/; pytest docs/user-guide --doctest-glob='*.rst' --accept" list-env = "pip list" -run-coverage = "pytest --cov-config=pyproject.toml --cov=pkg --cov-report xml --cov=src --junitxml=junit.xml -o junit_family=legacy" -run-coverage-gpu = "pip install cupy-cuda12x && pytest -m gpu --cov-config=pyproject.toml --cov=pkg --cov-report xml --cov=src --junitxml=junit.xml -o junit_family=legacy" -run-coverage-html = "pytest --cov-config=pyproject.toml --cov=pkg --cov-report html --cov=src" + +[tool.hatch.envs.docs] +features = ['docs'] + +[tool.hatch.envs.docs.scripts] +build = "cd docs && make html" +serve = "sphinx-autobuild docs docs/_build --host 0.0.0.0" [tool.ruff] line-length = 100 From a609d061518f63c5c5e5cb51d7b1da13a36a3740 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Mon, 4 Aug 2025 16:58:43 +0100 Subject: [PATCH 2/2] Run GPU tests in GPU CI --- .github/workflows/gpu_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gpu_test.yml b/.github/workflows/gpu_test.yml index dd1d05db3d..133265f348 100644 --- a/.github/workflows/gpu_test.yml +++ b/.github/workflows/gpu_test.yml @@ -63,7 +63,7 @@ jobs: hatch env run -e gputest.py${{ matrix.python-version }}-${{ matrix.numpy-version }}-${{ matrix.dependency-set }} list-env - name: Run Tests run: | - hatch env run --env gputest.py${{ matrix.python-version }}-${{ matrix.numpy-version }}-${{ matrix.dependency-set }} run-coverage + hatch env run --env gputest.py${{ matrix.python-version }}-${{ matrix.numpy-version }}-${{ matrix.dependency-set }} run-coverage-gpu - name: Upload coverage uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3 # v5.3.1