@@ -28,31 +28,48 @@ runs:
28
28
shell : bash
29
29
# Filter failed E2E files from the result JSON file, and re-run them.
30
30
run : |
31
- # Debug: Check if results file exists and show its structure
31
+ # Debug: Check if results file exists
32
32
echo "Checking for results file: $E2E_RESULT_FILEPATH"
33
33
if [[ -f "$E2E_RESULT_FILEPATH" ]]; then
34
34
echo "Results file exists, size: $(wc -c < "$E2E_RESULT_FILEPATH") bytes"
35
- echo "First 500 characters of results file:"
36
- head -c 500 "$E2E_RESULT_FILEPATH"
37
- echo ""
38
35
39
36
# Extract failed test files and run only those
40
37
echo "Extracting failed test files..."
38
+
39
+ # Try multiple JSON structures to find failed tests
40
+ FAILED_FILES=""
41
+
42
+ # Method 1: Standard structure
43
+ echo "Trying standard JSON structure..."
41
44
FAILED_FILES=$(cat "$E2E_RESULT_FILEPATH" | jq -r '[.suites[] | (if has("suites") then .suites[] | .specs[] else .specs[] end) | select(.tests[].status == "unexpected") | .file] | unique | .[]' 2>/dev/null)
42
45
43
- if [[ $? -ne 0 ]]; then
44
- echo "Error: jq command failed. Trying alternative JSON structure..."
45
- # Try alternative structure - maybe tests are directly in specs
46
+ # Method 2: Direct specs structure
47
+ if [[ -z "$FAILED_FILES" ]]; then
48
+ echo "Trying direct specs structure..."
46
49
FAILED_FILES=$(cat "$E2E_RESULT_FILEPATH" | jq -r '[.suites[] | .specs[] | select(.tests[].status == "unexpected") | .file] | unique | .[]' 2>/dev/null)
47
50
fi
48
51
52
+ # Method 3: Look for any file with unexpected status
53
+ if [[ -z "$FAILED_FILES" ]]; then
54
+ echo "Trying to find any file with unexpected status..."
55
+ FAILED_FILES=$(cat "$E2E_RESULT_FILEPATH" | jq -r '[.. | select(.status? == "unexpected") | .file] | unique | .[]' 2>/dev/null)
56
+ fi
57
+
58
+ # Method 4: Look for files in test results
59
+ if [[ -z "$FAILED_FILES" ]]; then
60
+ echo "Trying to extract from test results..."
61
+ FAILED_FILES=$(cat "$E2E_RESULT_FILEPATH" | jq -r '[.suites[] | .specs[] | select(.tests[] | .status == "unexpected") | .file] | unique | .[]' 2>/dev/null)
62
+ fi
63
+
49
64
if [[ -n "$FAILED_FILES" ]]; then
50
65
echo "Retrying failed test files: $FAILED_FILES"
51
66
npx playwright test --config=tests/e2e/playwright.config.ts --grep-invert @todo $FAILED_FILES
52
67
else
53
68
echo "No failed test files found to retry"
54
- echo "Debug: Full JSON structure:"
55
- cat "$E2E_RESULT_FILEPATH" | jq '.' | head -50
69
+ echo "Debug: Checking JSON structure..."
70
+ echo "JSON keys: $(cat "$E2E_RESULT_FILEPATH" | jq -r 'keys | .[]' 2>/dev/null || echo "Failed to get keys")"
71
+ echo "Has suites: $(cat "$E2E_RESULT_FILEPATH" | jq -r 'has("suites")' 2>/dev/null || echo "Failed to check suites")"
72
+ echo "Suites count: $(cat "$E2E_RESULT_FILEPATH" | jq -r '.suites | length' 2>/dev/null || echo "Failed to get suites count")"
56
73
fi
57
74
else
58
75
echo "Error: Results file not found at $E2E_RESULT_FILEPATH"
0 commit comments