Skip to content

Commit 092b4ff

Browse files
authored
Fix CI and Rails 7.1 compatibility on main (#107)
* 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
1 parent 0b0bfc4 commit 092b4ff

File tree

9 files changed

+108
-23
lines changed

9 files changed

+108
-23
lines changed

.github/workflows/ci.yml

Lines changed: 63 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,94 @@ on: [push, pull_request]
44

55
jobs:
66
test:
7-
name: 'Ruby: ${{ matrix.ruby }}, Rails: ${{ matrix.rails }}'
7+
name: 'Ruby: ${{ matrix.ruby }}, Rails: ${{ matrix.rails }}, Channel: ${{ matrix.channel }}'
88
runs-on: 'ubuntu-22.04'
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
ruby: ['3.2', '3.1', '3.0', '2.7', '2.6', '2.5']
13-
rails: ['5.1', '5.2', '6.0', '6.1', '7.0', '7.1']
14-
exclude:
12+
ruby: ['3.3', '3.2', '3.1', '3.0', '2.7', '2.6', '2.5']
13+
rails: ['5.1', '5.2', '6.0', '6.1', '7.0', '7.1', '7.2']
14+
channel: ['stable']
15+
16+
include:
17+
- ruby: 'ruby-head'
18+
rails: 'edge'
19+
channel: 'experimental'
20+
- ruby: 'ruby-head'
21+
rails: '7.2'
22+
channel: 'experimental'
23+
- ruby: 'ruby-head'
24+
rails: '7.1'
25+
channel: 'experimental'
26+
27+
- ruby: '3.3'
28+
rails: 'edge'
29+
channel: 'experimental'
1530
- ruby: '3.2'
31+
rails: 'edge'
32+
channel: 'experimental'
33+
- ruby: '3.1'
34+
rails: 'edge'
35+
channel: 'experimental'
36+
37+
exclude:
38+
- ruby: '3.3'
39+
rails: '7.0' # TODO: works on 7-0-stable branch, remove after a 7.0.x patch release
40+
- ruby: '3.3'
41+
rails: '6.1'
42+
- ruby: '3.3'
43+
rails: '6.0'
44+
- ruby: '3.3'
45+
rails: '5.2'
46+
- ruby: '3.3'
1647
rails: '5.1'
48+
1749
- ruby: '3.2'
18-
rails: '5.2'
50+
rails: '6.1'
1951
- ruby: '3.2'
2052
rails: '6.0'
2153
- ruby: '3.2'
22-
rails: '6.1'
23-
- ruby: '3.1'
54+
rails: '5.2'
55+
- ruby: '3.2'
2456
rails: '5.1'
57+
58+
- ruby: '3.1'
59+
rails: '6.0'
2560
- ruby: '3.1'
2661
rails: '5.2'
2762
- ruby: '3.1'
28-
rails: '6.0'
29-
- ruby: '3.0'
3063
rails: '5.1'
64+
65+
- ruby: '3.0'
66+
rails: '7.2'
3167
- ruby: '3.0'
3268
rails: '5.2'
69+
- ruby: '3.0'
70+
rails: '5.1'
71+
72+
- ruby: '2.7'
73+
rails: '7.2'
74+
75+
- ruby: '2.6'
76+
rails: '7.2'
77+
- ruby: '2.6'
78+
rails: '7.1'
3379
- ruby: '2.6'
3480
rails: '7.0'
81+
3582
- ruby: '2.5'
36-
rails: '7.0'
83+
rails: '7.2'
3784
- ruby: '2.5'
3885
rails: '7.1'
39-
- ruby: '2.6'
40-
rails: '7.1'
86+
- ruby: '2.5'
87+
rails: '7.0'
88+
89+
continue-on-error: ${{ matrix.channel != 'stable' }}
90+
4191
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
4292
BUNDLE_GEMFILE: gemfiles/rails_${{ matrix.rails }}.gemfile
4393
steps:
44-
- uses: actions/checkout@v3
94+
- uses: actions/checkout@v4
4595
- name: Set up Ruby ${{ matrix.ruby }}
4696
uses: ruby/setup-ruby@v1
4797
with:

Appraisals

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,28 @@ end
88

99
appraise "rails-6.0" do
1010
gem "rails", "~> 6.0.0"
11+
gem "sqlite3", "~> 1.5"
1112
end
1213

1314
appraise "rails-6.1" do
1415
gem "rails", "~> 6.1.0"
16+
gem "sqlite3", "~> 1.5"
1517
end
1618

1719
appraise "rails-7.0" do
1820
gem "rails", "~> 7.0.0"
21+
gem "sqlite3", "~> 1.7"
1922
end
2023

2124
appraise "rails-7.1" do
2225
gem "rails", "~> 7.1.0"
26+
gem "sqlite3", "~> 1.7" # FIXME: remove after rails/rails#51592
27+
end
28+
29+
appraise "rails-7.2" do
30+
gem "rails", "~> 7.2.0.beta2"
31+
end
32+
33+
appraise "rails-edge" do
34+
gem "rails", github: "rails/rails"
2335
end

gemfiles/rails_6.0.gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ source "https://rubygems.org"
44

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

89
group :test do
910
gem "simplecov", require: false

gemfiles/rails_6.1.gemfile

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,11 @@ source "https://rubygems.org"
44

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

89
group :test do
910
gem "simplecov", require: false
1011
gem "codecov", require: false
1112
end
1213

13-
if RUBY_VERSION >= '3.1'
14-
gem 'net-smtp', require: false
15-
gem 'net-imap', require: false
16-
gem 'net-pop', require: false
17-
end
18-
19-
2014
gemspec path: "../"

gemfiles/rails_7.0.gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ source "https://rubygems.org"
44

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

89
group :test do
910
gem "simplecov", require: false

gemfiles/rails_7.1.gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
source "https://rubygems.org"
44

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

89
group :test do
910
gem "simplecov", require: false

gemfiles/rails_7.2.gemfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# This file was generated by Appraisal
2+
3+
source "https://rubygems.org"
4+
5+
gem "database_cleaner-core", git: "https://github.com/DatabaseCleaner/database_cleaner"
6+
gem "rails", "~> 7.2.0.beta2"
7+
8+
group :test do
9+
gem "simplecov", require: false
10+
gem "codecov", require: false
11+
end
12+
13+
gemspec path: "../"

gemfiles/rails_edge.gemfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# This file was generated by Appraisal
2+
3+
source "https://rubygems.org"
4+
5+
gem "database_cleaner-core", git: "https://github.com/DatabaseCleaner/database_cleaner"
6+
gem "rails", github: "rails/rails"
7+
8+
group :test do
9+
gem "simplecov", require: false
10+
gem "codecov", require: false
11+
end
12+
13+
gemspec path: "../"

lib/database_cleaner/active_record/base.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ def self.config_file_location
1515

1616
class Base < DatabaseCleaner::Strategy
1717
def self.migration_table_name
18-
if Gem::Version.new("7.1.0") < ::ActiveRecord.version
18+
if ::ActiveRecord::Base.connection_pool.respond_to?(:schema_migration) # Rails >= 7.2
1919
::ActiveRecord::Base.connection_pool.schema_migration.table_name
20-
elsif Gem::Version.new("6.0.0") <= ::ActiveRecord.version
20+
elsif ::ActiveRecord::Base.connection.respond_to?(:schema_migration) # Rails >= 6.0
2121
::ActiveRecord::Base.connection.schema_migration.table_name
2222
else
2323
::ActiveRecord::SchemaMigration.table_name

0 commit comments

Comments
 (0)