Skip to content

Commit c8e26f6

Browse files
Retry CI bundler installs on rubygems blips (#1828)
ruby/setup-ruby's `bundler:` input installs bundler with one bare `gem install`, and RubyGems has no retry of its own. A single failed TCP connect to rubygems.org in hosted-e2e's Setup Ruby step failed the merge_group run for #1813 and evicted it from the queue. Install bundler in hosted-e2e through a new gem-install-retry.sh (the pip-install-retry.sh pattern: 4 attempts, growing pause) instead, with the same `~> 2.6.0` requirement setup-ruby used, and route the e2e job's Bundler 1.x install through it too. Claude-Session: https://claude.ai/code/session_011f9aeTA3DTuUZTYGYzv6KB Co-authored-by: Claude <noreply@anthropic.com>
1 parent c07af61 commit c8e26f6

2 files changed

Lines changed: 45 additions & 4 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,7 +1610,7 @@ jobs:
16101610
shell: bash
16111611
env:
16121612
BUNDLER_TEST_VERSION: ${{ matrix.bundler }}
1613-
run: gem install bundler -v "$BUNDLER_TEST_VERSION" --no-document
1613+
run: scripts/gem-install-retry.sh bundler -v "$BUNDLER_TEST_VERSION" --no-document
16141614

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

2855+
- name: Install Bundler
2856+
if: steps.gate.outputs.run == 'true'
2857+
# The gem hosted rewrite pins into the Gemfile.lock CHECKSUMS
2858+
# section, which `bundle lock --add-checksums` only emits on >= 2.6.
2859+
# `~> 2.6.0` is what setup-ruby's `bundler: '2.6'` installed; as the
2860+
# highest installed bundler it is the one `bundle` runs.
2861+
run: |
2862+
scripts/gem-install-retry.sh bundler -v '~> 2.6.0' --no-document
2863+
bundle --version
2864+
28552865
- name: Setup Go
28562866
if: steps.gate.outputs.run == 'true'
28572867
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0

‎scripts/gem-install-retry.sh‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
# `gem install` that survives a rubygems.org connection blip.
3+
#
4+
# scripts/gem-install-retry.sh <gem install args...>
5+
#
6+
# RubyGems has no retry of its own: one failed TCP connect to rubygems.org
7+
# ("SocketError: Failed to open TCP connection to rubygems.org:443") aborts
8+
# the install at once. ruby/setup-ruby's `bundler:` input runs exactly such
9+
# a bare `gem install bundler`, and one blip there evicted a merge-queue
10+
# entry in hosted-e2e, so the CI bundler installs go through here: up to 4
11+
# attempts with a growing pause. The args are passed through unchanged, so
12+
# a pinned `-v X.Y.Z` stays pinned.
13+
set -euo pipefail
14+
15+
if [ "$#" -eq 0 ]; then
16+
echo "usage: $0 <gem install args...>" >&2
17+
exit 2
18+
fi
19+
20+
attempts=4
21+
for attempt in $(seq 1 "$attempts"); do
22+
if gem install "$@"; then
23+
exit 0
24+
fi
25+
if [ "$attempt" = "$attempts" ]; then
26+
echo "::error::gem install $* failed on all $attempts attempts"
27+
exit 1
28+
fi
29+
echo "::warning::gem install $* attempt $attempt failed; retrying"
30+
sleep $((attempt * 10))
31+
done

0 commit comments

Comments
 (0)