Skip to content

Commit

Permalink
Fix CI and Rails 7.1 compatibility on main (#107)
Browse files Browse the repository at this point in the history
* Improve CI

Stable builds:
- Test against Ruby 3.3 stable
- Test against Rails 7.1 stable
- Test against Rails 7.2 beta

Experimental builds:
- Test against Rails edge (previously: 7.1, ref: #106)
- Test against Ruby head

Fixes:
- Fix sqlite3 dependency on old Rails versions

Updates:
- Update GitHub actions

Readability:
- Sort and group inclusion and exclusions in CI matrix

* Fix Rails 7.1 compatibility

Also:
- Invert the logic to make the conditional more readable
- Add "alpha" to version to include pre-releases

ActiveRecord:
- 7.2: `Base.connection_pool.schema_migration.table_name`
- 7.1, 7.0, 6.x: `Base.connection.schema_migration.table_name`
- 5.x: `SchemaMigration.table_name`

Close #106

* Use `respond_to?` to find migration table name

Removes dependency on version
  • Loading branch information
tagliala authored Jul 12, 2024
1 parent 0b0bfc4 commit 092b4ff
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 23 deletions.
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
::ActiveRecord::Base.connection.schema_migration.table_name
else
::ActiveRecord::SchemaMigration.table_name
Expand Down

0 comments on commit 092b4ff

Please sign in to comment.