Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
coverage:
status:
project:
default:
target: auto # do not drop below the current level...
threshold: 1% # ...by more than 1%
patch:
default:
target: 80% # new/changed code in the PR diff must be >= 80% covered

flags:
unit:
paths:
- ydb/
carryforward: true
integration:
paths:
- ydb/
carryforward: true

comment:
layout: "reach, diff, flags, files"
require_changes: false

# Auto-generated protobuf stubs and tests must not affect the metric.
# Already excluded from coverage.xml via [tool.coverage.run] omit, listed here for safety.
ignore:
- "ydb/_grpc/v3"
- "ydb/_grpc/v4"
- "ydb/_grpc/v5"
- "ydb/_grpc/v6"
- "ydb/dbapi" # legacy
- "ydb/sqlalchemy" # legacy
- "**/*_test.py"
- "tests"
- "examples"
- "docs"
- "benchmarks"
51 changes: 51 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,54 @@ jobs:

- name: Run unit tests
run: tox -e py -- ydb

coverage:
runs-on: ubuntu-latest

concurrency:
group: coverage-${{ github.ref }}
cancel-in-progress: true

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install tox
run: |
python -m pip install --upgrade pip
pip install tox==4.2.6

# sysmon (PEP 669) keeps tracer overhead low so timing-sensitive chaos
# tests (which kill/restart YDB) still pass under coverage. Requires py3.12+.
- name: Unit tests with coverage
env:
COVERAGE_CORE: sysmon
run: tox -e cov -- ydb

- name: Upload unit coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: unit
name: unit
# The gate is enforced via Codecov status checks (branch protection),
# so don't fail CI on transient upload errors.
fail_ci_if_error: false

- name: Integration tests with coverage
env:
COVERAGE_CORE: sysmon
run: tox -e cov -- tests

- name: Upload integration coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: integration
name: integration
fail_ci_if_error: false
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ ydb.egg-info/
/ydb_data
/tmp
.coverage
.coverage.*
/cov_html
/coverage.xml
/build
docs/_build
.DS_Store
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ YDB Python SDK
[![API Reference](https://img.shields.io/badge/API-Reference-lightgreen.svg)](https://ydb-platform.github.io/ydb-python-sdk)
[![Functional tests](https://github.com/ydb-platform/ydb-python-sdk/actions/workflows/tests.yaml/badge.svg)](https://github.com/ydb-platform/ydb-python-sdk/actions/workflows/tests.yaml)
[![Style checks](https://github.com/ydb-platform/ydb-python-sdk/actions/workflows/style.yaml/badge.svg)](https://github.com/ydb-platform/ydb-python-sdk/actions/workflows/style.yaml)
[![codecov](https://codecov.io/gh/ydb-platform/ydb-python-sdk/graph/badge.svg)](https://codecov.io/gh/ydb-platform/ydb-python-sdk)

Officially supported Python client for YDB.

Expand Down
26 changes: 26 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,29 @@ ignore_missing_imports = true
[[tool.mypy.overrides]]
module = ["ydb.types", "ydb.table"]
disable_error_code = ["attr-defined"]

[tool.coverage.run]
branch = true
source = ["ydb"]
# Auto-generated protobuf stubs and test files must not skew the metric.
omit = [
"ydb/_grpc/v3/*",
"ydb/_grpc/v4/*",
"ydb/_grpc/v5/*",
"ydb/_grpc/v6/*",
"*_test.py",
# Legacy, no longer actively developed.
"ydb/dbapi/*",
"ydb/sqlalchemy/*",
]

[tool.coverage.report]
show_missing = true
exclude_also = [
"if TYPE_CHECKING:",
"raise NotImplementedError",
"@(abc\\.)?abstractmethod",
]

[tool.coverage.html]
directory = "cov_html"
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ pylint-protobuf
cython
freezegun>=1.3.0
opentelemetry-sdk>=1.0.0
# pytest-cov
pytest-cov>=4.0.0
yandexcloud
-e .
8 changes: 8 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ deps =
-r{toxinidir}/test-requirements.txt
protobuf<6.0.0

[testenv:cov]
passenv = COVERAGE_CORE
commands =
pytest -v --cov --cov-report=term-missing --cov-report=html --cov-report=xml {posargs}
deps =
-r{toxinidir}/test-requirements.txt
protobuf<7.0.0

[testenv:py-proto4]
commands =
pytest -v {posargs}
Expand Down
Loading