Skip to content

Commit d79faa2

Browse files
committed
ci: add pytest-cov and codecov integration for coverage tracking
Signed-off-by: Srihari <svenkata@redhat.com>
1 parent 8a0f23c commit d79faa2

4 files changed

Lines changed: 136 additions & 0 deletions

File tree

.codecov.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
codecov:
2+
require_ci_to_pass: true
3+
4+
coverage:
5+
precision: 2
6+
round: down
7+
range: "50...70"
8+
9+
status:
10+
project:
11+
default:
12+
informational: true
13+
target: auto
14+
threshold: 1%
15+
patch:
16+
default:
17+
informational: true
18+
target: 70%
19+
20+
comment:
21+
layout: "reach,diff,flags,files,footer"
22+
behavior: default
23+
require_changes: false
24+
require_base: false
25+
require_head: true
26+
show_carryforward_flags: true
27+
28+
flags:
29+
python-unit:
30+
paths:
31+
- sdk/python/feast/
32+
carryforward: true
33+
go-feature-server:
34+
paths:
35+
- go/
36+
carryforward: true
37+
38+
ignore:
39+
- "sdk/python/tests/**"
40+
- "**/*_pb2.py"
41+
- "**/*_pb2_grpc.py"
42+
- "sdk/python/feast/protos/**"
43+
- "sdk/python/feast/embedded_go/**"
44+
- "protos/**"
45+
- "docs/**"
46+
- "ui/**"
47+
- "java/**"
48+
- "infra/feast-operator/test/**"

.github/workflows/unit_tests.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,68 @@ jobs:
7979
fi
8080
8181
make test-python-unit
82+
- name: Upload Python coverage to Codecov
83+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
84+
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
85+
with:
86+
file: ./coverage.xml
87+
flags: python-unit
88+
fail_ci_if_error: false
89+
env:
90+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
8291
- name: Minimize uv cache
8392
run: uv cache prune --ci
8493

94+
unit-test-go:
95+
runs-on: ubuntu-latest
96+
steps:
97+
- uses: actions/checkout@v4
98+
- name: Setup Go
99+
uses: actions/setup-go@v5
100+
with:
101+
go-version-file: go.mod
102+
cache: true
103+
- name: Setup Python
104+
uses: actions/setup-python@v5
105+
with:
106+
python-version: "3.11"
107+
architecture: x64
108+
- name: Install the latest version of uv
109+
uses: astral-sh/setup-uv@v5
110+
with:
111+
enable-cache: true
112+
- name: Install system dependencies
113+
run: |
114+
sudo apt-get update
115+
sudo apt-get install -y make protobuf-compiler libsqlite3-dev
116+
- name: Install Go proto plugins
117+
run: |
118+
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
119+
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
120+
- name: Compile Go protobufs
121+
run: make compile-protos-go
122+
- name: Create virtual environment
123+
run: |
124+
uv venv
125+
echo "${{ github.workspace }}/.venv/bin" >> $GITHUB_PATH
126+
- name: Install feast locally
127+
run: make install-feast-locally
128+
- name: Run Go tests with coverage
129+
run: |
130+
CGO_ENABLED=1 go test \
131+
-coverprofile=go/coverage.out \
132+
-covermode=atomic \
133+
-skip "TestGetOnlineFeatures" \
134+
./go/...
135+
- name: Upload Go coverage to Codecov
136+
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
137+
with:
138+
file: ./go/coverage.out
139+
flags: go-feature-server
140+
fail_ci_if_error: false
141+
env:
142+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
143+
85144
unit-test-ui:
86145
runs-on: ubuntu-latest
87146
env:

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ benchmark-python-local: ## Run integration + benchmark tests for Python (local d
171171

172172
test-python-unit: ## Run Python unit tests (use pattern=<pattern> to filter tests, e.g., pattern=milvus, pattern=test_online_retrieval.py, pattern=test_online_retrieval.py::test_get_online_features_milvus)
173173
uv run python -m pytest -n 8 --color=yes $(if $(pattern),-k "$(pattern)") \
174+
--cov=feast \
175+
--cov-report=xml \
176+
--cov-report=term-missing \
174177
sdk/python/tests/unit
175178

176179
# Fast unit tests only

pyproject.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ dbt = ["dbt-artifacts-parser"]
143143
test = [
144144
"pytest>=6.0.0,<8",
145145
"pytest-xdist>=3.8.0",
146+
"pytest-cov>=5.0.0",
146147
"pytest-timeout==1.4.2",
147148
"pytest-lazy-fixture==0.6.3",
148149
"pytest-ordering~=0.6.0",
@@ -335,3 +336,28 @@ test-ci = { cmd = "python -m pytest -n auto --dist loadgroup --integration sdk/p
335336
duckdb-tests = ["py310", "duckdb-tests"]
336337
ray-tests = ["py310", "ray-tests"]
337338
registration-tests = ["py310", "registration-tests"]
339+
340+
[tool.coverage.run]
341+
branch = true
342+
source = ["feast"]
343+
omit = [
344+
"*/tests/*",
345+
"*/protos/*",
346+
"*_pb2.py",
347+
"*_pb2_grpc.py",
348+
"feast/embedded_go/*",
349+
]
350+
351+
[tool.coverage.report]
352+
show_missing = true
353+
skip_covered = false
354+
exclude_lines = [
355+
"pragma: no cover",
356+
"def __repr__",
357+
"raise NotImplementedError",
358+
"if TYPE_CHECKING:",
359+
"pass$",
360+
]
361+
362+
[tool.coverage.xml]
363+
output = "coverage.xml"

0 commit comments

Comments
 (0)