From 34a0d1e12f605f1be3b90625e595e1c78db1a8a3 Mon Sep 17 00:00:00 2001 From: Gemma Danks <8269577+gemmadanks@users.noreply.github.com> Date: Thu, 9 Oct 2025 21:27:07 +0100 Subject: [PATCH 1/3] feat: add codecov CI workflow uploads test coverage report to codecov. --- .github/workflows/ci.yaml | 5 ++++- pyproject.toml | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cea9631..d3bd061 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -71,7 +71,10 @@ jobs: run: poetry install --no-interaction --with dev - name: Run tests (full suite) - run: poetry run pytest --cov --cov-report=term-missing + run: poetry run pytest --cov --cov-branch --cov-report=xml + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v5 docs: name: Build docs (mkdocs) diff --git a/pyproject.toml b/pyproject.toml index 8432453..cb7e8a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,10 +19,10 @@ dependencies = [ [dependency-groups] dev = [ "pytest (>=8.4.2,<9.0.0)", - "pytest-cov (>=7.0.0,<8.0.0)", "ruff (>=0.13.1,<0.15.0)", "pre-commit (>=4.3.0,<5.0.0)", - "pyright (>=1.1.406,<2.0.0)" + "pyright (>=1.1.406,<2.0.0)", + "pytest-cov (>=7.0.0,<8.0.0)" ] docs = [ "mkdocs", From 55c4b8470251102c2e45490f4aa580ceffa7dd6b Mon Sep 17 00:00:00 2001 From: Gemma Danks <8269577+gemmadanks@users.noreply.github.com> Date: Thu, 9 Oct 2025 21:35:55 +0100 Subject: [PATCH 2/3] chore: exclude tests and conftest.py from coverage --- pyproject.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index cb7e8a1..8dda695 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,6 +30,12 @@ docs = [ "mkdocs-material" ] +[tool.coverage.run] +source = ["package_name"] +omit = [ + "tests/*", + "conftest.py" +] [build-system] requires = ["poetry-core>=2.0.0,<3.0.0"] From 44c0763c0ead2686f86893a8525ab47ee252c061 Mon Sep 17 00:00:00 2001 From: Gemma Danks <8269577+gemmadanks@users.noreply.github.com> Date: Thu, 9 Oct 2025 21:42:54 +0100 Subject: [PATCH 3/3] feat: add badge for codecov --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ad15011..74e5147 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Python Project Template ![Python Version from PEP 621 TOML](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Fgemmadanks%2Fpython-project-template%2Frefs%2Fheads%2Fmain%2Fpyproject.toml) +[![codecov](https://codecov.io/gh/gemmadanks/python-project-template/graph/badge.svg?token=SJVFI32RHC)](https://codecov.io/gh/gemmadanks/python-project-template) [![CI](https://github.com/gemmadanks/python-project-template/actions/workflows/ci.yaml/badge.svg?branch=main)](.github/workflows/ci.yaml) [![release-please](https://github.com/gemmadanks/python-project-template/actions/workflows/release-please.yaml/badge.svg)](release-please-config.json) [![Docs (GitHub Pages)](https://github.com/gemmadanks/python-project-template/actions/workflows/docs-pages.yaml/badge.svg)](https://github.com/gemmadanks/python-project-template/actions/workflows/docs-pages.yaml) @@ -10,7 +11,7 @@ [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white)](https://conventionalcommits.org) [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) -A minimal, opinionated template for modern Python projects -- featuring Poetry packaging, Ruff for linting and formatting, pytest testing, MkDocs documentation with configuration for Read The Docs, pre-commit hooks, GitHub Actions CI, GitHub issue and pull request templates and automated semantic releases. +A minimal, opinionated template for modern Python projects -- featuring Poetry packaging, Ruff for linting and formatting, pytest testing with code coverage upload to codecov, MkDocs documentation with configuration for Read The Docs, pre-commit hooks, GitHub Actions CI, GitHub issue and pull request templates and automated semantic releases. The goal is to help you start writing code immediately without having to spend time deciding what tools or conventions to use.