From 1c750349577da856374f0982986b561b64c05915 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Sun, 14 Jun 2026 21:17:59 +0200 Subject: [PATCH] ci(smoke): retry transient GitHub download failures The first-boot smoke test and install.sh fetched the released binary with a single curl attempt, so a transient GitHub/CDN 504 failed the whole job. - smoke-firstboot.sh: add --retry/--retry-all-errors with connect/max timeouts to the version API and tarball downloads, split the download into a guarded step, and assert the tarball is non-empty. - install.sh: add --retry plus connect/max timeouts to the release-binary downloads and version lookups. Omit --retry-all-errors here for curl < 7.71 (Ubuntu 20.04 / Debian 10 / CentOS 7) compatibility; plain --retry already covers 504 and other transient errors. --- deploy/test/smoke-firstboot.sh | 17 ++++++++++++++--- install.sh | 8 ++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/deploy/test/smoke-firstboot.sh b/deploy/test/smoke-firstboot.sh index 4755addd9..9fb103782 100644 --- a/deploy/test/smoke-firstboot.sh +++ b/deploy/test/smoke-firstboot.sh @@ -32,11 +32,22 @@ docker run --rm \ REPO=MHSanaei/3x-ui ARCH=$(dpkg --print-architecture) # amd64 | arm64 echo "container arch: $ARCH" - VER=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | jq -r .tag_name) + VER=$(curl --fail --location --silent --show-error \ + --retry 5 --retry-all-errors --retry-delay 3 \ + --connect-timeout 15 --max-time 60 \ + "https://api.github.com/repos/${REPO}/releases/latest" | jq -r .tag_name) [ -n "$VER" ] && [ "$VER" != "null" ] || { echo "FAIL: cannot resolve version"; exit 1; } tmp=$(mktemp -d) - curl -fL4 -o "${tmp}/x.tar.gz" \ - "https://github.com/${REPO}/releases/download/${VER}/x-ui-linux-${ARCH}.tar.gz" + # 504s and other transient GitHub/CDN hiccups are retried; a real HTTP + # failure (e.g. missing arch asset) still aborts after the retries. + if ! curl -4 --fail --location --silent --show-error \ + --retry 5 --retry-all-errors --retry-delay 3 \ + --connect-timeout 15 --max-time 300 \ + -o "${tmp}/x.tar.gz" \ + "https://github.com/${REPO}/releases/download/${VER}/x-ui-linux-${ARCH}.tar.gz"; then + echo "FAIL: cannot download x-ui-linux-${ARCH}.tar.gz (${VER})" >&2; exit 1 + fi + test -s "${tmp}/x.tar.gz" || { echo "FAIL: downloaded tarball is empty"; exit 1; } tar -xzf "${tmp}/x.tar.gz" -C /usr/local/ chmod +x /usr/local/x-ui/x-ui install -m 755 /root/x-ui-firstboot.sh /usr/local/x-ui/x-ui-firstboot.sh diff --git a/install.sh b/install.sh index 5eb097835..620b7897c 100644 --- a/install.sh +++ b/install.sh @@ -1305,17 +1305,17 @@ install_x-ui() { # Download resources if [ $# == 0 ]; then - tag_version=$(curl -Ls "https://api.github.com/repos/MHSanaei/3x-ui/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') + tag_version=$(curl -Ls --retry 5 --retry-delay 3 --connect-timeout 15 --max-time 60 "https://api.github.com/repos/MHSanaei/3x-ui/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') if [[ ! -n "$tag_version" ]]; then echo -e "${yellow}Trying to fetch version with IPv4...${plain}" - tag_version=$(curl -4 -Ls "https://api.github.com/repos/MHSanaei/3x-ui/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') + tag_version=$(curl -4 -Ls --retry 5 --retry-delay 3 --connect-timeout 15 --max-time 60 "https://api.github.com/repos/MHSanaei/3x-ui/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') if [[ ! -n "$tag_version" ]]; then echo -e "${red}Failed to fetch x-ui version, it may be due to GitHub API restrictions, please try it later${plain}" exit 1 fi fi echo -e "Got x-ui latest version: ${tag_version}, beginning the installation..." - curl -4fLRo ${xui_folder}-linux-$(arch).tar.gz https://github.com/MHSanaei/3x-ui/releases/download/${tag_version}/x-ui-linux-$(arch).tar.gz + curl -4fLR --retry 5 --retry-delay 3 --connect-timeout 15 --max-time 300 -o ${xui_folder}-linux-$(arch).tar.gz https://github.com/MHSanaei/3x-ui/releases/download/${tag_version}/x-ui-linux-$(arch).tar.gz if [[ $? -ne 0 ]]; then echo -e "${red}Downloading x-ui failed, please be sure that your server can access GitHub ${plain}" exit 1 @@ -1332,7 +1332,7 @@ install_x-ui() { url="https://github.com/MHSanaei/3x-ui/releases/download/${tag_version}/x-ui-linux-$(arch).tar.gz" echo -e "Beginning to install x-ui $1" - curl -4fLRo ${xui_folder}-linux-$(arch).tar.gz ${url} + curl -4fLR --retry 5 --retry-delay 3 --connect-timeout 15 --max-time 300 -o ${xui_folder}-linux-$(arch).tar.gz ${url} if [[ $? -ne 0 ]]; then echo -e "${red}Download x-ui $1 failed, please check if the version exists ${plain}" exit 1