Skip to content

Commit 3025df8

Browse files
committed
Add more debugging to parse_errors
1 parent 3fb3679 commit 3025df8

1 file changed

Lines changed: 68 additions & 14 deletions

File tree

.github/actions/incremental-build/parse_errors.sh

Lines changed: 68 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,43 +21,82 @@ set +e
2121

2222
LOG_FILE=$1
2323

24+
echo "[DEBUG parse_errors.sh] Processing: $LOG_FILE" >&2
25+
2426
# Extract module path from log file path
2527
# e.g., ./components-starter/camel-slack-starter/target/surefire-reports/foo.txt -> components-starter/camel-slack-starter
2628
MODULE_PATH=$(echo "$LOG_FILE" | sed 's|^\./||' | sed 's|/target/.*||')
29+
echo "[DEBUG parse_errors.sh] Module path: $MODULE_PATH" >&2
2730

2831
# Skip if file doesn't exist or is not readable
29-
if [[ ! -f "$LOG_FILE" ]] || [[ ! -r "$LOG_FILE" ]]; then
32+
if [[ ! -f "$LOG_FILE" ]]; then
33+
echo "[DEBUG parse_errors.sh] File does not exist: $LOG_FILE" >&2
3034
exit 0
3135
fi
3236

37+
if [[ ! -r "$LOG_FILE" ]]; then
38+
echo "[DEBUG parse_errors.sh] File is not readable: $LOG_FILE" >&2
39+
exit 0
40+
fi
41+
42+
echo "[DEBUG parse_errors.sh] File exists and is readable, size: $(wc -c < "$LOG_FILE") bytes" >&2
43+
3344
# Extract failures/errors
45+
echo "[DEBUG parse_errors.sh] Searching for FAILURE|ERROR patterns..." >&2
3446
raw_failures=$(cat "$LOG_FILE" | egrep "FAILURE|ERROR" 2>/dev/null || true)
3547
if [[ -z "$raw_failures" ]]; then
48+
echo "[DEBUG parse_errors.sh] No FAILURE or ERROR patterns found in file" >&2
3649
exit 0
3750
fi
3851

52+
echo "[DEBUG parse_errors.sh] Found FAILURE/ERROR entries (count: $(echo "$raw_failures" | wc -l))" >&2
53+
echo "[DEBUG parse_errors.sh] First few lines of raw_failures:" >&2
54+
echo "$raw_failures" | head -5 >&2
55+
3956
# Look for "Time elapsed" entries and extract org.* test names
57+
echo "[DEBUG parse_errors.sh] Searching for 'Time elapsed' entries..." >&2
4058
time_elapsed_entries=$(echo "$raw_failures" | grep "Time elapsed" 2>/dev/null || true)
59+
echo "[DEBUG parse_errors.sh] Time elapsed entries found: $(echo "$time_elapsed_entries" | wc -l)" >&2
60+
61+
echo "[DEBUG parse_errors.sh] Searching for org.* entries..." >&2
4162
org_entries=$(echo "$time_elapsed_entries" | egrep "^org" 2>/dev/null || true)
63+
echo "[DEBUG parse_errors.sh] org.* entries found: $(echo "$org_entries" | wc -l)" >&2
4264

4365
if [[ -n "$org_entries" ]]; then
66+
echo "[DEBUG parse_errors.sh] Processing org_entries:" >&2
67+
echo "$org_entries" >&2
68+
4469
# Generate summary with module path included in test name
4570
# Format: | Module::TestClass | Duration | Type |
71+
echo "[DEBUG parse_errors.sh] Generating failed_summary..." >&2
4672
failed_summary=$(echo "$org_entries" | sed 's/\!//g' | awk -v mod="$MODULE_PATH" -F ' ' '{printf "| **%s**::%s | %s%s | %s |\n", mod, $1,$5,$6, $8}' 2>/dev/null || true)
73+
echo "[DEBUG parse_errors.sh] failed_summary generated (length: ${#failed_summary})" >&2
4774

48-
if [[ -n "$failed_summary" ]] && [[ -n "${GITHUB_STEP_SUMMARY:-}" ]]; then
49-
# Add to GitHub step summary
50-
echo "$failed_summary" >> "$GITHUB_STEP_SUMMARY" 2>/dev/null || true
51-
52-
# Add detailed error output
53-
echo "" >> "$GITHUB_STEP_SUMMARY" 2>/dev/null || true
54-
echo "<details><summary>❌ Failure details for $MODULE_PATH</summary>" >> "$GITHUB_STEP_SUMMARY" 2>/dev/null || true
55-
echo "" >> "$GITHUB_STEP_SUMMARY" 2>/dev/null || true
56-
echo "\`\`\`" >> "$GITHUB_STEP_SUMMARY" 2>/dev/null || true
57-
cat "$LOG_FILE" | egrep -A 10 "FAILURE|ERROR" | head -100 >> "$GITHUB_STEP_SUMMARY" 2>/dev/null || true
58-
echo "\`\`\`" >> "$GITHUB_STEP_SUMMARY" 2>/dev/null || true
59-
echo "</details>" >> "$GITHUB_STEP_SUMMARY" 2>/dev/null || true
60-
echo "" >> "$GITHUB_STEP_SUMMARY" 2>/dev/null || true
75+
if [[ -n "$failed_summary" ]]; then
76+
echo "[DEBUG parse_errors.sh] failed_summary is not empty" >&2
77+
78+
if [[ -n "${GITHUB_STEP_SUMMARY:-}" ]]; then
79+
echo "[DEBUG parse_errors.sh] GITHUB_STEP_SUMMARY is set to: $GITHUB_STEP_SUMMARY" >&2
80+
81+
# Add to GitHub step summary
82+
echo "[DEBUG parse_errors.sh] Writing summary to GITHUB_STEP_SUMMARY..." >&2
83+
echo "$failed_summary" >> "$GITHUB_STEP_SUMMARY" 2>/dev/null || true
84+
85+
# Add detailed error output
86+
echo "" >> "$GITHUB_STEP_SUMMARY" 2>/dev/null || true
87+
echo "<details><summary>❌ Failure details for $MODULE_PATH</summary>" >> "$GITHUB_STEP_SUMMARY" 2>/dev/null || true
88+
echo "" >> "$GITHUB_STEP_SUMMARY" 2>/dev/null || true
89+
echo "\`\`\`" >> "$GITHUB_STEP_SUMMARY" 2>/dev/null || true
90+
cat "$LOG_FILE" | egrep -A 10 "FAILURE|ERROR" | head -100 >> "$GITHUB_STEP_SUMMARY" 2>/dev/null || true
91+
echo "\`\`\`" >> "$GITHUB_STEP_SUMMARY" 2>/dev/null || true
92+
echo "</details>" >> "$GITHUB_STEP_SUMMARY" 2>/dev/null || true
93+
echo "" >> "$GITHUB_STEP_SUMMARY" 2>/dev/null || true
94+
echo "[DEBUG parse_errors.sh] Summary written to GITHUB_STEP_SUMMARY" >&2
95+
else
96+
echo "[DEBUG parse_errors.sh] GITHUB_STEP_SUMMARY is not set, skipping summary output" >&2
97+
fi
98+
else
99+
echo "[DEBUG parse_errors.sh] failed_summary is empty, skipping summary generation" >&2
61100
fi
62101

63102
# Output to stderr for CI logs
@@ -71,6 +110,21 @@ if [[ -n "$org_entries" ]]; then
71110
cat "$LOG_FILE" | egrep -A 10 "FAILURE|ERROR" | head -50 >&2
72111
echo "=============================================" >&2
73112
echo "" >&2
113+
else
114+
echo "[DEBUG parse_errors.sh] No org.* entries found, but raw_failures exist" >&2
115+
echo "[DEBUG parse_errors.sh] Outputting raw_failures to help debug:" >&2
116+
echo "" >&2
117+
echo "=============================================" >&2
118+
echo "FAILURE/ERROR in module: $MODULE_PATH (no org.* pattern match)" >&2
119+
echo "=============================================" >&2
120+
echo "Raw failures found:" >&2
121+
echo "$raw_failures" | head -20 >&2
122+
echo "" >&2
123+
echo "Full log file content (first 100 lines):" >&2
124+
head -100 "$LOG_FILE" >&2
125+
echo "=============================================" >&2
126+
echo "" >&2
74127
fi
75128

129+
echo "[DEBUG parse_errors.sh] Finished processing $LOG_FILE" >&2
76130
exit 0

0 commit comments

Comments
 (0)