Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
dcb0851
PYTHON-5467 Add codecov integration
blink1073 Jan 28, 2026
2a36785
fix coverage target
blink1073 Jan 28, 2026
2b714fe
add codecov config
blink1073 Jan 28, 2026
a1a464f
generate xml report
blink1073 Jan 28, 2026
90aea18
allow search to find coverage file
blink1073 Jan 29, 2026
285ee75
fix handling of codecov
blink1073 Jan 29, 2026
e01d66a
debug
blink1073 Jan 29, 2026
399ad55
debug
blink1073 Jan 29, 2026
a307de8
dibug
blink1073 Jan 29, 2026
2383ce0
fix bin handling
blink1073 Jan 29, 2026
36571a9
fix dir handling
blink1073 Jan 29, 2026
3c6318e
try with do-upload
blink1073 Jan 29, 2026
8478244
fix pushd
blink1073 Jan 29, 2026
375c0dc
simplify
blink1073 Jan 29, 2026
80c7632
debug
blink1073 Jan 29, 2026
bf68f3d
try uv directly
blink1073 Jan 29, 2026
8afc9d7
upload coverage.xml
blink1073 Jan 30, 2026
f8b7425
update gitignore
blink1073 Jan 30, 2026
7708305
produce legacy file
blink1073 Jan 30, 2026
c77b3c9
fix coverage param
blink1073 Jan 30, 2026
deafed1
specify cov
blink1073 Jan 30, 2026
fb06afa
generate xml with coverage command
blink1073 Jan 30, 2026
f6ef2f3
fix coverage gen
blink1073 Jan 30, 2026
90ec592
fix coverage gen
blink1073 Jan 30, 2026
3f43d33
try with default settings
blink1073 Jan 30, 2026
4824a88
try again
blink1073 Jan 30, 2026
c5f6356
add flag config
blink1073 Jan 30, 2026
446a438
try setting the git server
blink1073 Jan 30, 2026
b717d0b
fix evg report
blink1073 Jan 30, 2026
84ba8e4
fix evg report
blink1073 Jan 30, 2026
c2a8c29
use explicit cov args
blink1073 Jan 30, 2026
ae5904a
cleanup
blink1073 Jan 30, 2026
66afe8c
fix cov usage
blink1073 Jan 30, 2026
d6cc0dc
fix cov usage
blink1073 Jan 30, 2026
ae533d2
fix cov usage
blink1073 Jan 30, 2026
6f19bf0
fix cov usage
blink1073 Jan 30, 2026
f4036fd
fix cov usage
blink1073 Jan 30, 2026
46d4dee
try increasing bson coverage
blink1073 Jan 30, 2026
1356ef1
try increasing bson coverage
blink1073 Jan 31, 2026
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
1 change: 1 addition & 0 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ post:
# Disabled, causing timeouts
# - func: "upload working dir"
- func: "teardown system"
- func: "upload codecov"
- func: "upload coverage"
- func: "upload mo artifacts"
- func: "upload test results"
Expand Down
18 changes: 18 additions & 0 deletions .evergreen/generated_configs/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,24 @@ functions:
- TOOLCHAIN_VERSION
type: test

# Upload coverage codecov
upload codecov:
- command: subprocess.exec
params:
binary: bash
args:
- .evergreen/scripts/upload-codecov.sh
working_dir: src
include_expansions_in_env:
- CODECOV_TOKEN
- build_variant
- task_name
- github_commit
- github_pr_number
- github_pr_head_branch
- github_author
type: test

# Upload coverage
upload coverage:
- command: ec2.assume_role
Expand Down
3 changes: 3 additions & 0 deletions .evergreen/generated_configs/variants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ buildvariants:
display_name: No C Ext RHEL8
run_on:
- rhel87-small
expansions:
COVERAGE: "1"
NO_EXT: "1"

# No server tests
- name: no-server-rhel8
Expand Down
22 changes: 20 additions & 2 deletions .evergreen/scripts/generate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,10 @@ def create_green_framework_variants():
def create_no_c_ext_variants():
host = DEFAULT_HOST
tasks = [".test-standard"]
expansions = dict()
expansions = dict(COVERAGE="1")
handle_c_ext(C_EXTS[0], expansions)
display_name = get_variant_name("No C Ext", host)
return [create_variant(tasks, display_name, host=host)]
return [create_variant(tasks, display_name, host=host, expansions=expansions)]


def create_mod_wsgi_variants():
Expand Down Expand Up @@ -1077,6 +1077,24 @@ def create_upload_coverage_func():
return "upload coverage", [get_assume_role(), cmd]


def create_upload_coverage_codecov_func():
# Upload the coverage xml report to codecov.
include_expansions = [
"CODECOV_TOKEN",
"build_variant",
"task_name",
"github_commit",
"github_pr_number",
"github_pr_head_branch",
"github_author",
]
args = [
".evergreen/scripts/upload-codecov.sh",
]
upload_cmd = get_subprocess_exec(include_expansions_in_env=include_expansions, args=args)
return "upload codecov", [upload_cmd]


def create_download_and_merge_coverage_func():
include_expansions = ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"]
args = [
Expand Down
42 changes: 42 additions & 0 deletions .evergreen/scripts/upload-codecov.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
# shellcheck disable=SC2154
# Upload a coverate report to codecov.
set -eu

HERE=$(dirname ${BASH_SOURCE:-$0})
ROOT=$(dirname "$(dirname $HERE)")

pushd $ROOT > /dev/null
export FNAME=coverage.xml

if [ -z "${github_pr_number:-}" ]; then
echo "This is not a PR, not running codecov"
exit 0
fi

if [ ! -f ".coverage" ]; then
echo "There are no XML test results, not running codecov"
exit 0
fi

echo "Uploading..."
printf 'pr: %s\n' "$github_pr_number"
printf 'sha: %s\n' "$github_commit"
printf 'branch: %s:%s\n' "$github_author" "$github_pr_head_branch"
printf 'flag: %s-%s\n' "$build_variant" "$task_name"
printf 'file: %s\n' "$FNAME"
uv tool run --with "coverage[toml]" coverage xml
uv tool run --from codecov-cli codecovcli upload-process \
--report-type coverage \
--disable-search \
--fail-on-error \
--git-service github \
--token ${CODECOV_TOKEN} \
--pr ${github_pr_number} \
--sha ${github_commit} \
--branch "${github_author}:${github_pr_head_branch}" \
--flag "${build_variant}-${task_name}" \
--file $FNAME
echo "Uploading...done."

popd > /dev/null
29 changes: 29 additions & 0 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,35 @@ jobs:
- name: Run tests
run: uv run --extra test pytest -v

coverage:
# This enables a coverage report for a given PR, which will be augmented by
# the combined codecov report uploaded in Evergreen.
runs-on: ubuntu-latest

name: Coverage
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7
with:
enable-cache: true
python-version: "3.10"
- id: setup-mongodb
uses: mongodb-labs/drivers-evergreen-tools@master
with:
version: "8.0"
- name: Install just
run: uv tool install rust-just
- name: Setup tests
run: COVERAGE=1 just setup-tests
- name: Run tests
run: just run-tests
- name: Generate xml report
run: uv tool run --with "coverage[toml]" coverage xml
- name: Upload test results to Codecov
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5
doctest:
runs-on: ubuntu-latest
name: DocTest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ test/lambda/*.json

# test results and logs
xunit-results/
coverage.xml
server.log
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,11 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?)|dummy.*)$"

[tool.coverage.run]
branch = true
source = ["pymongo", "bson", "gridfs" ]
include = [
"pymongo/*",
"bson/*",
"gridfs/*"
]
relative_files = true

[tool.coverage.report]
Expand Down
Loading