Skip to content

Add code coverage measurement with Codecov integration#837

Merged
vgvoleg merged 1 commit into
mainfrom
add-code-coverage
Jun 11, 2026
Merged

Add code coverage measurement with Codecov integration#837
vgvoleg merged 1 commit into
mainfrom
add-code-coverage

Conversation

@vgvoleg

@vgvoleg vgvoleg commented Jun 11, 2026

Copy link
Copy Markdown
Member

Summary

Introduces code coverage measurement for the ydb package and wires it to Codecov with a PR gate.

  • Measurement: pytest-cov (coverage.py) — branch coverage, source=ydb. Auto-generated _grpc/v3..v6 stubs and *_test.py files are excluded; the hand-written _grpc/grpcwrapper/* (topic reader/writer logic) stays measured.
  • tox: new cov env — tox -e cov -- ydb / tox -e cov -- tests, producing term/html/xml reports.
  • CI: dedicated coverage job (Python 3.12) that runs the unit and integration suites and uploads both to Codecov with unit / integration flags (Codecov merges them).
  • Gate (.github/codecov.yml): project coverage may not drop by more than 1%; new code in the diff (patch) must be ≥ 80% covered.
  • README: Codecov badge.

Baseline

Local combined run: unit + integration = 81% (605 passed, 18 pre-existing skips). Topic internals are well covered (reader/writer asyncio ~90%, grpcwrapper/ydb_topic.py 87%).

Note on COVERAGE_CORE=sysmon

The coverage job uses the PEP 669 sys.monitoring backend. The default C tracer's overhead breaks the timing-sensitive chaos tests (e.g. test_no_session_leak does acquire(timeout=0.5) then asserts pool state and only restarts YDB after the assert — under tracer slowdown the assert fails, YDB stays down, and the rest of the suite cascades). sysmon keeps overhead low so these pass. It requires Python 3.12+, which is why coverage is collected on a single 3.12 job rather than across the whole matrix.

Follow-up (after this PR runs green)

Add codecov/project and codecov/patch as required status checks in main branch protection to make the gate blocking.

🤖 Generated with Claude Code

@codecov-commenter

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

Measure coverage of the `ydb` package via pytest-cov and report it to
Codecov with separate unit/integration flags.

- pyproject.toml: coverage config (branch coverage, source=ydb), omitting
  the auto-generated _grpc/v3..v6 stubs, *_test.py files, and the legacy
  dbapi/sqlalchemy packages.
- tox.ini: new `cov` env producing term/html/xml reports.
- tests.yaml: dedicated `coverage` job (Python 3.12) running the unit and
  integration suites and uploading both to Codecov.
- .github/codecov.yml: PR gate — overall project coverage may not drop by
  more than 1%, and new code in the diff must be >= 80% covered.
- README: Codecov badge.

The coverage job sets COVERAGE_CORE=sysmon (PEP 669) so the low-overhead
tracer keeps the timing-sensitive chaos tests (which kill and restart
YDB) passing under instrumentation.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vgvoleg vgvoleg force-pushed the add-code-coverage branch from 681686e to 1ac6374 Compare June 11, 2026 07:25
@vgvoleg vgvoleg merged commit f6e0a40 into main Jun 11, 2026
35 checks passed
@vgvoleg vgvoleg deleted the add-code-coverage branch June 11, 2026 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants