Skip to content

Commit d261c4a

Browse files
committed
fix: scope Codecov report to product code, excluding test files
CI runs `pytest --cov=sagemaker` per sub-package and uploads to Codecov, but coverage is not scoped to `src/` product code. Executed test-support scripts (notably `*/tests/data/*.py` training entry-scripts and model definitions) get recorded and uploaded. With no `codecov.yml` ignore list, these dominate the report: recent commits on master show ~98% of the measured files/lines are test files rather than product code (e.g. commit 3f810c6: 285 of 290 reported files are under tests/). This inflates the reported project coverage (~88-90%) far above the true product-code coverage and makes the number unreliable and unstable across commits. Add a repo-root `codecov.yml` that scopes the report to product code via an `ignore:` list (tests, conftest, test-data scripts, codegen and workflow_helper utilities), and defines project/patch status targets and `after_n_builds: 4` so the percentage is computed over all four sub-package uploads. Validated with the Codecov config validator. This follows how peer projects configure Codecov (scikit-learn ignores conftest/externals; aws-cdk ignores non-product paths).
1 parent 3f810c6 commit d261c4a

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

‎codecov.yml‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Codecov configuration for the sagemaker-python-sdk (v3) monorepo.
2+
# https://docs.codecov.com/docs/codecovyml-reference
3+
#
4+
# Why this file exists:
5+
# CI runs `pytest --cov=sagemaker` per sub-package and uploads to Codecov. Because
6+
# coverage is not scoped to the `src/` product code, executed test-support scripts
7+
# (notably `*/tests/data/*.py` training entry-scripts and model definitions) are
8+
# recorded and uploaded. With no ignore list these dominated the report — recent
9+
# commits show ~98% of the measured files/lines were test files, not product code,
10+
# which inflates the reported coverage and makes the number meaningless.
11+
#
12+
# The `ignore:` list below scopes the Codecov report to product code only, matching
13+
# how peer projects configure Codecov (e.g. scikit-learn ignores conftest/externals;
14+
# aws-cdk ignores non-product paths).
15+
16+
codecov:
17+
# Wait for all four sub-package unit-test jobs to upload before finalizing, so the
18+
# project % is computed over the complete report rather than whichever job lands first.
19+
notify:
20+
after_n_builds: 4
21+
wait_for_ci: true
22+
23+
coverage:
24+
status:
25+
project:
26+
default:
27+
# Do not let overall product coverage regress.
28+
target: auto
29+
threshold: 1%
30+
patch:
31+
default:
32+
# New/changed product lines should be reasonably covered.
33+
target: 80%
34+
threshold: 1%
35+
36+
comment:
37+
layout: "header, diff, flags, components"
38+
require_changes: true
39+
40+
# Paths excluded from coverage measurement/reporting. These are test code, test
41+
# fixtures/data scripts, and build/codegen helpers — not shippable product code.
42+
ignore:
43+
- "**/tests/**"
44+
- "**/test_*.py"
45+
- "**/conftest.py"
46+
- "sagemaker-*/test_script.py"
47+
- "**/workflow_helper/**"
48+
- "**/tools/*_codegen.py"
49+
- "**/setup.py"
50+
- "docs/**"
51+
- "v3-examples/**"

0 commit comments

Comments
 (0)