Skip to content

Commit 22b177c

Browse files
authored
Fix test coverage (zarr-developers#3334)
* Fix test coverage * Run GPU tests in GPU CI
1 parent 1858af1 commit 22b177c

File tree

2 files changed

+28
-42
lines changed

2 files changed

+28
-42
lines changed

.github/workflows/gpu_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
hatch env run -e gputest.py${{ matrix.python-version }}-${{ matrix.numpy-version }}-${{ matrix.dependency-set }} list-env
6464
- name: Run Tests
6565
run: |
66-
hatch env run --env gputest.py${{ matrix.python-version }}-${{ matrix.numpy-version }}-${{ matrix.dependency-set }} run-coverage
66+
hatch env run --env gputest.py${{ matrix.python-version }}-${{ matrix.numpy-version }}-${{ matrix.dependency-set }} run-coverage-gpu
6767
6868
- name: Upload coverage
6969
uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3 # v5.3.1

pyproject.toml

Lines changed: 27 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@ dependencies = [
150150
]
151151
features = ["test"]
152152

153+
[tool.hatch.envs.test.env-vars]
154+
# Required to test with a pytest plugin; see https://pytest-cov.readthedocs.io/en/latest/plugins.html
155+
COV_CORE_SOURCE = "src"
156+
COV_CORE_CONFIG = ".coveragerc"
157+
COV_CORE_DATAFILE = ".coverage.eager"
158+
153159
[[tool.hatch.envs.test.matrix]]
154160
python = ["3.11", "3.12", "3.13"]
155161
numpy = ["1.26", "2.2"]
@@ -161,25 +167,18 @@ matrix.deps.dependencies = [
161167
]
162168

163169
[tool.hatch.envs.test.scripts]
164-
run-coverage = "pytest --cov-config=pyproject.toml --cov=pkg --cov-report xml --cov=src --junitxml=junit.xml -o junit_family=legacy"
165-
run-coverage-html = "pytest --cov-config=pyproject.toml --cov=pkg --cov-report html --cov=src"
170+
run-coverage = "pytest --cov-config=pyproject.toml --cov=src --cov-append --cov-report xml --junitxml=junit.xml -o junit_family=legacy"
171+
run-coverage-html = "pytest --cov-config=pyproject.toml --cov=src --cov-append --cov-report html"
172+
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"
166173
run = "run-coverage --no-cov"
167174
run-pytest = "run"
168175
run-verbose = "run-coverage --verbose"
169176
run-mypy = "mypy src"
170177
run-hypothesis = "run-coverage -nauto --run-slow-hypothesis tests/test_properties.py tests/test_store/test_stateful*"
171178
list-env = "pip list"
172179

173-
[tool.hatch.envs.doctest]
174-
features = ["test", "optional", "remote", "remote_tests"]
175-
description = "Test environment for doctests"
176-
177-
[tool.hatch.envs.doctest.scripts]
178-
run = "rm -r data/; pytest docs/user-guide --doctest-glob='*.rst'"
179-
fix = "rm -r data/; pytest docs/user-guide --doctest-glob='*.rst' --accept"
180-
list-env = "pip list"
181-
182180
[tool.hatch.envs.gputest]
181+
template = "test"
183182
dependencies = [
184183
"numpy~={matrix:numpy}",
185184
"universal_pathlib",
@@ -191,22 +190,8 @@ python = ["3.11", "3.12", "3.13"]
191190
numpy = ["1.26", "2.2"]
192191
version = ["minimal"]
193192

194-
[tool.hatch.envs.gputest.scripts]
195-
run-coverage = "pytest -m gpu --cov-config=pyproject.toml --cov=pkg --cov-report xml --cov=src --junitxml=junit.xml -o junit_family=legacy"
196-
run = "run-coverage --no-cov"
197-
run-verbose = "run-coverage --verbose"
198-
run-mypy = "mypy src"
199-
run-hypothesis = "run-coverage --hypothesis-profile ci --run-slow-hypothesis tests/test_properties.py tests/test_store/test_stateful*"
200-
list-env = "pip list"
201-
202-
[tool.hatch.envs.docs]
203-
features = ['docs']
204-
205-
[tool.hatch.envs.docs.scripts]
206-
build = "cd docs && make html"
207-
serve = "sphinx-autobuild docs docs/_build --host 0.0.0.0"
208-
209193
[tool.hatch.envs.upstream]
194+
template = 'test'
210195
python = "3.13"
211196
dependencies = [
212197
'packaging @ git+https://github.com/pypa/packaging',
@@ -226,20 +211,12 @@ PIP_INDEX_URL = "https://pypi.anaconda.org/scientific-python-nightly-wheels/simp
226211
PIP_EXTRA_INDEX_URL = "https://pypi.org/simple/"
227212
PIP_PRE = "1"
228213

229-
[tool.hatch.envs.upstream.scripts]
230-
run = "pytest --verbose"
231-
run-mypy = "mypy src"
232-
run-hypothesis = "pytest --hypothesis-profile ci tests/test_properties.py tests/test_store/test_stateful*"
233-
run-coverage = "pytest --cov-config=pyproject.toml --cov=pkg --cov-report xml --cov=src --junitxml=junit.xml -o junit_family=legacy"
234-
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"
235-
run-coverage-html = "pytest --cov-config=pyproject.toml --cov=pkg --cov-report html --cov=src"
236-
list-env = "pip list"
237-
238214
[tool.hatch.envs.min_deps]
239215
description = """Test environment for minimum supported dependencies
240216
241217
See Spec 0000 for details and drop schedule: https://scientific-python.org/specs/spec-0000/
242218
"""
219+
template = "test"
243220
python = "3.11"
244221
dependencies = [
245222
'zarr[remote]',
@@ -257,13 +234,22 @@ dependencies = [
257234
'zarr[remote_tests]',
258235
]
259236

260-
[tool.hatch.envs.min_deps.scripts]
261-
run = "pytest --verbose"
262-
run-hypothesis = "pytest --hypothesis-profile ci tests/test_properties.py tests/test_store/test_stateful*"
237+
238+
[tool.hatch.envs.doctest]
239+
features = ["test", "optional", "remote", "remote_tests"]
240+
description = "Test environment for doctests"
241+
242+
[tool.hatch.envs.doctest.scripts]
243+
run = "rm -r data/; pytest docs/user-guide --doctest-glob='*.rst'"
244+
fix = "rm -r data/; pytest docs/user-guide --doctest-glob='*.rst' --accept"
263245
list-env = "pip list"
264-
run-coverage = "pytest --cov-config=pyproject.toml --cov=pkg --cov-report xml --cov=src --junitxml=junit.xml -o junit_family=legacy"
265-
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"
266-
run-coverage-html = "pytest --cov-config=pyproject.toml --cov=pkg --cov-report html --cov=src"
246+
247+
[tool.hatch.envs.docs]
248+
features = ['docs']
249+
250+
[tool.hatch.envs.docs.scripts]
251+
build = "cd docs && make html"
252+
serve = "sphinx-autobuild docs docs/_build --host 0.0.0.0"
267253

268254
[tool.ruff]
269255
line-length = 100

0 commit comments

Comments
 (0)