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
18 changes: 14 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@ jobs:
shell: bash
env:
BUNDLER_TEST_VERSION: ${{ matrix.bundler }}
run: gem install bundler -v "$BUNDLER_TEST_VERSION" --no-document
run: scripts/gem-install-retry.sh bundler -v "$BUNDLER_TEST_VERSION" --no-document

# Installing a bundler does not make `bundle` run it: with no lockfile
# to read, RubyGems' binstub activates the HIGHEST installed bundler,
Expand Down Expand Up @@ -2847,11 +2847,21 @@ jobs:
uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
with:
ruby-version: '3.2.10'
# The gem hosted rewrite pins into the Gemfile.lock CHECKSUMS
# section, which `bundle lock --add-checksums` only emits on >= 2.6.
bundler: '2.6'
# Bundler comes from the next step, which retries rubygems.org
# blips; setup-ruby's own install is a single bare `gem install`.
bundler: 'none'
bundler-cache: false

- name: Install Bundler
if: steps.gate.outputs.run == 'true'
# The gem hosted rewrite pins into the Gemfile.lock CHECKSUMS
# section, which `bundle lock --add-checksums` only emits on >= 2.6.
# `~> 2.6.0` is what setup-ruby's `bundler: '2.6'` installed; as the
# highest installed bundler it is the one `bundle` runs.
run: |
scripts/gem-install-retry.sh bundler -v '~> 2.6.0' --no-document
bundle --version

- name: Setup Go
if: steps.gate.outputs.run == 'true'
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
Expand Down
31 changes: 31 additions & 0 deletions scripts/gem-install-retry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# `gem install` that survives a rubygems.org connection blip.
#
# scripts/gem-install-retry.sh <gem install args...>
#
# RubyGems has no retry of its own: one failed TCP connect to rubygems.org
# ("SocketError: Failed to open TCP connection to rubygems.org:443") aborts
# the install at once. ruby/setup-ruby's `bundler:` input runs exactly such
# a bare `gem install bundler`, and one blip there evicted a merge-queue
# entry in hosted-e2e, so the CI bundler installs go through here: up to 4
# attempts with a growing pause. The args are passed through unchanged, so
# a pinned `-v X.Y.Z` stays pinned.
set -euo pipefail

if [ "$#" -eq 0 ]; then
echo "usage: $0 <gem install args...>" >&2
exit 2
fi

attempts=4
for attempt in $(seq 1 "$attempts"); do
if gem install "$@"; then
exit 0
fi
if [ "$attempt" = "$attempts" ]; then
echo "::error::gem install $* failed on all $attempts attempts"
exit 1
fi
echo "::warning::gem install $* attempt $attempt failed; retrying"
sleep $((attempt * 10))
done
Loading