Skip to content

Commit

Permalink
Drop support for old Rubies and Rails (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
jturkel committed Sep 18, 2023
1 parent a87f794 commit 1c9239e
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 99 deletions.
45 changes: 9 additions & 36 deletions .circleci/config.yml
Expand Up @@ -2,18 +2,14 @@ version: 2.1
jobs:
lint:
docker:
- image: salsify/ruby_ci:2.6.10
- image: ruby:3.0.6
working_directory: ~/goldiloader
steps:
- checkout
- run:
# This is only needed for Ruby 2.6.10 which has an old version of SQLite
name: Install SQLite
command: sudo apt-get update && sudo apt-get install -y libsqlite3-dev
- restore_cache:
keys:
- v1-gems-ruby-2.6.10-{{ checksum "goldiloader.gemspec" }}-{{ checksum "Gemfile" }}
- v1-gems-ruby-2.6.10-
- v1-gems-ruby-3.0.6-{{ checksum "goldiloader.gemspec" }}-{{ checksum "Gemfile" }}
- v1-gems-ruby-3.0.6-
- run:
name: Install Gems
command: |
Expand All @@ -22,7 +18,7 @@ jobs:
bundle clean
fi
- save_cache:
key: v1-gems-ruby-2.6.10-{{ checksum "goldiloader.gemspec" }}-{{ checksum "Gemfile" }}
key: v1-gems-ruby-3.0.6-{{ checksum "goldiloader.gemspec" }}-{{ checksum "Gemfile" }}
paths:
- "vendor/bundle"
- "gemfiles/vendor/bundle"
Expand All @@ -36,21 +32,13 @@ jobs:
ruby_version:
type: string
docker:
- image: salsify/ruby_ci:<< parameters.ruby_version >>
- image: ruby:<< parameters.ruby_version >>
environment:
CIRCLE_TEST_REPORTS: "test-results"
BUNDLE_GEMFILE: << parameters.gemfile >>
working_directory: ~/goldiloader
steps:
- checkout
- when:
condition:
equal: [ "2.6.10", << parameters.ruby_version >> ]
steps:
- run:
# This is only needed for Ruby 2.6.10 which has an old version of SQLite
name: Install SQLite
command: sudo apt-get update && sudo apt-get install -y libsqlite3-dev
- unless:
condition:
equal: ["gemfiles/rails_edge.gemfile", << parameters.gemfile >>]
Expand Down Expand Up @@ -89,28 +77,13 @@ workflows:
matrix:
parameters:
gemfile:
- "gemfiles/rails_5.2.gemfile"
- "gemfiles/rails_6.0.gemfile"
- "gemfiles/rails_6.1.gemfile"
- "gemfiles/rails_7.0.gemfile"
- "gemfiles/rails_edge.gemfile"
ruby_version:
- "2.6.10"
- "2.7.7"
- "3.0.5"
- "3.1.3"
- "3.2.0"
exclude:
- gemfile: "gemfiles/rails_5.2.gemfile"
ruby_version: "3.0.5"
- gemfile: "gemfiles/rails_5.2.gemfile"
ruby_version: "3.1.3"
- gemfile: "gemfiles/rails_5.2.gemfile"
ruby_version: "3.2.0"
- gemfile: "gemfiles/rails_7.0.gemfile"
ruby_version: "2.6.10"
- gemfile: "gemfiles/rails_edge.gemfile"
ruby_version: "2.6.10"
- "3.0.6"
- "3.1.4"
- "3.2.2"
weekly_rails_edge:
triggers:
- schedule:
Expand All @@ -126,4 +99,4 @@ workflows:
gemfile:
- "gemfiles/rails_edge.gemfile"
ruby_version:
- "3.2.0"
- "3.2.2"
2 changes: 1 addition & 1 deletion .rubocop.yml
Expand Up @@ -2,7 +2,7 @@ inherit_gem:
salsify_rubocop: conf/rubocop.yml

AllCops:
TargetRubyVersion: 2.6
TargetRubyVersion: 3.0
Exclude:
- 'vendor/**/*'
- 'gemfiles/**/*'
24 changes: 6 additions & 18 deletions Appraisals
@@ -1,27 +1,15 @@
# frozen_string_literal: true

appraise 'rails-5.2' do
gem 'activerecord', '5.2.8.1'
gem 'activesupport', '5.2.8.1'
gem 'rails', '5.2.8.1'
end

appraise 'rails-6.0' do
gem 'activerecord', '6.0.6'
gem 'activesupport', '6.0.6'
gem 'rails', '6.0.6'
end

appraise 'rails-6.1' do
gem 'activerecord', '6.1.7'
gem 'activesupport', '6.1.7'
gem 'rails', '6.1.7'
gem 'activerecord', '6.1.7.6'
gem 'activesupport', '6.1.7.6'
gem 'rails', '6.1.7.6'
end

appraise 'rails-7.0' do
gem 'activerecord', '7.0.4'
gem 'activesupport', '7.0.4'
gem 'rails', '7.0.4'
gem 'activerecord', '7.0.8'
gem 'activesupport', '7.0.8'
gem 'rails', '7.0.8'
end

appraise 'rails-edge' do
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,8 @@
# Changelog

## 5.0.0
- Drop support for Ruby < 3.0 and Rails < 6.1.

## 4.2.0
- Add support for Rails 7.0 and Ruby 3.1.

Expand Down
7 changes: 4 additions & 3 deletions README.md
Expand Up @@ -12,8 +12,9 @@

Wouldn't it be awesome if ActiveRecord didn't make you think about eager loading and it just did the "right" thing by default? With Goldiloader it can!

**This branch only supports Rails 5.2+ with Ruby 2.6+. For older versions of Rails/Ruby use [3-x-stable](https://github.com/salsify/goldiloader/blob/3-x-stable/README.md),
[2-x-stable](https://github.com/salsify/goldiloader/blob/2-x-stable/README.md)
**This branch only supports Rails 6.1+ with Ruby 3.0+. For older versions of Rails/Ruby use
[4-x-stable](https://github.com/salsify/goldiloader/blob/4-x-stable/README.md),
[3-x-stable](https://github.com/salsify/goldiloader/blob/3-x-stable/README.md), [2-x-stable](https://github.com/salsify/goldiloader/blob/2-x-stable/README.md)
or [1-x-stable](https://github.com/salsify/goldiloader/blob/1-x-stable/README.md).**

Consider the following models:
Expand Down Expand Up @@ -293,7 +294,7 @@ end

## Status

This gem is tested with Rails 5.2, 6.0, 6.1, 7.0 and Edge using MRI 2.6, 2.7, 3.0, 3.1 and 3.2.
This gem is tested with Rails 6.1, 7.0 and Edge using MRI 3.0, 3.1 and 3.2.

Let us know if you find any issues or have any other feedback.

Expand Down
9 changes: 0 additions & 9 deletions gemfiles/rails_5.2.gemfile

This file was deleted.

9 changes: 0 additions & 9 deletions gemfiles/rails_6.0.gemfile

This file was deleted.

6 changes: 3 additions & 3 deletions gemfiles/rails_6.1.gemfile
Expand Up @@ -2,8 +2,8 @@

source "https://rubygems.org"

gem "activerecord", "6.1.7"
gem "activesupport", "6.1.7"
gem "rails", "6.1.7"
gem "activerecord", "6.1.7.6"
gem "activesupport", "6.1.7.6"
gem "rails", "6.1.7.6"

gemspec path: "../"
6 changes: 3 additions & 3 deletions gemfiles/rails_7.0.gemfile
Expand Up @@ -2,8 +2,8 @@

source "https://rubygems.org"

gem "activerecord", "7.0.4"
gem "activesupport", "7.0.4"
gem "rails", "7.0.4"
gem "activerecord", "7.0.8"
gem "activesupport", "7.0.8"
gem "rails", "7.0.8"

gemspec path: "../"
8 changes: 4 additions & 4 deletions goldiloader.gemspec
Expand Up @@ -29,16 +29,16 @@ Gem::Specification.new do |spec|

spec.files = `git ls-files lib Readme.md LICENSE.txt`.split($INPUT_RECORD_SEPARATOR)

spec.required_ruby_version = '>= 2.6'
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'activerecord', '>= 5.2', '< 7.2'
spec.add_dependency 'activesupport', '>= 5.2', '< 7.2'
spec.add_dependency 'activerecord', '>= 6.1', '< 7.2'
spec.add_dependency 'activesupport', '>= 6.1', '< 7.2'

spec.add_development_dependency 'appraisal'
spec.add_development_dependency 'benchmark-ips'
spec.add_development_dependency 'combustion', '~> 1.3'
spec.add_development_dependency 'coveralls_reborn', '>= 0.18.0'
spec.add_development_dependency 'rails', '>= 5.2', '< 7.2'
spec.add_development_dependency 'rails', '>= 6.1', '< 7.2'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rspec', '~> 3'
spec.add_development_dependency 'rspec_junit_formatter'
Expand Down
3 changes: 1 addition & 2 deletions lib/goldiloader/active_record_patches.rb
Expand Up @@ -114,8 +114,7 @@ def fully_load?
private

def eager_loadable?
klass && reflection.eager_loadable?(klass) &&
(::Goldiloader::Compatibility.destroyed_model_associations_eager_loadable? || !owner.destroyed?)
klass && reflection.eager_loadable?(klass)
end

def load_with_auto_include
Expand Down
10 changes: 0 additions & 10 deletions lib/goldiloader/compatibility.rb
Expand Up @@ -3,27 +3,17 @@
module Goldiloader
module Compatibility
ACTIVE_RECORD_VERSION = ::Gem::Version.new(::ActiveRecord::VERSION::STRING).release
RAILS_5_2_0 = ACTIVE_RECORD_VERSION == ::Gem::Version.new('5.2.0')

def self.pre_rails_7?
::ActiveRecord::VERSION::MAJOR < 7
end

def self.rails_5_2?
::ActiveRecord::VERSION::MAJOR == 5 && ::ActiveRecord::VERSION::MINOR == 2
end

def self.rails_6_1?
::ActiveRecord::VERSION::MAJOR == 6 && ::ActiveRecord::VERSION::MINOR == 1
end

def self.rails_6_1_or_greater?
::ActiveRecord::VERSION::MAJOR > 6 || rails_6_1?
end

# See https://github.com/rails/rails/pull/32375
def self.destroyed_model_associations_eager_loadable?
!RAILS_5_2_0
end
end
end
2 changes: 1 addition & 1 deletion lib/goldiloader/version.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Goldiloader
VERSION = '4.2.0'
VERSION = '5.0.0'
end

0 comments on commit 1c9239e

Please sign in to comment.