Skip to content

Commit 8e90f85

Browse files
Copilotpelikhan
andcommitted
Fix install script with retry logic and remove macOS-13
- Add retry logic with exponential backoff (3 attempts, 2s/4s/8s delays) to handle transient download failures like 503 errors - Remove macOS-13 from test matrix as requested - Update test script to verify retry logic implementation Fixes: https://github.com/githubnext/gh-aw/actions/runs/20135912025/job/57790530332 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
1 parent 33e53fe commit 8e90f85

3 files changed

Lines changed: 48 additions & 9 deletions

File tree

.github/workflows/install.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ jobs:
2727
- ubuntu-latest
2828
- ubuntu-22.04
2929
- macos-latest
30-
- macos-13 # Intel-based macOS
3130
- windows-latest
3231
steps:
3332
- name: Checkout code

install-gh-aw.sh

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,27 @@ if [ -f "$BINARY_PATH" ]; then
196196
print_warning "Binary '$BINARY_PATH' already exists. It will be overwritten."
197197
fi
198198

199-
# Download the binary
199+
# Download the binary with retry logic
200200
print_info "Downloading gh-aw binary..."
201-
if curl -L -f -o "$BINARY_PATH" "$DOWNLOAD_URL"; then
202-
print_success "Binary downloaded successfully"
203-
else
204-
print_error "Failed to download binary from $DOWNLOAD_URL"
205-
print_info "Please check if the version and platform combination exists in the releases."
206-
exit 1
207-
fi
201+
MAX_RETRIES=3
202+
RETRY_DELAY=2
203+
204+
for attempt in $(seq 1 $MAX_RETRIES); do
205+
if curl -L -f -o "$BINARY_PATH" "$DOWNLOAD_URL"; then
206+
print_success "Binary downloaded successfully"
207+
break
208+
else
209+
if [ $attempt -eq $MAX_RETRIES ]; then
210+
print_error "Failed to download binary from $DOWNLOAD_URL after $MAX_RETRIES attempts"
211+
print_info "Please check if the version and platform combination exists in the releases."
212+
exit 1
213+
else
214+
print_warning "Download attempt $attempt failed. Retrying in ${RETRY_DELAY}s..."
215+
sleep $RETRY_DELAY
216+
RETRY_DELAY=$((RETRY_DELAY * 2))
217+
fi
218+
fi
219+
done
208220

209221
# Make it executable
210222
print_info "Making binary executable..."

scripts/test-install-script.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,5 +232,33 @@ else
232232
exit 1
233233
fi
234234

235+
# Test 9: Verify retry logic for downloads
236+
echo ""
237+
echo "Test 9: Verify download retry logic"
238+
239+
# Check for MAX_RETRIES variable
240+
if grep -q "MAX_RETRIES=" "$PROJECT_ROOT/install-gh-aw.sh"; then
241+
echo " ✓ PASS: MAX_RETRIES variable exists"
242+
else
243+
echo " ✗ FAIL: MAX_RETRIES variable not found"
244+
exit 1
245+
fi
246+
247+
# Check for retry loop
248+
if grep -q "for attempt in" "$PROJECT_ROOT/install-gh-aw.sh"; then
249+
echo " ✓ PASS: Retry loop exists"
250+
else
251+
echo " ✗ FAIL: Retry loop not found"
252+
exit 1
253+
fi
254+
255+
# Check for exponential backoff
256+
if grep -q "RETRY_DELAY=\$((RETRY_DELAY \* 2))" "$PROJECT_ROOT/install-gh-aw.sh"; then
257+
echo " ✓ PASS: Exponential backoff implemented"
258+
else
259+
echo " ✗ FAIL: Exponential backoff not found"
260+
exit 1
261+
fi
262+
235263
echo ""
236264
echo "=== All tests passed ==="

0 commit comments

Comments
 (0)