Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI and Rails 7.1 compatibility on main #107

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 63 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,94 @@ on: [push, pull_request]

jobs:
test:
name: 'Ruby: ${{ matrix.ruby }}, Rails: ${{ matrix.rails }}'
name: 'Ruby: ${{ matrix.ruby }}, Rails: ${{ matrix.rails }}, Channel: ${{ matrix.channel }}'
runs-on: 'ubuntu-22.04'
strategy:
fail-fast: false
matrix:
ruby: ['3.2', '3.1', '3.0', '2.7', '2.6', '2.5']
rails: ['5.1', '5.2', '6.0', '6.1', '7.0', '7.1']
exclude:
ruby: ['3.3', '3.2', '3.1', '3.0', '2.7', '2.6', '2.5']
rails: ['5.1', '5.2', '6.0', '6.1', '7.0', '7.1', '7.2']
channel: ['stable']

include:
- ruby: 'ruby-head'
rails: 'edge'
channel: 'experimental'
- ruby: 'ruby-head'
rails: '7.2'
channel: 'experimental'
- ruby: 'ruby-head'
rails: '7.1'
channel: 'experimental'

- ruby: '3.3'
rails: 'edge'
channel: 'experimental'
- ruby: '3.2'
rails: 'edge'
channel: 'experimental'
- ruby: '3.1'
rails: 'edge'
channel: 'experimental'

exclude:
- ruby: '3.3'
rails: '7.0' # TODO: works on 7-0-stable branch, remove after a 7.0.x patch release
- ruby: '3.3'
rails: '6.1'
- ruby: '3.3'
rails: '6.0'
- ruby: '3.3'
rails: '5.2'
- ruby: '3.3'
rails: '5.1'

- ruby: '3.2'
rails: '5.2'
rails: '6.1'
- ruby: '3.2'
rails: '6.0'
- ruby: '3.2'
rails: '6.1'
- ruby: '3.1'
rails: '5.2'
- ruby: '3.2'
rails: '5.1'

- ruby: '3.1'
rails: '6.0'
- ruby: '3.1'
rails: '5.2'
- ruby: '3.1'
rails: '6.0'
- ruby: '3.0'
rails: '5.1'

- ruby: '3.0'
rails: '7.2'
- ruby: '3.0'
rails: '5.2'
- ruby: '3.0'
rails: '5.1'

- ruby: '2.7'
rails: '7.2'

- ruby: '2.6'
rails: '7.2'
- ruby: '2.6'
rails: '7.1'
- ruby: '2.6'
rails: '7.0'

- ruby: '2.5'
rails: '7.0'
rails: '7.2'
- ruby: '2.5'
rails: '7.1'
- ruby: '2.6'
rails: '7.1'
- ruby: '2.5'
rails: '7.0'

continue-on-error: ${{ matrix.channel != 'stable' }}

env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
BUNDLE_GEMFILE: gemfiles/rails_${{ matrix.rails }}.gemfile
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Ruby ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
Expand Down
12 changes: 12 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,28 @@ end

appraise "rails-6.0" do
gem "rails", "~> 6.0.0"
gem "sqlite3", "~> 1.5"
end

appraise "rails-6.1" do
gem "rails", "~> 6.1.0"
gem "sqlite3", "~> 1.5"
end

appraise "rails-7.0" do
gem "rails", "~> 7.0.0"
gem "sqlite3", "~> 1.7"
end

appraise "rails-7.1" do
gem "rails", "~> 7.1.0"
gem "sqlite3", "~> 1.7" # FIXME: remove after rails/rails#51592
end

appraise "rails-7.2" do
gem "rails", "~> 7.2.0.beta2"
end

appraise "rails-edge" do
gem "rails", github: "rails/rails"
end
1 change: 1 addition & 0 deletions gemfiles/rails_6.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source "https://rubygems.org"

gem "database_cleaner-core", git: "https://github.com/DatabaseCleaner/database_cleaner"
gem "rails", "~> 6.0.0"
gem "sqlite3", "~> 1.5"

group :test do
gem "simplecov", require: false
Expand Down
8 changes: 1 addition & 7 deletions gemfiles/rails_6.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@ source "https://rubygems.org"

gem "database_cleaner-core", git: "https://github.com/DatabaseCleaner/database_cleaner"
gem "rails", "~> 6.1.0"
gem "sqlite3", "~> 1.5"

group :test do
gem "simplecov", require: false
gem "codecov", require: false
end

if RUBY_VERSION >= '3.1'
gem 'net-smtp', require: false
gem 'net-imap', require: false
gem 'net-pop', require: false
end


gemspec path: "../"
1 change: 1 addition & 0 deletions gemfiles/rails_7.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source "https://rubygems.org"

gem "database_cleaner-core", git: "https://github.com/DatabaseCleaner/database_cleaner"
gem "rails", "~> 7.0.0"
gem "sqlite3", "~> 1.7"

group :test do
gem "simplecov", require: false
Expand Down
3 changes: 2 additions & 1 deletion gemfiles/rails_7.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
source "https://rubygems.org"

gem "database_cleaner-core", git: "https://github.com/DatabaseCleaner/database_cleaner"
gem "rails", github: 'rails/rails' # "~> 7.1.0"
gem "rails", "~> 7.1.0"
gem "sqlite3", "~> 1.7"

group :test do
gem "simplecov", require: false
Expand Down
13 changes: 13 additions & 0 deletions gemfiles/rails_7.2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "database_cleaner-core", git: "https://github.com/DatabaseCleaner/database_cleaner"
gem "rails", "~> 7.2.0.beta2"

group :test do
gem "simplecov", require: false
gem "codecov", require: false
end

gemspec path: "../"
13 changes: 13 additions & 0 deletions gemfiles/rails_edge.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "database_cleaner-core", git: "https://github.com/DatabaseCleaner/database_cleaner"
gem "rails", github: "rails/rails"

group :test do
gem "simplecov", require: false
gem "codecov", require: false
end

gemspec path: "../"
4 changes: 2 additions & 2 deletions lib/database_cleaner/active_record/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def self.config_file_location

class Base < DatabaseCleaner::Strategy
def self.migration_table_name
if Gem::Version.new("7.1.0") < ::ActiveRecord.version
if ::ActiveRecord::Base.connection_pool.respond_to?(:schema_migration) # Rails >= 7.2
::ActiveRecord::Base.connection_pool.schema_migration.table_name
elsif Gem::Version.new("6.0.0") <= ::ActiveRecord.version
elsif ::ActiveRecord::Base.connection.respond_to?(:schema_migration) # Rails >= 6.0
Comment on lines -18 to +20
Copy link
Contributor Author

@tagliala tagliala Jun 11, 2024

Choose a reason for hiding this comment

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

opinionated change in a separate commit, feel free to remove the last commit to use a version-based comparison.

As a side node, these changes are introduced in alphas, betas, and even RCs, so I prefer respond_to? instead of relying on the version

::ActiveRecord::Base.connection.schema_migration.table_name
else
::ActiveRecord::SchemaMigration.table_name
Expand Down