Skip to content
Draft
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
5 changes: 5 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
comment: # this is a top-level key
layout: " diff, flags, files"
behavior: default
require_changes: true
require_base: false
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
19 changes: 19 additions & 0 deletions .evergreen/generated_configs/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,25 @@ 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
silent: true
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
20 changes: 20 additions & 0 deletions .evergreen/scripts/generate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,26 @@ 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(
silent=True, 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
2 changes: 1 addition & 1 deletion .evergreen/scripts/setup_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def handle_test_env() -> None:
# Keep in sync with combine-coverage.sh.
# coverage >=5 is needed for relative_files=true.
UV_ARGS.append("--group coverage")
TEST_ARGS = f"{TEST_ARGS} --cov"
TEST_ARGS = f"{TEST_ARGS} --cov --cov-report=xml"
write_env("COVERAGE")

if opts.green_framework:
Expand Down
32 changes: 32 additions & 0 deletions .evergreen/scripts/upload-codecov.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
# shellcheck disable=SC2154
# Upload a coverate report to codecov.
set -eux

echo "Inside upload-codecov script"

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

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

# TODO: handle linux and windows.
curl -Os https://cli.codecov.io/latest/linux/codecov
curl -Os https://cli.codecov.io/latest/linux/codecov.SHA256SUM
shasum -a 256 -c codecov.SHA256SUM
sudo chmod +x codecov
./codecov upload-process \
--report-type test_results \
--disable-search \
--fail-on-error \
--token ${CODECOV_TOKEN} \
--pr ${github_pr_number} \
--sha "${github_commit}" \
--branch "${github_author}:${github_pr_head_branch}" \
--flag "${build_variant}-${task_name}" \
--file xunit-results/TEST-results.xml
30 changes: 30 additions & 0 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,36 @@ 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: Upload test results to Codecov
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5
with:
report_type: test_results
token: ${{ secrets.CODECOV_TOKEN }}
doctest:
runs-on: ubuntu-latest
name: DocTest
Expand Down
Loading