Wait for a pushed gem without rubygems-await

Merged
RO
12d ago
+95-2

Since at least v0.38.0, every release's Ruby workflow has failed after the gem published. "Create GitHub Release" then failed too, so each release page needed that workflow dispatched by hand. The step that waits for the gem to appear, rubygems-await 0.5.4 (the newest), reads the compact index through Bundler's CompactIndexClient. Bundler 4.1.0, which gem exec installs beside it, removed that class, and the fallback then asks RubyGems' cache for a method it doesn't have. So it crashes on every poll and times out after five minutes.

This replaces it with a bounded loop over what gem install and Bundler actually fetch from the public index:

  • the version's line in /info/basecamp-sdk;
  • the last /versions line for the gem carrying that file's MD5, which is how Bundler sees that its cached copy is stale. It reads the file's 2 MB tail, and the whole 25 MB file only when the tail has no line for the gem;
  • the quick gemspec that RubyGems before 4.1 installs from;
  • the .gem itself, whose sha256 has to match the v2 API's.

When this job did the push, that sha256 also has to be the gem it pushed. A run that finds the version already published may have rebuilt the gem: a full re-run does, and gem build stamps it with the time. So that run's local file isn't compared. A check that has passed isn't repeated. Each request times out after a minute, three for the full /versions, or at the ten-minute deadline if that comes first. So the step reports what was missing well inside its fifteen-minute limit. On failure it says which checks were still missing. The publish step also matches the already-pushed message with a here-string instead of a pipe.

Checks

  • Reproduced the crash locally, hours after 0.39.0 was live: gem exec rubygems-await basecamp-sdk-0.39.0.gem crashes the same way and times out.
  • Ran the step's own script, parsed out of the YAML, under the runner's bash -e -o pipefail:
CaseResult
0.39.0, pushed, the real gempasses
0.39.0, pushed, a different gemfails at once, naming both sha256s
0.39.0, re-run, a different gempasses
never publishedfails after the timeout, saying what's missing
/versions checksum doesn't match /infofails after the timeout
quick gemspec missingfails after the timeout
.gem not downloadablefails after the timeout
a server that accepts the connection and never answersends after the request's one-minute limit
/versions tail without the gem's linefalls back to the full file once and passes
the same with the fallback removedfails, the control for the row above
that fallback, with the gemspec missing for 40 s4 polls, 1 full /versions download
  • actionlint passes, and CI passes.
  • Adversarial review, run locally on this worktree with pi openai-codex/gpt-6.1-sol (thinking high), one pass per head. Each finding was fixed in the next head:
    • Round 1 (60862e98): the .gem download wasn't checked, requests had no time limit, grep -q on a curl pipe under pipefail, and the stated cause was wrong.
    • Round 2 (b68ab01e): /versions wasn't checked, the quick gemspec wasn't checked, and the publish step piped its output into grep -q. While fixing these I found and fixed a silent exit when the /versions tail had no line for the gem.
    • Round 3 (dd8e41c0): a re-run long after a release fetched the full /versions on every poll, and two sentences overstated things.
    • Round 4 (3427f28e): no functional defect, only two overstated sentences, reworded in dadc7411.
    • Copilot on dadc7411: a poll starting near the ten-minute mark could run its requests long enough for the fifteen-minute step limit to kill it before the message. 696fe5e2 caps every request to the time left, so no request starts after the deadline.
    • Round 5 (696fe5e2): no functional defect. The worst case is about 615 s from the start of the wait to the message, inside the 900 s step limit. It flagged one sentence as more precise than a whole-second clock allows, reworded in 58d7e619. This head, 3f3f35a1, only changes "Bundler 4.1" to "Bundler 4.1.0" in the comment and commit message.
  • A real release is the only end-to-end test, since publishing needs a tag.

Card: Ruby SDK release workflow fails after a successful gem push