33
44# Script to upload coverage to Codecov
55# Usage: upload_codecov.sh "Step Label"
6+ #
7+ # Coverage Architecture Notes:
8+ # - Tests import vllm from: /usr/local/lib/python3.12/dist-packages/vllm/ (installed package)
9+ # - Source code exists at: /vllm-workspace/src/vllm/ (for python_only_compile.sh test)
10+ # - Coverage tracks the installed package location during test execution
11+ # - Path mapping in .coveragerc normalizes paths to vllm/ for reporting
612
713STEP_LABEL=" ${1:- unknown} "
814
@@ -15,57 +21,75 @@ if [ "$FLAG" = "multi-modal_models_test_standard" ]; then
1521 exit 0
1622fi
1723
18- # Find and normalize ALL coverage.xml files in the workspace
19- # This handles cases where tests run from different directories (e.g., whisper tests with cd ..)
20- COVERAGE_FILES=$( find /vllm-workspace -name " coverage.xml" -type f 2> /dev/null || true)
24+ # Find all .coverage.* files in the workspace
25+ COVERAGE_DB_FILES=$( find /vllm-workspace -name " .coverage.*" -type f 2> /dev/null || true)
2126
22- if [ -z " $COVERAGE_FILES " ]; then
23- echo " No coverage.xml files found in /vllm-workspace, skipping upload"
27+ if [ -z " $COVERAGE_DB_FILES " ]; then
28+ echo " No . coverage.* files found in /vllm-workspace, skipping upload"
2429 exit 0
2530fi
2631
27- echo " Found coverage.xml files:"
28- echo " $COVERAGE_FILES "
29-
30- # Normalize paths in ALL coverage.xml files
31- for cov_file in $COVERAGE_FILES ; do
32- echo " "
33- echo " Processing: $cov_file "
34- echo " Sample paths before normalization:"
35- grep ' filename=' " $cov_file " | head -3 || true
36-
37- # Normalize filenames to ensure consistent paths across uploads
38- # Map any site/dist-packages and workspace-relative paths to canonical "vllm/"
39- if sed -i \
40- -e ' s@filename="[^"]*/site-packages/vllm/@filename="vllm/@g' \
41- -e ' s@filename="[^"]*/dist-packages/vllm/@filename="vllm/@g' \
42- -e ' s@filename="/vllm-workspace/vllm/@filename="vllm/@g' \
43- -e ' s@filename="\./vllm/@filename="vllm/@g' \
44- -e ' s@filename="\.\./vllm/@filename="vllm/@g' \
45- " $cov_file " 2> /dev/null; then
46- echo " ✓ Path normalization successful for $cov_file "
47- else
48- echo " ⚠ Warning: sed path normalization failed for $cov_file "
32+ echo " Found $( echo " $COVERAGE_DB_FILES " | wc -l) coverage file(s) to process"
33+
34+ # Change to /vllm-workspace to combine coverage files
35+ cd /vllm-workspace
36+
37+ # Move all .coverage.* files to the current directory so coverage combine can find them
38+ # Note: coverage combine only looks in the current directory, not subdirectories
39+ # Using cp -n to skip files that are already in the target directory
40+ for cov_file in $COVERAGE_DB_FILES ; do
41+ if [ -f " $cov_file " ]; then
42+ cp -n " $cov_file " . 2> /dev/null || true
4943 fi
50-
51- echo " Sample paths after normalization:"
52- grep ' filename=' " $cov_file " | head -3 || true
5344done
5445
55- # Use coverage.xml in current directory for upload
46+ # Combine all coverage database files into a single .coverage file
47+ # This will apply the [paths] remapping from .coveragerc to normalize paths to vllm/
48+ echo " Combining coverage files..."
49+ COMBINE_OUTPUT=$( python3 -m coverage combine --keep 2>&1 )
50+ COMBINE_EXIT=$?
51+
52+ echo " $COMBINE_OUTPUT "
53+
54+ # Check if it's the "No data to combine" error (coverage exits with 0 even for this!)
55+ if echo " $COMBINE_OUTPUT " | grep -q " No data to combine" ; then
56+ echo " Warning: No coverage data found - skipping upload"
57+ exit 0
58+ fi
59+
60+ if [ $COMBINE_EXIT -ne 0 ]; then
61+ echo " Error: coverage combine failed with status $COMBINE_EXIT "
62+ exit 1
63+ fi
64+
65+ # Check if combine was successful
66+ if [ ! -f .coverage ]; then
67+ echo " Error: Failed to combine coverage files - .coverage not created"
68+ exit 1
69+ fi
70+ echo " Successfully combined coverage files"
71+
72+ # Generate XML report from the combined coverage data
73+ # This will use the path mappings from .coveragerc to normalize paths
74+ echo " Generating XML coverage report..."
75+ python3 -m coverage xml -o coverage.xml
76+
5677if [ ! -f coverage.xml ]; then
57- echo " Warning: No coverage.xml in current directory $( pwd) , using first found file"
58- FIRST_COV=$( echo " $COVERAGE_FILES " | head -1)
59- ln -s " $FIRST_COV " coverage.xml || cp " $FIRST_COV " coverage.xml
78+ echo " Error: Failed to generate coverage.xml"
79+ exit 1
6080fi
6181
62- # Ensure Codecov does not re-generate coverage from local DBs anywhere; upload XML as-is
63- find /vllm-workspace -type f -name " .coverage* " -delete 2> /dev/null || true
64- rm -f . coverage .coverage. * 2> /dev/null || true
82+ # Count total files in coverage report
83+ TOTAL_FILES= $( grep -c ' <class.*filename= ' coverage.xml || echo " 0 " )
84+ echo " Generated coverage.xml with $TOTAL_FILES files "
6585
6686# Download codecov CLI if not present
6787if [ ! -f codecov ]; then
68- curl -Os https://cli.codecov.io/latest/linux/codecov
88+ echo " Downloading codecov CLI..."
89+ if ! curl -Os https://cli.codecov.io/latest/linux/codecov; then
90+ echo " Warning: Failed to download codecov CLI"
91+ exit 1
92+ fi
6993 chmod +x codecov
7094fi
7195
@@ -90,7 +114,7 @@ if [ "$UPLOAD_SLUG" = "$DEFAULT_SLUG" ] && [ -z "${CODECOV_TOKEN:-}" ]; then
90114fi
91115
92116# Build Codecov args
93- # Use coverage-upload directory to ensure codecov only finds our single combined file
117+ # Let codecov find all coverage files and use codecov.yml fixes to normalize paths
94118CODECOV_ARGS=(upload-process -f coverage.xml --git-service github \
95119 --build " ${BUILDKITE_BUILD_NUMBER:- unknown} " \
96120 --branch " ${BUILDKITE_BRANCH:- unknown} " \
@@ -107,6 +131,7 @@ if [ -n "${BUILDKITE_PULL_REQUEST:-}" ] && [ "${BUILDKITE_PULL_REQUEST}" != "fal
107131fi
108132
109133# Upload to codecov
110- ./codecov " ${CODECOV_ARGS[@]} " || true
134+ echo " Uploading to codecov..."
135+ ./codecov " ${CODECOV_ARGS[@]} " || echo " Warning: codecov upload failed"
111136
112137exit 0
0 commit comments