Skip to content

PAYMENTS-12054 Fix the CI bundler cache and the puma spec port collisions - #46

Merged
WillemHoman merged 5 commits into
mainfrom
PAYMENTS-12054-ci-and-spec-hygiene
Aug 12, 2026
Merged

PAYMENTS-12054 Fix the CI bundler cache and the puma spec port collisions#46
WillemHoman merged 5 commits into
mainfrom
PAYMENTS-12054-ci-and-spec-hygiene

Conversation

@WillemHoman

@WillemHoman WillemHoman commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Jira: PAYMENTS-12054

N.B. no Changelog updates as will have a release with #45

What? Why?

Fixes

1. restore_cache has been failing on every job of every build

template: cacheKey:1:24: executing "cacheKey" at <checksum "Gemfile.lock">:
error calling checksum: open /home/circleci/repo/Gemfile.lock: no such file or directory
error computing cache key

orbs/internal-ruby.yml builds its key as <cache_key>-{{ arch }}-{{ checksum <checksumfile> }}, and checksumfile
defaults to Gemfile.lock.

This repo ships no lockfile, it is gitignored so it always resulted in a cache miss.
The Gemfile is the stable file that does exist so it is used as the checksumfile.
Reduces the build by ~ 5 mins.

2. The puma specs collide on ports

default_port was 9800 + rand(100)

require 'spec_helper'

describe Bigcommerce::Prometheus::Servers::Puma::Server do
  let(:server) { described_class.new(port: default_port) }
  let(:default_port) { 9800 + rand(100) }

Constructing the server binds a real listener.
Three examples use it, so they collide about 3% of the time, raising an Errno::EADDRINUSE.

  1. Bind ephemeral: Port 0 asks the kernel for a free port so two live listeners cannot share one.
  2. Close on teardown: closes the port on spec teardown.

How was it tested?

CI


Note

Low Risk
CI and test-only changes with no production runtime behavior; low risk aside from verifying cache keys still isolate Ruby versions correctly.

Overview
Fixes CircleCI bundler cache restore failures and intermittent Puma server spec port collisions.

CI: Sets shared checksumfile: Gemfile (this repo has no committed Gemfile.lock) and distinct cache_key values per Ruby job (gem-cache-ruby-3_3, 3_4, 4_0) so the internal-ruby orb can compute cache keys without error and restore gems reliably.

Specs: Puma Server examples now bind port 0 for ephemeral listeners instead of 9800 + rand(100), track started servers, and close binders in an after hook. The configured-port example probes a free port via TCPServer on port 0 so assertions still target a known port without colliding with other examples.

Reviewed by Cursor Bugbot for commit 31bef9f. Bugbot is set up for automated code reviews on this repo. Configure here.

@WillemHoman
WillemHoman force-pushed the PAYMENTS-12054-ci-and-spec-hygiene branch from 5f4d810 to 60cade6 Compare August 10, 2026 10:25
…each example

Bind the puma server specs to an ephemeral port
@WillemHoman
WillemHoman force-pushed the PAYMENTS-12054-ci-and-spec-hygiene branch from 60cade6 to 8e52431 Compare August 10, 2026 11:08
@WillemHoman
WillemHoman force-pushed the PAYMENTS-12054-ci-and-spec-hygiene branch from 8e52431 to 421c05a Compare August 10, 2026 11:11
@WillemHoman
WillemHoman marked this pull request as ready for review August 10, 2026 11:12
@WillemHoman
WillemHoman requested a review from a team as a code owner August 10, 2026 11:12
@WillemHoman
WillemHoman requested a review from j05h August 10, 2026 11:15
Comment thread spec/bigcommerce/prometheus/servers/puma/server_spec.rb Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6dc0ac3. Configure here.

Comment thread spec/bigcommerce/prometheus/servers/puma/server_spec.rb Outdated
Willem Homan added 2 commits August 11, 2026 13:25
…rt in the spec, ask the kernel for a free port and use it to eliminate the chance of collisions
@WillemHoman
WillemHoman merged commit 12bcdc7 into main Aug 12, 2026
10 checks passed
@WillemHoman
WillemHoman deleted the PAYMENTS-12054-ci-and-spec-hygiene branch August 12, 2026 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants