Skip to content

Commit

Permalink
Refactor verify script (#313)
Browse files Browse the repository at this point in the history
* format and relplace backticks

* add retry
  • Loading branch information
friedrichwilken authored Dec 12, 2023
1 parent 551b0e1 commit 2036473
Showing 1 changed file with 36 additions and 9 deletions.
45 changes: 36 additions & 9 deletions scripts/verify-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,42 @@
echo "Checking status of POST Jobs for Eventing-Manager"

REF_NAME="${1:-"main"}"
TIMEOUT_TIME="${2:-120}"
INTERVAL_TIME="${3:-3}"

# Generate job Status URL
STATUS_URL="https://api.github.com/repos/kyma-project/eventing-manager/commits/${REF_NAME}/status"
fullstatus=`curl -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" ${STATUS_URL} | head -n 2 `

sleep 10
echo $fullstatus
function retry {
local start_time=$(date +%s)
# Get status result
local statusresult=$(curl -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" ${STATUS_URL})
# Get overall state
local fullstatus=$(echo $statusresult | jq '.state' | tr -d '"')

while [ "$fullstatus" == "pending" ]; do
current_time=$(date +%s)
elapsed_time=$((current_time - start_time))

if [ $elapsed_time -ge $TIMEOUT_TIME ]; then
echo "Timeout reached. Exiting."
exit 1
fi

echo "Status is 'pending'. Retrying in $interval seconds..."
sleep $INTERVAL_TIME
done

# Show overall state to user
echo "$statusresult"

if [[ "$fullstatus" == *"success"* ]]; then
echo "All jobs succeeded"
else
echo "Jobs failed or pending - Check Prow status"
exit 1
fi
if [ "$fullstatus" == "success" ]; then
echo "Success!"
elif [ "$fullstatus" == "failed" ]; then
echo "Failure! Exiting with an error."
exit 1
else
echo "Invalid result: $result"
exit 1
fi
}

0 comments on commit 2036473

Please sign in to comment.