Skip to content

chore(DODO-5263): upgrade Ruby from 3.2.3 to 3.4.8#168

Open
fbriand-docto wants to merge 31 commits intomasterfrom
chore/upgrade-ruby-3.4
Open

chore(DODO-5263): upgrade Ruby from 3.2.3 to 3.4.8#168
fbriand-docto wants to merge 31 commits intomasterfrom
chore/upgrade-ruby-3.4

Conversation

@fbriand-docto
Copy link
Copy Markdown
Member

@fbriand-docto fbriand-docto commented Apr 2, 2026

Why

Ruby 3.2 reached end-of-life in March 2026. This upgrades safe-pg-migrations to require Ruby >= 3.4, hence the major version bump to 5.0.0.

How

  • Bumped .ruby-version to 3.4.8, required_ruby_version to >= 3.4, and gem version to 5.0.0
  • Bumped activerecord / activesupport to >= 7.1 and dropped AR 6.1 / 7.0 gemfiles: both are long EOL and untested against Ruby 3.4
  • Migrated tests from Minitest::Mock / Object#stub to mocha: minitest 6 removed these entirely
  • Removed explicit minitest from Gemfile: transitive dependency of activesupport
  • Fixed .rubocop.yml: renamed Metrics/LineLengthLayout/LineLength, updated TargetRubyVersion to 3.4; disabled new cops from rubocop 1.86 unrelated to the upgrade (to address in a separate PR)
  • Updated CI matrix: Ruby 3.4, PG 12.14 and 15.3; dropped PG 11 (strong_migrations 2.x dropped it)
  • Kept ruby/setup-ruby@v1: doctolib/actions/setup-ruby is a private action, inaccessible from this public repo

Evidence of Testing

CI green on PG 12.14 and 15.3.


This pull request was created with AI assistance.

Bumps Ruby version to 3.4.8 for EOL compliance (Ruby 3.2 EOL March 2026).
Updates CI matrix to test Ruby 3.3 and 3.4, replaces ruby/setup-ruby with
doctolib/actions/setup-ruby (official distribution channel compliance).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@fbriand-docto fbriand-docto added ai-augmented PR has been augmented by AI review:size-s Small PR (<100 lines changed) labels Apr 2, 2026
@fbriand-docto fbriand-docto changed the title chore: upgrade Ruby from 3.2.3 to 3.4.8 chore(DODO-5263): upgrade Ruby from 3.2.3 to 3.4.8 Apr 2, 2026
@fbriand-docto fbriand-docto self-assigned this Apr 2, 2026
…-ruby

doctolib/actions is a private repo, inaccessible from public repo CI.
ruby/setup-ruby is the correct action for public repositories.
Also pins to v1.299.0 SHA for supply chain security.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@fbriand-docto fbriand-docto marked this pull request as ready for review April 2, 2026 12:47
@fbriand-docto fbriand-docto requested a review from a team as a code owner April 2, 2026 12:47
@fbriand-docto
Copy link
Copy Markdown
Member Author

/test

fbriand-docto and others added 11 commits April 2, 2026 14:57
SHA-pinned ruby/setup-ruby was causing startup_failure. Revert to
the original action references (@v1, @V3), only changing Ruby versions
in the matrix (3.1→3.3/3.4) and legacy tests (3.0→3.3).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…change

Ruby 3.4 changed Hash#inspect to use {key: val} instead of {:key=>val}.
Add normalize_for_ruby34 helper to test_helper and apply it to all
assertions comparing migration output strings containing hash options.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…t in test assertions

Ruby 3.4 changed Hash#inspect output from {:key=>val} to {key: val}.
Update all hardcoded expected strings in tests to use the new format.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Unit tests assert on Hash#inspect output which changed in 3.4.
Keep 3.3 only in legacy AR tests (no format-sensitive assertions there).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sed corrupted the file during normalize_for_ruby34 removal.
Restored with correct content and updated hash format strings.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… AR tests

- require minitest/mock explicitly in test_helper (was auto-required by
  mocha 2.0.4 in main Gemfile.lock, but legacy gemfiles install latest
  mocha which no longer auto-requires it)
- switch legacy-activerecord-test matrix from Ruby 3.3 to 3.4 to match
  the hash inspect format used in updated test assertions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
minitest 6 (installed by '>= 5' with no lockfile) reorganized its file
structure and removed minitest/mock as a standalone require path. Pin
to ~> 5 to keep behavior consistent with the main Gemfile.lock which
pins minitest 5.18.1.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add gem 'mutex_m' to activerecord61.gemfile: mutex_m was removed from
  Ruby stdlib in 3.4 and is now a standalone gem; AR 6.1 uses it but
  doesn't declare the dependency
- Update test_helper to handle AR 8.0+: SchemaMigration.new now takes a
  connection pool instead of a connection adapter (API changed in AR 8.0)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…mfile

- Add gem 'base64': like mutex_m, base64 was removed from Ruby stdlib
  in 3.4 and AR 6.1 depends on it without declaring it
- Move mutex_m after mocha to satisfy Bundler/OrderedGems rubocop rule

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
AR 6.1 is EOL (Jun 2023) and incompatible with Ruby 3.4 stdlib changes.
Replace with AR 7.1 which natively supports Ruby 3.4 and matches the
version used in the main Gemfile.lock.

- Replace gemfiles/activerecord61.gemfile with activerecord71.gemfile
- Bump gemspec minimum from >= 6.1 to >= 7.1

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@fbriand-docto fbriand-docto marked this pull request as draft April 2, 2026 19:40
fbriand-docto and others added 8 commits April 2, 2026 22:15
…g_migrations job

Only without_strong_migrations.gemfile tests something genuinely unique
(code path without the optional strong_migrations dependency). The AR
version gemfiles were redundant with the main Gemfile or tested
unsupported versions. Drop the matrix entirely since there is now a
single legacy gemfile.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Aligns with the platform-wide EOL compliance initiative (Ruby 3.3/3.4/4.0).
Ruby 3.0–3.3 are no longer tested or supported.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Gem authors should not commit Gemfile.lock — it prevents flexible
dependency resolution and causes Ruby version incompatibilities in CI
when switching Ruby versions (bundler runs in frozen mode and fails).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Ruby 4.0 is not yet available in rbenv and bundler compatibility is
still catching up. 3.4.8 is the correct stable target.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…it minitest/mock require

Gemfile.lock was removed during the Ruby upgrade process; regenerating
it with Ruby 3.4.8. minitest/mock is no longer a separate file in
minitest 6 (now included by default), so the explicit require is dropped.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fbriand-docto and others added 8 commits April 2, 2026 23:32
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
minitest 6 removed Minitest::Mock and Object#stub entirely.
Migrating the test suite to mocha equivalents is non-trivial,
so we cap minitest at ~> 5 for now.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Metrics/LineLength → Layout/LineLength (cop was renamed)
- TargetRubyVersion: 3.0 → 3.4 (aligns with gemspec required_ruby_version)
- Style/SuperArguments, Style/ComparableBetween, anonymous block/kwargs forwarding (autocorrected)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rations 2.x)

PG 11 reached end-of-life in November 2023. strong_migrations 2.x
(pulled in by the Ruby 3.4 lockfile regeneration) also explicitly
dropped PG 11 support, confirming it is no longer a supported target.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ersion cap

minitest 6 removed Minitest::Mock and Object#stub. Rather than capping
the version, migrate the affected tests to use mocha (already a test
dependency):
- Minitest::Mock.new + .expect → mock() + .expects (mocha auto-verifies)
- SomeClass.stub :m, val do ... end → SomeClass.stubs(:m).returns(val)
  (mocha cleans up stubs after each test in teardown)

Removes the minitest ~> 5 pin from both Gemfile and
gemfiles/without_strong_migrations.gemfile.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
rubocop was bumped from 1.53 to 1.86 as a side effect of the lockfile
regeneration, enabling new cops (Style/ArgumentsForwarding,
Naming/BlockForwarding, Style/SuperArguments, Style/ComparableBetween)
that flag lib/ code. These changes are unrelated to the Ruby upgrade;
disable them in .rubocop.yml to be addressed in a separate PR.

Reverts the lib/ autocorrects from the previous rubocop commit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ctivesupport)

minitest >= 5.1 is already a transitive dependency of activesupport.
No need to declare it explicitly in the Gemfile.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nd 15.3

Breaking change: drop Ruby < 3.4 support → major version bump.
Update CI matrix to Ruby 3.4 and PostgreSQL 12.14, 15.3.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@fbriand-docto fbriand-docto marked this pull request as ready for review April 3, 2026 23:19
@@ -1,5 +1,5 @@
env:
RUBY_VERSION: 3.2.3
RUBY_VERSION: 3.4.8
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

3.4.9 is the latest

Comment thread .ruby-version Outdated
@@ -1 +1 @@
3.2.3
3.4.8
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not reach for 4.0 line directly?

Copy link
Copy Markdown
Member Author

@fbriand-docto fbriand-docto Apr 14, 2026

Choose a reason for hiding this comment

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

I'll try, the PR became bigger than an elephant when I tried the first time but I did not try very hard :)

postgres: [ 11.7, 12.14, 15.2 ]
ruby: [ 3.1, 3.2 ]
postgres: [ 12.14, 15.3 ]
ruby: [ "3.4" ]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We will update the monolith to 4.0 this quarter. Probably better to test against it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, as safe-pgmigration` is open source, probably good to test against all active ruby version. Wdyt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-augmented PR has been augmented by AI DODO review:size-s Small PR (<100 lines changed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants