Skip to content

Commit 271ecac

Browse files
committed
Debug commit for coverage merge
1 parent 59e83ab commit 271ecac

File tree

1 file changed

+79
-16
lines changed

1 file changed

+79
-16
lines changed

.github/workflows/coverage-check-parallel.yml

Lines changed: 79 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ jobs:
7979
run: |
8080
echo "Running ${{ matrix.mode }} tests for ${{ matrix.test_file }}"
8181
82-
# Set test filter based on mode
8382
if [ "${{ matrix.mode }}" = "sea" ]; then
8483
TEST_FILTER="-k"
8584
TEST_EXPRESSION="extra_params1 or extra_params2"
@@ -93,22 +92,41 @@ jobs:
9392
COVERAGE_DATA=".coverage-${TEST_NAME}-${{ matrix.mode }}"
9493
echo "TEST_NAME=$TEST_NAME" >> $GITHUB_ENV
9594
95+
# Clean any previous coverage data to avoid conflicts
96+
rm -f .coverage*
97+
98+
echo "🧪 Running pytest with coverage..."
9699
poetry run pytest "${{ matrix.test_file }}" "$TEST_FILTER" "$TEST_EXPRESSION" \
97-
--cov=src --cov-append --cov-report=xml:$COVERAGE_FILE --cov-report=term \
98-
-v || [ $? -eq 5 ]
100+
--cov=src --cov-report=xml:$COVERAGE_FILE --cov-report=term -v || [ $? -eq 5 ]
101+
102+
echo "🔍 DEBUG: Post-test file analysis..."
103+
echo "Current directory contents:"
104+
ls -la
105+
106+
echo "Coverage-related files:"
107+
ls -la .coverage* coverage-* 2>/dev/null || echo "No coverage files found"
99108
100-
# Ensure .coverage file exists for merging (even if empty)
101109
if [ -f ".coverage" ]; then
110+
COVERAGE_SIZE=$(stat -c%s .coverage 2>/dev/null || stat -f%z .coverage)
111+
echo "✅ .coverage file found (${COVERAGE_SIZE} bytes)"
102112
mv .coverage "$COVERAGE_DATA"
103113
echo "✅ Saved coverage data as $COVERAGE_DATA"
104114
else
105115
echo "⚠️ No .coverage generated, creating empty file"
106116
touch "$COVERAGE_DATA"
107117
fi
108118
109-
# Debug: Show what files we have for upload
110-
echo "📁 Files available for upload:"
111-
ls -la .coverage* 2>/dev/null || echo "No coverage files found"
119+
if [ -f "$COVERAGE_FILE" ]; then
120+
XML_SIZE=$(stat -c%s "$COVERAGE_FILE" 2>/dev/null || stat -f%z "$COVERAGE_FILE")
121+
echo "✅ XML coverage file found: $COVERAGE_FILE (${XML_SIZE} bytes)"
122+
echo "XML preview:"
123+
head -3 "$COVERAGE_FILE" 2>/dev/null || echo "Cannot read XML file"
124+
else
125+
echo "❌ No XML coverage file generated: $COVERAGE_FILE"
126+
fi
127+
128+
echo "📁 Final files available for upload:"
129+
ls -la .coverage* coverage-* 2>/dev/null || echo "No coverage files found"
112130
113131
- name: Upload coverage artifact
114132
uses: actions/upload-artifact@v4
@@ -161,32 +179,78 @@ jobs:
161179

162180
- name: Merge coverage
163181
run: |
164-
# Install xmllint if not available
182+
echo "🔧 Installing xmllint..."
165183
if ! command -v xmllint &> /dev/null; then
166184
sudo apt-get update && sudo apt-get install -y libxml2-utils
167185
fi
168186
169-
# Copy all coverage files with unique names
187+
echo "📁 DEBUG: Checking downloaded artifacts structure..."
188+
find coverage_files -type f -name "*" | head -20
189+
echo "Total files found: $(find coverage_files -type f | wc -l)"
190+
170191
echo "📁 Checking for coverage files in artifacts..."
192+
COVERAGE_FILES_FOUND=0
171193
for artifact_dir in coverage_files/*/; do
172194
if [ -d "$artifact_dir" ]; then
173-
echo "Artifact: $(basename "$artifact_dir")"
195+
echo "🔍 Artifact: $(basename "$artifact_dir")"
196+
echo " Contents:"
174197
ls -la "$artifact_dir" || echo " (empty or inaccessible)"
198+
199+
# Copy .coverage files
175200
for cov_file in "$artifact_dir"/.coverage-*; do
176201
if [ -f "$cov_file" ]; then
177202
cp "$cov_file" .
178-
echo " ✅ Copied $(basename "$cov_file")"
203+
COVERAGE_FILES_FOUND=$((COVERAGE_FILES_FOUND + 1))
204+
echo " ✅ Copied $(basename "$cov_file") ($(stat -c%s "$cov_file" 2>/dev/null || stat -f%z "$cov_file") bytes)"
205+
fi
206+
done
207+
208+
# Copy XML files for debugging
209+
for xml_file in "$artifact_dir"/coverage-*.xml; do
210+
if [ -f "$xml_file" ]; then
211+
cp "$xml_file" .
212+
echo " 📄 Copied $(basename "$xml_file") ($(stat -c%s "$xml_file" 2>/dev/null || stat -f%z "$xml_file") bytes)"
179213
fi
180214
done
181215
fi
182216
done
183217
218+
echo "📊 SUMMARY: Found $COVERAGE_FILES_FOUND .coverage files"
184219
echo "Available .coverage files for merging:"
185-
ls -la .coverage-* 2>/dev/null || echo "No .coverage-* files found"
220+
ls -la .coverage-* 2>/dev/null || echo "❌ No .coverage-* files found"
221+
222+
echo "Available XML files:"
223+
ls -la coverage-*.xml 2>/dev/null || echo "❌ No XML files found"
186224
187-
poetry run coverage combine .coverage-* || true
188-
poetry run coverage xml || echo '<coverage lines-covered="0" lines-valid="1"></coverage>' > coverage.xml
189-
poetry run coverage report || true
225+
if [ $COVERAGE_FILES_FOUND -gt 0 ]; then
226+
echo "🔄 Combining coverage data..."
227+
poetry run coverage combine .coverage-* || {
228+
echo "❌ Coverage combine failed, checking individual files:"
229+
for f in .coverage-*; do
230+
if [ -f "$f" ]; then
231+
echo " File: $f ($(stat -c%s "$f" 2>/dev/null || stat -f%z "$f") bytes)"
232+
file "$f" 2>/dev/null || echo " Cannot determine file type"
233+
fi
234+
done
235+
echo "⚠️ Using fallback approach..."
236+
touch .coverage
237+
}
238+
239+
echo "📊 Generating XML report..."
240+
poetry run coverage xml || {
241+
echo "❌ XML generation failed, using fallback"
242+
echo '<coverage lines-covered="0" lines-valid="1"></coverage>' > coverage.xml
243+
}
244+
245+
echo "📋 Generating text report..."
246+
poetry run coverage report || echo "⚠️ Text report failed"
247+
else
248+
echo "⚠️ No coverage data files found, creating empty report"
249+
echo '<coverage lines-covered="0" lines-valid="1"></coverage>' > coverage.xml
250+
fi
251+
252+
echo "📄 Final coverage.xml preview:"
253+
head -5 coverage.xml 2>/dev/null || echo "Cannot read coverage.xml"
190254
191255
- name: Report coverage percentage
192256
run: |
@@ -199,7 +263,6 @@ jobs:
199263
COVERED=$(xmllint --xpath "string(//coverage/@lines-covered)" "$COVERAGE_FILE")
200264
TOTAL=$(xmllint --xpath "string(//coverage/@lines-valid)" "$COVERAGE_FILE")
201265
202-
# Calculate percentage using Python for precision
203266
PERCENTAGE=$(python3 -c "covered=${COVERED}; total=${TOTAL}; print(round((covered/total)*100, 2))")
204267
205268
echo "📊 Combined Coverage: ${PERCENTAGE}%"

0 commit comments

Comments
 (0)