Skip to content

Commit ac3d0a3

Browse files
committed
ci: add Codecov integration for coverage reporting
- Add [tool.coverage.run] and [tool.coverage.report] to pyproject.toml - Modify test-critical job with OIDC permissions and codecov uploads - Upload both coverage.xml and junit.xml (test results) - Add codecov badge to README - Add junit.xml to .gitignore Uses OIDC authentication (no secrets needed), non-blocking uploads, and per-Python-version flags for coverage filtering.
1 parent ab56443 commit ac3d0a3

File tree

4 files changed

+59
-2
lines changed

4 files changed

+59
-2
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ jobs:
116116
name: Tests (Python ${{ matrix.python-version }})
117117
runs-on: ubuntu-latest
118118
timeout-minutes: 15
119+
permissions:
120+
contents: read
121+
id-token: write # Required for Codecov OIDC
119122
strategy:
120123
fail-fast: false
121124
matrix:
@@ -163,11 +166,35 @@ jobs:
163166
run: |
164167
uv sync --group dev
165168
166-
- name: Run critical tests
169+
- name: Run critical tests with coverage
167170
env:
168171
REDIS_URL: redis://localhost:6379
169172
run: |
170-
make test-critical
173+
uv run pytest tests/critical/ -m "not slow" \
174+
--cov=src/cachekit \
175+
--cov-report=xml \
176+
--cov-report=term \
177+
--junitxml=junit.xml \
178+
-o junit_family=legacy
179+
180+
- name: Upload coverage to Codecov
181+
if: ${{ !cancelled() }}
182+
uses: codecov/codecov-action@v5
183+
with:
184+
files: ./coverage.xml
185+
use_oidc: true
186+
fail_ci_if_error: false
187+
flags: python-${{ matrix.python-version }}
188+
189+
- name: Upload test results to Codecov
190+
if: ${{ !cancelled() }}
191+
uses: codecov/codecov-action@v5
192+
with:
193+
files: ./junit.xml
194+
report_type: test_results
195+
use_oidc: true
196+
flags: python-${{ matrix.python-version }}
197+
fail_ci_if_error: false
171198

172199
# Markdown documentation tests
173200
test-docs:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ htmlcov/
4444
nosetests.xml
4545
coverage-rust-html/
4646
coverage.xml
47+
junit.xml
4748
*.coveragerc
4849

4950
# IDEs

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Production-ready Redis caching for Python with intelligent reliability features
88

99
[![PyPI Version][pypi-badge]][pypi-url]
1010
[![Python Versions][python-badge]][pypi-url]
11+
[![codecov][codecov-badge]][codecov-url]
1112
[![License: MIT][license-badge]][license-url]
1213

1314
</div>
@@ -382,3 +383,5 @@ MIT License - see [LICENSE][license-file-url] for details.
382383
[license-file-url]: LICENSE
383384
[github-url]: https://github.com/cachekit-io/cachekit-py
384385
[issues-url]: https://github.com/cachekit-io/cachekit-py/issues
386+
[codecov-badge]: https://codecov.io/github/cachekit-io/cachekit-py/graph/badge.svg
387+
[codecov-url]: https://codecov.io/github/cachekit-io/cachekit-py

pyproject.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,32 @@ doctest_optionflags = [
167167
"ELLIPSIS",
168168
]
169169

170+
# Coverage configuration
171+
[tool.coverage.run]
172+
source = ["src/cachekit"]
173+
branch = true
174+
omit = [
175+
"*/tests/*",
176+
"*/__pycache__/*",
177+
"*/.venv/*",
178+
]
179+
180+
[tool.coverage.report]
181+
precision = 2
182+
show_missing = true
183+
skip_covered = false
184+
exclude_lines = [
185+
"pragma: no cover",
186+
"def __repr__",
187+
"raise AssertionError",
188+
"raise NotImplementedError",
189+
"if __name__ == .__main__.:",
190+
"if TYPE_CHECKING:",
191+
"@abstractmethod",
192+
"@overload",
193+
"class .*\\bProtocol\\b.*:",
194+
]
195+
170196
[dependency-groups]
171197
dev = [
172198
# Testing

0 commit comments

Comments
 (0)