From 5fd282c0859ba65f2be704dd23de7639753219ad Mon Sep 17 00:00:00 2001 From: Chuck Daniels Date: Fri, 24 Jan 2025 16:16:11 -0500 Subject: [PATCH] Ignore conftest.py in code coverage In addition, make it easier for produce coverage report locally by adding pytest config options to pyproject.toml. This also produces consistent results between local runs and runs in CI, and adds a term-missing report for human readability, both for local runs as well as in CI, so it show up in the logs. Fixes #387 --- .coveragerc | 3 +++ .github/codecov.yml | 3 ++- .github/workflows/main.yml | 2 +- .github/workflows/min-deps.yml | 2 +- .github/workflows/upstream.yml | 2 +- docs/contributing.md | 4 ++-- pyproject.toml | 4 ++++ 7 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..e1dfd048 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,3 @@ +[run] +omit = + virtualizarr/tests/* diff --git a/.github/codecov.yml b/.github/codecov.yml index 70390a69..4fba1de2 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -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 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4037abea..2dcbc491 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 --cov-report=xml --verbose virtualizarr - name: Upload code coverage to Codecov uses: codecov/codecov-action@v3.1.4 diff --git a/.github/workflows/min-deps.yml b/.github/workflows/min-deps.yml index 1c3a598f..7565cb16 100644 --- a/.github/workflows/min-deps.yml +++ b/.github/workflows/min-deps.yml @@ -51,7 +51,7 @@ jobs: - name: Running Tests run: | - python -m pytest ./virtualizarr --cov=./ --cov-report=xml --verbose + python -m pytest --cov-report=xml --verbose virtualizarr - name: Upload code coverage to Codecov uses: codecov/codecov-action@v3.1.4 diff --git a/.github/workflows/upstream.yml b/.github/workflows/upstream.yml index e847cf62..910d7321 100644 --- a/.github/workflows/upstream.yml +++ b/.github/workflows/upstream.yml @@ -51,7 +51,7 @@ jobs: - name: Running Tests run: | - python -m pytest ./virtualizarr --cov=./ --cov-report=xml --verbose + python -m pytest --cov-report=xml --verbose virtualizarr - name: Upload code coverage to Codecov uses: codecov/codecov-action@v3.1.4 diff --git a/docs/contributing.md b/docs/contributing.md index 31526971..c2c5fdbd 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -12,10 +12,10 @@ 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 --run-network-tests ``` -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. +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. ## Contributing documentation diff --git a/pyproject.toml b/pyproject.toml index 912f58b6..323f883c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -149,6 +149,10 @@ line-ending = "auto" known-first-party = ["virtualizarr"] [tool.pytest.ini_options] +addopts = [ + "--cov=virtualizarr", + "--cov-report=term-missing", +] markers = [ "network: marks test requiring internet (select with '--run-network-tests')", ]