Skip to content

Commit

Permalink
Ignore conftest.py in code coverage (zarr-developers#388)
Browse files Browse the repository at this point in the history
* Ignore conftest.py in code coverage

* Configure coverage in pyproject.toml

* Do not run pytest coverage by default
  • Loading branch information
chuckwondo authored Jan 28, 2025
1 parent e8ade46 commit 443928f
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ coverage:
project:
default:
target: 75
threshold: 0.1
# See https://json.schemastore.org/codecov.json
threshold: "0.1%"
patch:
default:
target: 75
Expand All @@ -14,4 +15,5 @@ comment:
branches: # branch names that can post comment
- "main"
ignore:
- "conftest.py"
- "virtualizarr/tests" # ignore folders and all its contents
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Running Tests
run: |
python -m pytest ./virtualizarr --run-network-tests --cov=./ --cov-report=xml --verbose
python -m pytest --run-network-tests --verbose --cov=virtualizarr --cov-report=xml
- name: Upload code coverage to Codecov
uses: codecov/codecov-action@v3.1.4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/min-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Running Tests
run: |
python -m pytest ./virtualizarr --cov=./ --cov-report=xml --verbose
python -m pytest --verbose --cov=virtualizarr --cov-report=xml
- name: Upload code coverage to Codecov
uses: codecov/codecov-action@v3.1.4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Running Tests
run: |
python -m pytest ./virtualizarr --cov=./ --cov-report=xml --verbose
python -m pytest --verbose --cov=virtualizarr --cov-report=xml
- name: Upload code coverage to Codecov
uses: codecov/codecov-action@v3.1.4
Expand Down
2 changes: 1 addition & 1 deletion ci/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies:
- hdf5plugin
- numcodecs
# Testing
- codecov
- codecov[toml]
- pre-commit
- mypy
- ruff
Expand Down
2 changes: 1 addition & 1 deletion ci/min-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
- ujson
- universal_pathlib
# Testing
- codecov
- codecov[toml]
- pre-commit
- mypy
- ruff
Expand Down
2 changes: 1 addition & 1 deletion ci/upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies:
- numcodecs
- imagecodecs>=2024.6.1
# Testing
- codecov
- codecov[toml]
- pre-commit
- mypy
- ruff
Expand Down
24 changes: 22 additions & 2 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,30 @@ mamba activate virtualizarr-tests
pre-commit install
# git checkout -b new-feature
python -m pip install -e . --no-deps
python -m pytest ./virtualizarr --run-network-tests --cov=./ --cov-report=xml --verbose
python -m pytest
```

The `--run-network-tests` argument is optional - it will run additional tests that require downloading files over the network. Skip this if you want the tests to run faster or you have no internet access.
You may also add the `--run-network-tests` option, which will run additional tests
that require downloading files over the network. Skip this if you want the tests to run
faster or you have no internet access:

```bash
python -m pytest --run-network-tests
```

Further, the `pytest-cov` plugin is a test dependency, so you can generate a test
coverage report locally, if you wish (CI will automatically do so). Here are some
examples:

```bash
python -m pytest --cov=. # Terminal (text) report (--cov=term)
python -m pytest --cov=. --cov=term-missing # Terminal report showing missing coverage
python -m pytest --cov=. --cov=html # HTML report written to htmlcov/index.html
```

To see all available `pytest` options added by the `pytest-cov` plugin, run
`python -m pytest -h`, or see the
[pytest-cov documentation](https://pytest-cov.readthedocs.io/en/latest/readme.html).

## Contributing documentation

Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ line-ending = "auto"
[tool.ruff.lint.isort]
known-first-party = ["virtualizarr"]

[tool.coverage.run]
include = ["virtualizarr/"]
omit = ["conftest.py", "virtualizarr/tests/*"]

[tool.pytest.ini_options]
# See https://pytest-asyncio.readthedocs.io/en/latest/concepts.html#asyncio-event-loops
# Explicitly set asyncio_default_fixture_loop_scope to eliminate the following warning:
Expand Down

0 comments on commit 443928f

Please sign in to comment.