Sync: a dropped connection to Diffinery no longer fails the wait (#73)
The main sync for a2120c0 failed after 15 minutes of waiting with "curl: (35) Recv failure: Connection reset by peer": curl's --retry doesn't retry a reset connection, and under `set -e` one failed poll ended the step without saying how the runs went. Requests now retry on any error, and a poll that still fails is logged and repeated until the time limit. Claude-Session: https://claude.ai/code/session_01Ruyx3Qr4jYrZEpPi466deb Co-authored-by: Claude <noreply@anthropic.com>
Canberk Demirci authored · GitHub committed signed1 parent 2fd1b06commit 9c9b881bb3af2b767f5aea42281465bf89899bb0Browse files
1 file changed+9−2
modifiedscripts/diffinery-wait-runs.sh+9−2View file
| @@ -9,13 +9,20 @@ | ||
| 9 | 9 | # Usage: DIFFINERY=https://diffinery.com TOKEN=... diffinery-wait-runs.sh owner/repo sha [minutes] |
| 10 | 10 | set -euo pipefail |
| 11 | 11 | repo=$1 sha=$2 minutes=${3:-60} |
| 12 | -api() { curl -fsS --retry 3 "$DIFFINERY/api/v3/repos/$repo$1" -H "Authorization: Bearer $TOKEN"; } | |
| 12 | +# --retry-all-errors also retries a reset connection, which plain --retry gives up on. | |
| 13 | +api() { curl -fsS --retry 4 --retry-all-errors --retry-delay 3 "$DIFFINERY/api/v3/repos/$repo$1" -H "Authorization: Bearer $TOKEN"; } | |
| 13 | 14 | unrelated='["workflow_dispatch", "schedule", "repository_dispatch"]' |
| 14 | 15 | |
| 15 | 16 | deadline=$(( $(date +%s) + minutes * 60 )) |
| 16 | 17 | settled=0 |
| 17 | 18 | while :; do |
| 18 | - all=$(api "/actions/runs?head_sha=$sha&per_page=100") | |
| 19 | + # One failed poll (the network, a deploy in progress) is not a result: poll again. | |
| 20 | + if ! all=$(api "/actions/runs?head_sha=$sha&per_page=100"); then | |
| 21 | + echo "::warning::could not list the runs at $(date -u +%T); polling again" | |
| 22 | + [ "$(date +%s)" -lt "$deadline" ] || { echo "::error::Diffinery was unreachable at the $minutes minute limit"; exit 1; } | |
| 23 | + sleep 15 | |
| 24 | + continue | |
| 25 | + fi | |
| 19 | 26 | runs=$(jq --argjson u "$unrelated" '.workflow_runs |= map(select(.event as $e | $u | index($e) | not))' <<<"$all") |
| 20 | 27 | total=$(jq '.workflow_runs | length' <<<"$runs") |
| 21 | 28 | pending=$(jq '[.workflow_runs[] | select(.status != "completed")] | length' <<<"$runs") |