Skip to content

Commit 1dd79e3

Browse files
Merge pull request #47 from Expensify/Rory-BetterErrorReportingForFailedDownloads
Surface better errors with failed downloads
2 parents 0809f7c + e0354d8 commit 1dd79e3

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

scripts/actionlint.sh

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,37 @@ else
6060
info "Downloading and verifying actionlint verion $EXPECTED_VERSION..." >&2
6161

6262
readonly TARBALL="$SCRIPT_DIR/actionlint.tar.gz"
63-
if ! curl -sL "https://github.com/rhysd/actionlint/releases/download/v${EXPECTED_VERSION}/${TARBALL_NAME}" -o "$TARBALL"; then
64-
error "Unable to download actionlint binary"
65-
exit 1
63+
64+
# --fail: Makes curl return error on HTTP errors (4xx, 5xx)
65+
# --location: Follow redirects
66+
# --retry: Retry on transient errors
67+
# --retry-delay: Wait between retry attempts
68+
curl --fail --location \
69+
--retry 3 \
70+
--retry-delay 3 \
71+
"https://github.com/rhysd/actionlint/releases/download/v${EXPECTED_VERSION}/${TARBALL_NAME}" \
72+
--output "$TARBALL"
73+
CURL_EXIT=$?
74+
75+
if [[ $CURL_EXIT -ne 0 ]]; then
76+
case $CURL_EXIT in
77+
18)
78+
error "Download failed: partial file transfer (network interrupted)" >&2
79+
;;
80+
22)
81+
error "Download failed: HTTP error from GitHub" >&2
82+
;;
83+
28)
84+
error "Download failed: operation timeout" >&2
85+
;;
86+
56)
87+
error "Download failed: network connection issue" >&2
88+
;;
89+
*)
90+
error "Download failed with curl exit code $CURL_EXIT" >&2
91+
;;
92+
esac
93+
exit "$CURL_EXIT"
6694
fi
6795

6896
# Ensure tarball is cleaned up

0 commit comments

Comments
 (0)