Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Configuration for Codecov: https://docs.codecov.com/docs/codecov-yaml
#
# Coverage reports are generated by `nox -s coverage-<python>` and
# uploaded in .github/workflows/ci.yml.

coverage:
status:
project:
default:
informational: true # report coverage without failing checks
patch:
default:
informational: true
Comment on lines +8 to +13

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll probably want to adjust these later so that checks fail if either the coverage goes down by a non-negligible amount, or if coverage falls below a floor value. That can lead to some erroneous failures, but is generally helpful.


comment:
layout: diff, flags, files
behavior: default
require_changes: true
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ jobs:
python: '3.13'
nox_session: tests-3.13

- name: Tests, Python 3.12
- name: Tests with code coverage, Python 3.12
os: ubuntu-latest
python: '3.12'
nox_session: tests-3.12
nox_session: coverage-3.12

- name: Tests, Python 3.11
os: macos-latest
Expand Down
20 changes: 20 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,26 @@ def tests(session: nox.Session) -> None:
session.run("pytest", *doctest_options, *session.posargs)


@nox_uv.session(uv_groups=["test"], python=SUPPORTED_PYTHON_VERSIONS)
def coverage(session: nox.Session) -> None:
"""
Run tests with pytest and measure code coverage.

The project is installed in editable mode (by ``uv sync``) so that
file paths in the coverage report point to ``src/``, which is
needed for the report uploaded to Codecov to map onto the source.

Configuration: ``[tool.coverage]`` in pyproject.toml
"""
session.run(
"pytest",
"--cov",
"--cov-report=xml",
"--cov-report=term",
*session.posargs,
)


if RUNNING_ON_RTD:
rtd_output_path = pathlib.Path(os.environ.get("READTHEDOCS_OUTPUT")) / "html" # ty: ignore[invalid-argument-type]
rtd_output_path.mkdir(parents=True, exist_ok=True)
Expand Down
13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
build-backend = "uv_build"
requires = [ "uv-build>=0.12.5,<0.13" ]
Expand Down Expand Up @@ -50,6 +50,7 @@
"cdflib",
"pytest",
"pytest-check>=2.9.1",
"pytest-cov",
"pytest-filter-subpackage",
"xarray>=2022.6,<2023.10; python_version<'3.11'",
"xarray>=2024.6; python_version>='3.11'",
Expand Down Expand Up @@ -284,3 +285,15 @@
]
strict = true
testpaths = [ "tests", "src/pyfaradaycup" ]

[tool.coverage] # https://coverage.readthedocs.io/en/latest/config.html
run.source_pkgs = [ "pyfaradaycup" ]
run.branch = true
paths.source = [ "src/pyfaradaycup", "*/site-packages/pyfaradaycup" ]
report.exclude_also = [
"@overload",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"raise NotImplementedError",
]
report.show_missing = true
Loading
Loading