diff --git a/.evergreen/generated_configs/functions.yml b/.evergreen/generated_configs/functions.yml index 6fcda5e985..58bffbf922 100644 --- a/.evergreen/generated_configs/functions.yml +++ b/.evergreen/generated_configs/functions.yml @@ -268,6 +268,8 @@ functions: - github_pr_number - github_pr_head_branch - github_author + - is_patch + - branch_name type: test # Upload coverage diff --git a/.evergreen/scripts/generate_config.py b/.evergreen/scripts/generate_config.py index 405125021f..3375b9e14e 100644 --- a/.evergreen/scripts/generate_config.py +++ b/.evergreen/scripts/generate_config.py @@ -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", diff --git a/.evergreen/scripts/upload-codecov.sh b/.evergreen/scripts/upload-codecov.sh index a7fdb03711..75bd9d9e21 100755 --- a/.evergreen/scripts/upload-codecov.sh +++ b/.evergreen/scripts/upload-codecov.sh @@ -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