Skip to content

Commit 8956fda

Browse files
authored
Merge pull request #2094 from codeflash-ai/test/coverage-infrastructure
test: set up coverage infrastructure in CI
2 parents 14ca2c8 + 0232d84 commit 8956fda

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 = 58
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
@@ -202,6 +202,44 @@ jobs:
202202
- name: Unit tests
203203
run: uv run pytest tests/
204204

205+
# ---------------------------------------------------------------------------
206+
# Coverage — single run on ubuntu/py3.13 to enforce the coverage floor.
207+
# ---------------------------------------------------------------------------
208+
coverage:
209+
needs: determine-changes
210+
if: needs.determine-changes.outputs.unit_tests == 'true'
211+
runs-on: ubuntu-latest
212+
env:
213+
PYTHONIOENCODING: utf-8
214+
steps:
215+
- uses: actions/checkout@v6
216+
with:
217+
fetch-depth: 1
218+
token: ${{ secrets.GITHUB_TOKEN }}
219+
220+
- name: Install uv
221+
uses: astral-sh/setup-uv@v8.0.0
222+
with:
223+
python-version: "3.13"
224+
enable-cache: true
225+
226+
- name: Install dependencies
227+
run: uv sync
228+
229+
- name: Run tests with coverage
230+
run: uv run pytest tests/ --ignore=tests/test_tracer.py --cov=codeflash --cov-report=xml:coverage.xml --cov-report=term-missing --cov-config=.coveragerc
231+
232+
- name: Check coverage floor
233+
run: uv run coverage report --fail-under=58
234+
235+
- name: Upload coverage report
236+
if: always()
237+
uses: actions/upload-artifact@v4
238+
with:
239+
name: coverage-report
240+
path: coverage.xml
241+
retention-days: 30
242+
205243
# ---------------------------------------------------------------------------
206244
# Mypy type checking
207245
# ---------------------------------------------------------------------------
@@ -559,6 +597,7 @@ jobs:
559597
needs:
560598
- check-linked-issue
561599
- unit-tests
600+
- coverage
562601
- type-check
563602
- prek
564603
- 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)