Skip to content

Commit eef4b4c

Browse files
committed
potentially prints error in ci, idk
1 parent a10942a commit eef4b4c

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

scripts/build.sh

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,29 +115,36 @@ function RunXcodebuild() {
115115

116116
local xcbeautify_cmd=(xcbeautify --renderer github-actions --disable-logging)
117117

118-
local result=0
119-
NSUnbufferedIO=YES xcodebuild "$@" 2>&1 | tee "$log_filename" | \
120-
"${xcbeautify_cmd[@]}" && CheckUnexpectedFailures "$log_filename" \
121-
|| result=$?
118+
# Run xcodebuild and capture the exit status of each command in the pipeline.
119+
NSUnbufferedIO=YES xcodebuild "$@" 2>&1 | tee "$log_filename" | "${xcbeautify_cmd[@]}"
120+
local pipe_statuses=("${PIPESTATUS[@]}")
121+
local result=${pipe_statuses[0]}
122122

123+
# If the first try failed with a potentially transient error (65), retry once.
123124
if [[ $result == 65 ]]; then
124125
ExportLogs "$@"
125-
126126
echo "xcodebuild exited with 65, retrying" 1>&2
127127
sleep 5
128128

129-
result=0
130-
NSUnbufferedIO=YES xcodebuild "$@" 2>&1 | tee "$log_filename" | \
131-
"${xcbeautify_cmd[@]}" && CheckUnexpectedFailures "$log_filename" \
132-
|| result=$?
129+
NSUnbufferedIO=YES xcodebuild "$@" 2>&1 | tee "$log_filename" | "${xcbeautify_cmd[@]}"
130+
pipe_statuses=("${PIPESTATUS[@]}")
131+
result=${pipe_statuses[0]}
133132
fi
134133

134+
# If the command failed, print the relevant part of the raw log to avoid noise.
135135
if [[ $result != 0 ]]; then
136-
echo "xcodebuild exited with $result" 1>&2
137-
136+
echo "xcodebuild exited with $result. Showing relevant part of the raw log:" 1>&2
137+
# This awk script finds the first line matching one of the error patterns
138+
# and prints from that line to the end of the file. This avoids duplicating
139+
# successful build output.
140+
awk '/error:|fatal:|terminated|\*\* (BUILD|TEST) FAILED \*\*/ {f=1} f' "$log_filename" 1>&2
138141
ExportLogs "$@"
139142
return $result
140143
fi
144+
145+
# If the command succeeded, check for unexpected test failures which don't
146+
# always cause xcodebuild to return a non-zero exit code.
147+
CheckUnexpectedFailures "$log_filename" || return $?
141148
}
142149

143150
# Exports any logs output captured in the xcresult

0 commit comments

Comments
 (0)