Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,83 @@ 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:
- linters
- autodoc
- test-install
- test-install-retry
- test-install-rerun
runs-on: ubuntu-26.04
steps:
- name: Verify all jobs succeeded
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
27 changes: 26 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading