|
21 | 21 | -name:Discover test files |
22 | 22 | id:discover |
23 | 23 | run:| |
24 | | - # Find all test files in e2e directory and create JSON array (excluding test_driver.py and test_parameterized_queries.py for now) |
25 | | - TEST_FILES=$(find tests/e2e -name "test_*.py" -type f |grep -v -E "(test_driver\.py|test_parameterized_queries\.py)" |sort | jq -R -s -c 'split("\n")[:-1]') |
| 24 | + # Find all test files in e2e directory |
| 25 | + TEST_FILES=$(find tests/e2e -name "test_*.py" -type f | sort | jq -R -s -c 'split("\n")[:-1]') |
26 | 26 | echo "test-files=$TEST_FILES" >> $GITHUB_OUTPUT |
27 | 27 | echo "Discovered test files: $TEST_FILES" |
28 | 28 |
|
@@ -95,64 +95,25 @@ jobs: |
95 | 95 | # Clean any previous coverage data to avoid conflicts |
96 | 96 | rm -f .coverage* |
97 | 97 |
|
98 | | - echo "🧪Running pytest with coverage..." |
| 98 | + echo "Running pytest with coverage..." |
99 | 99 | poetry run pytest "${{ matrix.test_file }}" "$TEST_FILTER" "$TEST_EXPRESSION" \ |
100 | 100 | --cov=src --cov-report=xml:$COVERAGE_FILE --cov-report=term -v || [ $? -eq 5 ] |
101 | 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" |
108 | | -
|
| 102 | + # Save coverage data with unique name |
109 | 103 | 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)" |
112 | 104 | mv .coverage "$COVERAGE_DATA" |
113 | | - echo "✅ Saved coveragedata as $COVERAGE_DATA" |
| 105 | + echo "Coveragedata saved as $COVERAGE_DATA" |
114 | 106 | else |
115 | | - echo "⚠️ No .coverage generated, creating minimal coverage file" |
116 | | - # Create a minimal but valid coverage file using coverage.py |
| 107 | + # Create minimal coverage file for cases where no tests run |
117 | 108 | poetry run coverage erase |
118 | 109 | poetry run coverage run --source=src -m pytest --version > /dev/null 2>&1 ||true |
119 | 110 | if [ -f ".coverage" ]; then |
120 | 111 | mv .coverage "$COVERAGE_DATA" |
121 | | - echo "✅ Created minimal coverage file as $COVERAGE_DATA" |
122 | 112 | else |
123 | | - # Fallback: create empty file (will be handled gracefully in merge) |
124 | 113 | touch "$COVERAGE_DATA" |
125 | | - echo "⚠️ Created empty placeholder as $COVERAGE_DATA" |
126 | 114 | fi |
| 115 | + echo "Created minimal coverage file as $COVERAGE_DATA" |
127 | 116 | fi |
128 | | -
|
129 | | - if [ -f "$COVERAGE_FILE" ]; then |
130 | | - XML_SIZE=$(stat -c%s "$COVERAGE_FILE" 2>/dev/null || stat -f%z "$COVERAGE_FILE") |
131 | | - echo "✅ XML coverage file found: $COVERAGE_FILE (${XML_SIZE} bytes)" |
132 | | - echo "XML preview:" |
133 | | - head -3 "$COVERAGE_FILE" 2>/dev/null || echo "Cannot read XML file" |
134 | | - else |
135 | | - echo "❌ No XML coverage file generated: $COVERAGE_FILE" |
136 | | - fi |
137 | | -
|
138 | | - echo "📁 Final files available for upload:" |
139 | | - ls -la .coverage* coverage-* 2>/dev/null || echo "No coverage files found" |
140 | | -
|
141 | | - echo "🔍 Specifically checking for files to upload:" |
142 | | - echo " coverage-data-* files:" |
143 | | - ls -la coverage-data-* 2>/dev/null || echo " None found" |
144 | | - echo " coverage-*-${{ matrix.mode }}.xml files:" |
145 | | - ls -la coverage-*-${{ matrix.mode }}.xml 2>/dev/null || echo " None found" |
146 | | -
|
147 | | - echo "🔍 CRITICAL DEBUG: Checking exact upload patterns:" |
148 | | - echo " Pattern 'coverage-data-*' matches:" |
149 | | - find . -maxdepth 1 -name "coverage-data-*" -type f 2>/dev/null || echo " No matches" |
150 | | - echo " Pattern 'coverage-*-${{ matrix.mode }}.xml' matches:" |
151 | | - find . -maxdepth 1 -name "coverage-*-${{ matrix.mode }}.xml" -type f 2>/dev/null || echo " No matches" |
152 | | -
|
153 | | - echo "🔍 Working directory: $(pwd)" |
154 | | - echo "🔍 All files in current directory:" |
155 | | - ls -la |
156 | 117 |
|
157 | 118 | -name:Upload coverage artifact |
158 | 119 | uses:actions/upload-artifact@v4 |
@@ -205,101 +166,54 @@ jobs: |
205 | 166 |
|
206 | 167 | -name:Merge coverage |
207 | 168 | run:| |
208 | | -echo "🔧 Installingxmllint..." |
| 169 | +# Installxmllint if not available |
209 | 170 | if ! command -v xmllint &> /dev/null; then |
210 | 171 | sudo apt-get update && sudo apt-get install -y libxml2-utils |
211 | 172 | fi |
212 | 173 |
|
213 | | - echo "📁 DEBUG: Checking downloaded artifacts structure..." |
214 | | - find coverage_files -type f -name "*" | head -20 |
215 | | - echo "Total files found: $(find coverage_files -type f | wc -l)" |
216 | | -
|
217 | | - echo "📁 Checking for coverage files in artifacts..." |
| 174 | + # Copy coverage data files from artifacts |
218 | 175 | COVERAGE_FILES_FOUND=0 |
219 | 176 | for artifact_dir in coverage_files/*/; do |
220 | 177 | if [ -d "$artifact_dir" ]; then |
221 | | - echo "🔍 Artifact: $(basename "$artifact_dir")" |
222 | | - echo " Contents:" |
223 | | - ls -la "$artifact_dir" || echo " (empty or inaccessible)" |
224 | | -
|
225 | | - # Copy coverage data files |
226 | 178 | for cov_file in "$artifact_dir"/coverage-data-*; do |
227 | 179 | if [ -f "$cov_file" ]; then |
228 | 180 | cp "$cov_file" . |
229 | 181 | COVERAGE_FILES_FOUND=$((COVERAGE_FILES_FOUND + 1)) |
230 | | - echo " ✅ Copied $(basename "$cov_file") ($(stat -c%s "$cov_file" 2>/dev/null || stat -f%z "$cov_file") bytes)" |
231 | | - fi |
232 | | - done |
233 | | -
|
234 | | - # Copy XML files for debugging |
235 | | - for xml_file in "$artifact_dir"/coverage-*.xml; do |
236 | | - if [ -f "$xml_file" ]; then |
237 | | - cp "$xml_file" . |
238 | | - echo " 📄 Copied $(basename "$xml_file") ($(stat -c%s "$xml_file" 2>/dev/null || stat -f%z "$xml_file") bytes)" |
239 | 182 | fi |
240 | 183 | done |
241 | 184 | fi |
242 | 185 | done |
243 | 186 |
|
244 | | - echo "📊 SUMMARY: Found $COVERAGE_FILES_FOUND coverage data files" |
245 | | - echo "Available coverage data files for merging:" |
246 | | - ls -la coverage-data-* 2>/dev/null || echo "❌ No coverage-data-* files found" |
247 | | -
|
248 | | - echo "Available XML files:" |
249 | | - ls -la coverage-*.xml 2>/dev/null || echo "❌ No XML files found" |
| 187 | + echo "Found $COVERAGE_FILES_FOUND coverage data files" |
250 | 188 |
|
251 | 189 | if [ $COVERAGE_FILES_FOUND -gt 0 ]; then |
252 | | - echo "🔄Combining coverage data..." |
| 190 | + echo "Combining coverage data..." |
253 | 191 |
|
254 | | - # Rename coverage-data-* files to .coverage format for combining |
255 | 192 | for f in coverage-data-*; do |
256 | 193 | if [ -f "$f" ]; then |
257 | | - # Extract the suffix and create .coverage.suffix format |
258 | 194 | suffix=$(echo "$f" | sed 's/coverage-data-/.coverage./') |
259 | 195 | mv "$f" "$suffix" |
260 | | - echo " 📝 Renamed $f to $suffix" |
261 | 196 | fi |
262 | 197 | done |
263 | 198 |
|
264 | | - poetry run coverage combine .coverage.* || { |
265 | | - echo "❌ Coverage combine failed, checking individual files:" |
266 | | - for f in .coverage.*; do |
267 | | - if [ -f "$f" ]; then |
268 | | - echo " File: $f ($(stat -c%s "$f" 2>/dev/null || stat -f%z "$f") bytes)" |
269 | | - file "$f" 2>/dev/null || echo " Cannot determine file type" |
270 | | - fi |
271 | | - done |
272 | | - echo "⚠️ Using fallback approach..." |
273 | | - touch .coverage |
274 | | - } |
275 | | -
|
276 | | - echo "📊 Generating XML report..." |
277 | | - poetry run coverage xml || { |
278 | | - echo "❌ XML generation failed, using fallback" |
279 | | - echo '<coverage lines-covered="0" lines-valid="1"></coverage>' > coverage.xml |
280 | | - } |
281 | | -
|
282 | | - echo "📋 Generating text report..." |
283 | | - poetry run coverage report || echo "⚠️ Text report failed" |
| 199 | + # Combine coverage files and generate reports |
| 200 | + poetry run coverage combine .coverage.* 2>/dev/null ||true |
| 201 | + poetry run coverage xml 2>/dev/null || echo '<coverage lines-covered="0" lines-valid="1"></coverage>' > coverage.xml |
| 202 | + poetry run coverage report 2>/dev/null ||true |
284 | 203 | else |
285 | | - echo "⚠️No coverage data files found, creating empty report" |
| 204 | + echo "No coverage data files found, creating empty report" |
286 | 205 | echo '<coverage lines-covered="0" lines-valid="1"></coverage>' > coverage.xml |
287 | 206 | fi |
288 | | -
|
289 | | - echo "📄 Final coverage.xml preview:" |
290 | | - head -5 coverage.xml 2>/dev/null || echo "Cannot read coverage.xml" |
291 | 207 |
|
292 | 208 | -name:Report coverage percentage |
293 | 209 | run:| |
294 | | - COVERAGE_FILE="coverage.xml" |
295 | | - if [ ! -f "$COVERAGE_FILE" ]; then |
296 | | - echo "ERROR: Coverage file not found at $COVERAGE_FILE" |
| 210 | + if [ ! -f "coverage.xml" ]; then |
| 211 | + echo "ERROR: Coverage file not found" |
297 | 212 | exit 1 |
298 | 213 | fi |
299 | 214 |
|
300 | | - COVERED=$(xmllint --xpath "string(//coverage/@lines-covered)" "$COVERAGE_FILE") |
301 | | - TOTAL=$(xmllint --xpath "string(//coverage/@lines-valid)" "$COVERAGE_FILE") |
302 | | -
|
| 215 | + COVERED=$(xmllint --xpath "string(//coverage/@lines-covered)" "coverage.xml") |
| 216 | + TOTAL=$(xmllint --xpath "string(//coverage/@lines-valid)" "coverage.xml") |
303 | 217 | PERCENTAGE=$(python3 -c "covered=${COVERED}; total=${TOTAL}; print(round((covered/total)*100, 2))") |
304 | 218 |
|
305 | | - echo "📊Combined Coverage: ${PERCENTAGE}%" |
| 219 | + echo "Combined Coverage: ${PERCENTAGE}%" |