Skip to content

Commit ac9d7aa

Browse files
ogabrielluizAdam-Aghili
authored andcommitted
ci(lfx): add coverage generation and Codecov reporting (#10266)
* chore: update dependency markers and add pytest-cov for coverage reporting - Refined dependency markers for several packages to improve compatibility with Python 3.12 and specific platforms. - Added pytest-cov to development dependencies for enhanced test coverage reporting. - Updated dependencies for pyobjc frameworks to include platform-specific markers for better compatibility. * chore: enhance lfx_tests command with coverage reporting - Updated the lfx_tests target in the Makefile to include coverage reporting options for pytest. - Added coverage metrics output in XML, HTML, and terminal formats to improve test visibility and analysis. * chore: update codecov configuration for LFX coverage tracking - Added LFX coverage target and threshold to the codecov.yml file. - Defined separate coverage flags for frontend, backend, and LFX components. - Updated ignore patterns to exclude LFX test and component directories from coverage reports. * chore: add coverage upload steps to Python CI workflow - Implemented steps to upload coverage reports to Codecov for Python 3.10. - Added artifact upload for coverage reports, retaining them for 30 days. * chore: update LFX coverage target in codecov configuration - Increased the LFX coverage target from 40% to 60% to encourage aspirational improvement. - Clarified the allowable drop in coverage threshold from 44% to 39% without failing the status check. * chore: update coverage configuration in pyproject.toml - Enabled branch coverage in the coverage run configuration. - Fixed a typo in the main module check to ensure proper execution.
1 parent 6851ed8 commit ac9d7aa

File tree

5 files changed

+80
-19
lines changed

5 files changed

+80
-19
lines changed

.github/workflows/python_test.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,27 @@ jobs:
168168
env:
169169
DO_NOT_TRACK: true # disable telemetry reporting
170170

171+
- name: Upload coverage to Codecov
172+
uses: codecov/codecov-action@v5
173+
if: matrix.python-version == '3.10'
174+
with:
175+
token: ${{ secrets.CODECOV_TOKEN }}
176+
files: ./src/lfx/coverage.xml
177+
flags: lfx
178+
name: lfx-coverage
179+
fail_ci_if_error: false
180+
directory: ./src/lfx/
181+
182+
- name: Upload coverage artifacts
183+
uses: actions/upload-artifact@v4
184+
if: matrix.python-version == '3.10'
185+
with:
186+
name: lfx-coverage-report
187+
path: |
188+
src/lfx/coverage.xml
189+
src/lfx/htmlcov/
190+
retention-days: 30
191+
171192
test-cli:
172193
name: Test CLI - Python ${{ matrix.python-version }}
173194
runs-on: ${{ (inputs['runs-on'] && startsWith(format('{0}', inputs['runs-on']), '[') && fromJSON(inputs['runs-on'])) || inputs['runs-on'] || github.event.inputs['runs-on'] || 'ubuntu-latest' }}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ lfx_tests: ## run lfx package unit tests
171171
@echo 'Running LFX Package Tests...'
172172
@cd src/lfx && \
173173
uv sync && \
174-
uv run pytest tests/unit -v $(args)
174+
uv run pytest tests/unit -v --cov=src/lfx --cov-report=xml --cov-report=html --cov-report=term-missing $(args)
175175

176176
integration_tests:
177177
uv run pytest src/backend/tests/integration \

codecov.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ coverage:
3636
flags:
3737
- frontend
3838

39+
# LFX coverage: Target for core package (excludes components)
40+
# Components (third-party integrations) tracked separately
41+
# Current core coverage: ~44%, Target: 60% (aspirational improvement)
42+
lfx:
43+
target: 60%
44+
# Threshold: Allowable drop in coverage before failing the check
45+
# 5% = coverage can drop from 44% to 39% without failing status
46+
threshold: 5%
47+
flags:
48+
- lfx
49+
3950
# New code coverage requirements - realistic target for current state
4051
# Encourages testing new features without blocking development
4152
patch:
@@ -51,7 +62,7 @@ comment:
5162
require_base: false # Don't require base branch comparison
5263
require_head: true # Require current branch coverage
5364

54-
# Define separate coverage tracking for frontend and backend
65+
# Define separate coverage tracking for frontend, backend, and lfx
5566
flags:
5667
backend:
5768
paths:
@@ -61,6 +72,10 @@ flags:
6172
paths:
6273
- src/frontend/
6374
carryforward: true # Preserve coverage data across builds if missing
75+
lfx:
76+
paths:
77+
- src/lfx/
78+
carryforward: true # Preserve coverage data across builds if missing
6479

6580
# Define coverage components for granular reporting
6681
component_management:
@@ -86,6 +101,7 @@ ignore:
86101
- "src/backend/tests/**"
87102
- "src/frontend/tests/**"
88103
- "src/frontend/test-results/**"
104+
- "src/lfx/tests/**"
89105
# Build artifacts and dependencies
90106
- "**/__pycache__/**"
91107
- "**/*.pyc"
@@ -94,4 +110,6 @@ ignore:
94110
# Python package init files - typically just imports
95111
- "**/__init__.py"
96112
# Database migrations
97-
- "**/migrations/**"
113+
- "**/migrations/**"
114+
# LFX components - third-party integrations tracked separately
115+
- "src/lfx/components/**"

src/lfx/pyproject.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,25 @@ dev = [
125125
"hypothesis>=6.136.3",
126126
"pytest>=8.4.1",
127127
"pytest-asyncio>=0.26.0",
128+
"pytest-cov>=7.0.0",
128129
"ruff>=0.9.10",
129130
]
131+
132+
[tool.coverage.run]
133+
branch = true
134+
omit = [
135+
"*/tests/*",
136+
"*/__init__.py",
137+
"*/components/*", # Third-party integrations tracked separately
138+
]
139+
140+
[tool.coverage.report]
141+
exclude_lines = [
142+
"pragma: no cover",
143+
"def __repr__",
144+
"raise AssertionError",
145+
"raise NotImplementedError",
146+
"if __name__ == '__main__':",
147+
"if TYPE_CHECKING:",
148+
"@abstractmethod",
149+
]

uv.lock

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

0 commit comments

Comments
 (0)