Skip to content

Commit 2c79e50

Browse files
committed
test: set up coverage infrastructure in CI
- Add pytest-cov to dev dependencies - Add .coveragerc with branch coverage, 60% floor (current baseline), and source/omit configuration - Add coverage CI job (ubuntu/py3.13) that runs pytest with --cov, enforces the floor, and uploads coverage.xml as an artifact - Wire coverage into the required-checks-passed gate Closes #2080
1 parent 67cf123 commit 2c79e50

4 files changed

Lines changed: 85 additions & 0 deletions

File tree

.coveragerc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[run]
2+
branch = true
3+
source = codeflash
4+
omit =
5+
codeflash/version.py
6+
7+
[report]
8+
sort = cover
9+
show_missing = true
10+
fail_under = 60
11+
exclude_lines =
12+
pragma: no cover
13+
if TYPE_CHECKING:
14+
if __name__ == .__main__.:
15+
16+
[html]
17+
directory = htmlcov

.github/workflows/ci.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,44 @@ jobs:
151151
- name: Unit tests
152152
run: uv run pytest tests/
153153

154+
# ---------------------------------------------------------------------------
155+
# Coverage — single run on ubuntu/py3.13 to enforce the coverage floor.
156+
# ---------------------------------------------------------------------------
157+
coverage:
158+
needs: determine-changes
159+
if: needs.determine-changes.outputs.unit_tests == 'true'
160+
runs-on: ubuntu-latest
161+
env:
162+
PYTHONIOENCODING: utf-8
163+
steps:
164+
- uses: actions/checkout@v6
165+
with:
166+
fetch-depth: 1
167+
token: ${{ secrets.GITHUB_TOKEN }}
168+
169+
- name: Install uv
170+
uses: astral-sh/setup-uv@v8.0.0
171+
with:
172+
python-version: "3.13"
173+
enable-cache: true
174+
175+
- name: Install dependencies
176+
run: uv sync
177+
178+
- name: Run tests with coverage
179+
run: uv run pytest tests/ --cov=codeflash --cov-report=xml:coverage.xml --cov-report=term-missing --cov-config=.coveragerc
180+
181+
- name: Check coverage floor
182+
run: uv run coverage report --fail-under=60
183+
184+
- name: Upload coverage report
185+
if: always()
186+
uses: actions/upload-artifact@v4
187+
with:
188+
name: coverage-report
189+
path: coverage.xml
190+
retention-days: 30
191+
154192
# ---------------------------------------------------------------------------
155193
# Mypy type checking
156194
# ---------------------------------------------------------------------------
@@ -507,6 +545,7 @@ jobs:
507545
if: always()
508546
needs:
509547
- unit-tests
548+
- coverage
510549
- type-check
511550
- prek
512551
- e2e-python

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ dev = [
8989
"prek>=0.2.25",
9090
"ty>=0.0.14",
9191
"uv>=0.9.29",
92+
"pytest-cov>=7.1.0",
9293
]
9394
tests = [
9495
"black>=25.9.0",

uv.lock

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)