From 435fc988d07a2c6ddc0d6ec568d8081ccd9916d7 Mon Sep 17 00:00:00 2001 From: Mehdi ABAAKOUK Date: Tue, 1 Dec 2026 11:55:56 +0100 Subject: [PATCH] fix: run install.sh again when a release download fails on a status curl does not retry On 2026-12-01 GitHub answered about one in ten downloads of the mergify-cli release tarball with a 618. install.sh's `curl --retry` retries timeouts and 408, 429, 500, 502, 503 and 504 answers only, so each 618 failed the step, and the job with it, on the first request. The action's own retry of its install.sh fetch does not reach the downloads install.sh makes. The action now runs install.sh again when it fails, waiting 10, 20 then 40 seconds, four tries in all. That covers every `mergify_cli_version`: the action fetches install.sh at the pinned version's tag, so a fix in install.sh would only reach the versions released after it. It also covers the other failures curl does not retry: a refused or reset connection, a TLS error, a download cut short that fails the checksum. Each failed try leaves a warning naming it, and once the tries run out the step fails below install.sh's own errors. A try that failed after two minutes or more is not run again. A failure that late comes after curl's own retries of a server error, which last four to five minutes per download, and another try would add as many minutes again to a job whose timeout may be sized for one. A failure that is not transient, such as a platform with no published binary, now takes 70 seconds longer to fail. The new test-install-rerun job points install.sh at a local server through its MERGIFY_BASE_URL. The server answers 618 to every tarball request under one path, where the install must fail after four tries, and to the first one under another, where it must recover. It redirects every other request to the release on GitHub. The job installs mergify-cli 2026.11.26 and Renovate does not bump it: its install.sh makes a single request on a 618, where a later one that retries the 618 itself would leave the re-run untested. Nothing is released on merge: release.yaml releases on its own only when the default mergify-cli version changes, so this ships in the release that the next mergify-cli bump cuts. Related to MRGFY-14054 Co-Authored-By: Claude Opus 5.5 Change-Id: I7e6ba77f3010eded84e03dd26295c427b8db7313 --- .github/workflows/ci.yaml | 70 +++++++++++++++++++++++++++++++++++++++ README.md | 10 +++--- action.yml | 27 ++++++++++++++- 3 files changed, 102 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1784c5a..a054788 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -149,6 +149,75 @@ jobs: echo "First attempt hung on 192.0.2.1, name restored at $(cat "$RUNNER_TEMP/first-attempt-hung") UTC" test "$(mergify --version | awk '{print $NF}')" = "$VERSION" + test-install-rerun: + timeout-minutes: 10 + runs-on: ubuntu-26.04 + env: + # A mergify-cli release whose install.sh makes a single request on a + # 618, so that only the action's re-run can recover from it. Out of + # Renovate's reach on purpose: an install.sh that retries the 618 itself + # would leave the re-run untested. + CLI_VERSION: 2026.11.26 + steps: + - name: Checkout 🛎️ + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Serve the release through a server that answers 618 + run: | + # install.sh downloads the release from MERGIFY_BASE_URL when it is + # set. This server answers 618, a status curl --retry does not + # retry, to the first request for each tarball and to every request + # under /always-618/, and redirects the others to the release on + # GitHub. + python3 - > "$RUNNER_TEMP/server.log" 2>&1 <<'EOF' & + import http.server + seen = set() + class Handler(http.server.BaseHTTPRequestHandler): + def do_GET(self): + if self.path.startswith("/always-618/") or ( + self.path.endswith(".tar.gz") and self.path not in seen + ): + seen.add(self.path) + self.send_error(618) + return + self.send_response(302) + self.send_header("Location", "https://github.com/Mergifyio/mergify-cli/releases/download" + self.path) + self.end_headers() + http.server.HTTPServer(("127.0.0.1", 8618), Handler).serve_forever() + EOF + curl -sS --retry 10 --retry-connrefused --retry-delay 1 -o /dev/null http://127.0.0.1:8618/ + + - name: Install mergify-cli when every release download answers 618 + id: gives-up + continue-on-error: true + uses: ./ + env: + MERGIFY_BASE_URL: http://127.0.0.1:8618/always-618/${{ env.CLI_VERSION }} + with: + mergify_cli_version: ${{ env.CLI_VERSION }} + + - name: Install mergify-cli when the first release download answers 618 + id: install + uses: ./ + env: + MERGIFY_BASE_URL: http://127.0.0.1:8618/${{ env.CLI_VERSION }} + with: + mergify_cli_version: ${{ env.CLI_VERSION }} + + - name: Assert the installs gave up after four tries, and recovered from one 618 + env: + GAVE_UP: ${{ steps.gives-up.outcome }} + VERSION: ${{ steps.install.outputs.mergify_cli_version }} + run: | + log="$RUNNER_TEMP/server.log" + cat "$log" + test "$GAVE_UP" = failure + test "$(grep -c "GET /always-618/$CLI_VERSION/[^ ]*\.tar\.gz HTTP/1\.1\" 618" "$log")" = 4 + test "$(grep -c "GET /$CLI_VERSION/[^ ]*\.tar\.gz HTTP/1\.1\" 618" "$log")" = 1 + grep -q "GET /$CLI_VERSION/[^ ]*\.tar\.gz HTTP/1\.1\" 302" "$log" + test "$VERSION" = "$CLI_VERSION" + test "$(mergify --version | awk '{print $NF}')" = "$VERSION" + all-greens: if: ${{ !cancelled() }} needs: @@ -156,6 +225,7 @@ jobs: - autodoc - test-install - test-install-retry + - test-install-rerun runs-on: ubuntu-26.04 steps: - name: Verify all jobs succeeded diff --git a/README.md b/README.md index 7097812..234ade8 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,12 @@ It installs the prebuilt `mergify` binary via the mergify-cli `install.sh` installer, which downloads the binary from the GitHub release and verifies it against the release `SHA256SUMS`. For a pinned version the installer is fetched from that release tag; `latest` uses `main`. The action retries that fetch on -timeouts and server errors for up to five minutes. It then puts the binary on -`PATH` and exposes the installed version as an output. Pinned by default, -`latest` supported. No Python or toolchain is required; Linux and macOS are -supported. +timeouts and server errors for up to five minutes. When the installer fails +within two minutes, as it does when a release download answers a status curl +does not retry, the action runs it again, up to four tries in all. It then +puts the binary on `PATH` and exposes the installed version as an output. +Pinned by default, `latest` supported. No Python or toolchain is required; +Linux and macOS are supported. More information on https://mergify.com diff --git a/action.yml b/action.yml index ad907d6..af5c8cf 100644 --- a/action.yml +++ b/action.yml @@ -67,7 +67,32 @@ runs: fi die "could not download ${url}, see the curl error above" fi - MERGIFY_VERSION="${MERGIFY_CLI_VERSION}" MERGIFY_INSTALL_DIR="${bindir}" sh "${tmp}/install.sh" + + # install.sh's curl retries timeouts and the usual server errors for + # minutes, but makes a single request on a status it does not know, + # such as the 618 that GitHub's release downloads answer now and then. + # install.sh then fails at once, on the download or, with curl 8.14, + # at its checksum. Run it again after such a failure, waiting 10, 20 + # then 40 seconds. A try that failed after two minutes or more went + # through curl's own retries, and another would only add as many + # minutes again: give up. + tries=4 + delay=10 + try=1 + start=${SECONDS} + until MERGIFY_VERSION="${MERGIFY_CLI_VERSION}" MERGIFY_INSTALL_DIR="${bindir}" sh "${tmp}/install.sh"; do + took=$((SECONDS - start)) + if [ "${try}" -ge "${tries}" ]; then + die "install.sh failed ${tries} times, see its errors above" + elif [ "${took}" -ge 120 ]; then + die "install.sh failed after ${took} s on try ${try} of ${tries}, too long to run it again, see its errors above" + fi + echo "::warning::install.sh failed on try ${try} of ${tries}, running it again in ${delay} s" + sleep "${delay}" + try=$((try + 1)) + delay=$((delay * 2)) + start=${SECONDS} + done # Expose the binary to later steps and read the version back from it # (the binary reports its real version) for the action output.