Skip to content

Commit 7e03ad9

Browse files
committed
🎨 Better jq checks
1 parent 58041e6 commit 7e03ad9

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

lib/bazel-bep.bash

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ process_bep() {
4545
local BEP_FILE="$1"
4646
local BAZEL_COMMAND="${2:-}"
4747

48+
# Ensure the file exists
49+
if [[ ! -f "$BEP_FILE" ]]; then
50+
echo "Error: BEP file does not exist: $BEP_FILE"
51+
return 1
52+
fi
53+
4854
# Count of target statuses
4955
local success_count=0
5056
local fail_count=0
@@ -69,9 +75,15 @@ process_bep() {
6975
echo "Processing BEP file: $BEP_FILE"
7076

7177
# Parse the JSON stream
72-
while read -r line; do
73-
# Skip empty lines or invalid JSON
74-
if [ -z "$line" ] || ! echo "$line" | jq -e '.' > /dev/null 2>&1; then
78+
while read -r line || [[ -n "$line" ]]; do
79+
# Skip empty lines
80+
if [ -z "$line" ]; then
81+
continue
82+
fi
83+
84+
# Try to parse as JSON, but continue on errors
85+
if ! echo "$line" | jq -e '.' > /dev/null 2>&1; then
86+
echo "Warning: Skipping invalid JSON line: ${line:0:50}..."
7587
continue
7688
fi
7789

@@ -303,4 +315,7 @@ process_bep() {
303315

304316
# Create the annotation
305317
create_annotation "$style" "$summary"
318+
319+
# Always return success after processing
320+
return 0
306321
}

0 commit comments

Comments
 (0)