PYTHON-5467 Fix codecov upload on Evergreen (#2702)

This commit is contained in:
Steven Silvester 2026-02-09 13:55:08 -06:00 committed by GitHub
parent b1a0a1f104
commit fdb6a3291f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 35 additions and 16 deletions

View File

@ -268,6 +268,8 @@ functions:
- github_pr_number
- github_pr_head_branch
- github_author
- is_patch
- branch_name
type: test
# Upload coverage

View File

@ -1087,6 +1087,8 @@ def create_upload_coverage_codecov_func():
"github_pr_number",
"github_pr_head_branch",
"github_author",
"is_patch",
"branch_name",
]
args = [
".evergreen/scripts/upload-codecov.sh",

View File

@ -9,34 +9,49 @@ 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"
if [ -n "${is_patch:-}" ]; then
echo "This is a patch build, not running codecov"
exit 0
fi
if [ ! -f ".coverage" ]; then
echo "There are no XML test results, not running codecov"
echo "There are no coverage 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
codecov_args=(
upload-process
--report-type coverage
--disable-search
--fail-on-error
--git-service github
--token "${CODECOV_TOKEN}"
--sha "${github_commit}"
--flag "${build_variant}-${task_name}"
--file "${FNAME}"
)
if [ -n "${github_pr_number:-}" ]; then
printf 'branch: %s:%s\n' "$github_author" "$github_pr_head_branch"
printf 'pr: %s\n' "$github_pr_number"
uv tool run --from codecov-cli codecovcli \
"${codecov_args[@]}" \
--pr "${github_pr_number}" \
--branch "${github_author}:${github_pr_head_branch}"
else
printf 'branch: %s\n' "$branch_name"
uv tool run --from codecov-cli codecovcli \
"${codecov_args[@]}" \
--branch "${branch_name}"
fi
echo "Uploading...done."
popd > /dev/null