Skip to content

Commit 698b6a9

Browse files
committed
Add debug logging to diagnose empty log output
1 parent 379561f commit 698b6a9

1 file changed

Lines changed: 32 additions & 3 deletions

File tree

.github/workflows/worker-build-logs.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,34 @@ jobs:
7777
7878
print_new_logs() {
7979
local json="$1"
80-
if [ -z "$json" ]; then return; fi
80+
echo "[DEBUG] print_new_logs called, json length: ${#json}"
81+
if [ -z "$json" ]; then
82+
echo "[DEBUG] json is empty, returning"
83+
return
84+
fi
85+
86+
# Check if .lines exists
87+
has_lines=$(echo "$json" | jq 'has("lines")' 2>/dev/null || echo "false")
88+
echo "[DEBUG] has .lines key: $has_lines"
89+
90+
# Check top-level keys
91+
echo "[DEBUG] top-level keys: $(echo "$json" | jq -r 'keys | join(", ")' 2>/dev/null || echo "PARSE ERROR")"
8192
8293
total_lines=$(echo "$json" | jq '.lines | length' 2>/dev/null || echo "0")
94+
echo "[DEBUG] total_lines=$total_lines last_line_count=$last_line_count"
8395
8496
if [ "$total_lines" -gt "$last_line_count" ]; then
97+
echo "[DEBUG] printing lines from $last_line_count to $total_lines"
98+
# Print first line raw for debugging
99+
echo "[DEBUG] first new line raw: $(echo "$json" | jq --argjson skip "$last_line_count" '.lines[$skip:][0]' 2>/dev/null)"
85100
echo "$json" | jq -r \
86101
--argjson skip "$last_line_count" \
87102
'.lines[$skip:][] | .[1]'
103+
jq_exit=$?
104+
echo "[DEBUG] jq exit code: $jq_exit"
88105
last_line_count=$total_lines
106+
else
107+
echo "[DEBUG] no new lines to print"
89108
fi
90109
}
91110
@@ -135,26 +154,36 @@ jobs:
135154
outcome=$(echo "$build_data" | jq -r '.build_outcome // empty')
136155
137156
# Fetch and print new log lines
138-
logs_json=$(curl -sf \
157+
echo "[DEBUG] Fetching logs for build ${build_uuid}..."
158+
logs_json=$(curl -s \
139159
"${API_BASE}/builds/builds/${build_uuid}/logs" \
140160
-H "$AUTH_HEADER" \
141161
) 2>/dev/null || logs_json=""
162+
logs_curl_exit=$?
163+
echo "[DEBUG] logs curl exit code: $logs_curl_exit, response length: ${#logs_json}"
164+
echo "[DEBUG] logs first 500 chars: ${logs_json:0:500}"
142165
143166
print_new_logs "$logs_json"
144167
145168
# When a build finishes, status becomes "stopped" and the
146169
# result is in build_outcome (success, fail, skipped, cancelled, terminated).
147170
if [ "$status" = "stopped" ]; then
171+
echo "[DEBUG] Build is stopped, outcome=$outcome"
148172
# Do a final log fetch to make sure we got everything
149173
sleep 2
150-
final_logs=$(curl -sf \
174+
echo "[DEBUG] Doing final log fetch..."
175+
final_logs=$(curl -s \
151176
"${API_BASE}/builds/builds/${build_uuid}/logs" \
152177
-H "$AUTH_HEADER" \
153178
) 2>/dev/null || final_logs=""
179+
echo "[DEBUG] final_logs length: ${#final_logs}"
180+
echo "[DEBUG] final_logs first 500 chars: ${final_logs:0:500}"
154181
155182
if [ -n "$final_logs" ]; then
156183
print_new_logs "$final_logs"
157184
print_build_phases "$final_logs"
185+
else
186+
echo "[DEBUG] final_logs is empty!"
158187
fi
159188
160189
echo ""

0 commit comments

Comments
 (0)