Skip to content
Merged
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
34 changes: 34 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,46 @@ jobs:
test -n "$VERSION"
test "$(mergify --version | awk '{print $NF}')" = "$VERSION"

test-install-retry:
timeout-minutes: 5
runs-on: ubuntu-26.04
steps:
- name: Checkout 🛎️
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0

- name: Point raw.githubusercontent.com at an address that never answers
run: |
# 192.0.2.1 is reserved for documentation (RFC 5737): a connection
# to it hangs, so the first download of install.sh times out.
echo "192.0.2.1 raw.githubusercontent.com" | sudo tee -a /etc/hosts
# Restore the name once curl is seen connecting to the dead address,
# so the install can only succeed on a later attempt.
restore_after_first_attempt() {
until ss -tnH state syn-sent dst 192.0.2.1 | grep -q .; do sleep 0.2; done
sudo sed -i "/raw.githubusercontent.com/d" /etc/hosts
date -u +%T > "$RUNNER_TEMP/first-attempt-hung"
}
restore_after_first_attempt > /dev/null 2>&1 &

- name: Install mergify-cli
id: install
uses: ./

- name: Assert the install succeeded on a retry
env:
VERSION: ${{ steps.install.outputs.mergify_cli_version }}
run: |
test -f "$RUNNER_TEMP/first-attempt-hung"
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"

all-greens:
if: ${{ !cancelled() }}
needs:
- linters
- autodoc
- test-install
- test-install-retry
runs-on: ubuntu-26.04
steps:
- name: Verify all jobs succeeded
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ GitHub Action to install the [Mergify CLI](https://github.com/Mergifyio/mergify-
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 then puts the binary on
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.
Expand Down
18 changes: 16 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,22 @@ runs:
# install.sh supports Linux and macOS only.
tmp=$(mktemp -d)
trap 'rm -rf "${tmp}"' EXIT
curl -fsSL "https://raw.githubusercontent.com/${REPO}/${ref}/install.sh" -o "${tmp}/install.sh" \
|| die "failed to fetch install.sh (ref ${ref})"
url="https://raw.githubusercontent.com/${REPO}/${ref}/install.sh"
# raw.githubusercontent.com answers a 503 or a 504 now and then: retry
# those and timeouts the way install.sh retries its own downloads, the
# wait doubling from one second. The two timeouts make a stalled
# connection or answer a retried timeout, and --retry-max-time stops
# the retries after five minutes, even when a Retry-After header asks
# for longer. A 404 fails at once. curl 8.14 exits 0 on an error it
# does not retry, such as that 404, so the status code is checked too.
if ! status=$(curl -fsSL --retry 8 --retry-max-time 300 --connect-timeout 10 --max-time 30 \
-w '%{http_code}' -o "${tmp}/install.sh" "${url}") || [ "${status}" != 200 ]; then
# On main, a 404 is not the input's fault.
if [ "${status}" = 404 ] && [ "${ref}" != main ]; then
die "${url} does not exist: mergify_cli_version ${ref} is not a mergify-cli release that ships install.sh"
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"

# Expose the binary to later steps and read the version back from it
Expand Down
Loading