Skip to content

Commit

Permalink
Wait for the expected result in put step directly.
Browse files Browse the repository at this point in the history
  • Loading branch information
fourdollars committed Jun 4, 2024
1 parent afe40b5 commit a2fa3e1
Showing 1 changed file with 32 additions and 10 deletions.
42 changes: 32 additions & 10 deletions in
Original file line number Diff line number Diff line change
Expand Up @@ -402,18 +402,43 @@ case "$0" in
url=

until [ -n "$timeout" ] && [[ $duration -ge $timeout ]]; do
[ -z "$debug" ] && echo "curl -nsS ${queue}api/json # $duration/$timeout"
"${CURL[@]}" "${queue}api/json" > queue.json
[ -n "$debug" ] && jq -r -S -C < queue.json
url=$(jq -r '.executable | .url' < queue.json)
if [ "$url" != 'null' ]; then
break
if [ -n "$url" ] && [ "$url" != 'null' ] && [ -n "${expectedResult[*]}" ]; then
[ -z "$debug" ] && echo "curl -nsS ${url}api/json # $duration/$timeout"
"${CURL[@]}" "${url}api/json" | jq -r > "$tmp"
result=$(jq -r .result < "$tmp")
if [[ "${expectedResult[*]}" =~ $result ]]; then
break
elif [ "$result" != 'null' ]; then
IFS=' '
echo "$url doesn't have the expected results in \"${expectedResult[*]}\" ($result)."
IFS=$'\n\t'
exit 1
fi
else
[ -z "$debug" ] && echo "curl -nsS ${queue}api/json # $duration/$timeout"
"${CURL[@]}" "${queue}api/json" > queue.json
[ -n "$debug" ] && jq -r -S -C < queue.json
url=$(jq -r '.executable | .url' < queue.json)
if [ "$url" != 'null' ]; then
if [ -n "${expectedResult[*]}" ]; then
continue
else
break
fi
fi
fi
sleep 5
duration=$((duration+5))
done

if [ "$url" != 'null' ]; then
if [ -n "$timeout" ] && [[ $duration -ge $timeout ]]; then
if [ "$url" = 'null' ]; then
echo "No build and timed out ($duration/$timeout)."
else
echo "$url timed out ($duration/$timeout)."
fi
exit 1
else
[ -z "$debug" ] && echo "curl -nsS ${url}api/json"
"${CURL[@]}" "${url}api/json" | jq -r > "$tmp"
digest="sha256:$(jq -S -M 'del(.estimatedDuration,.nextBuild)' < "$tmp" | sha256sum | awk '{print $1}')"
Expand All @@ -425,9 +450,6 @@ case "$0" in
duration=$(jq -r .duration < "$tmp")
duration=$(readable_duration "$duration")
result=$(jq -r .result < "$tmp")
else
echo "No build and timed out ($duration/$timeout)."
exit 1
fi
;;
esac
Expand Down

0 comments on commit a2fa3e1

Please sign in to comment.