Skip to content

Commit 9a3ced4

Browse files
committed
Add ruby 3.1 and activesupport 7.0 support
1 parent 883f42c commit 9a3ced4

18 files changed

Lines changed: 179 additions & 12 deletions

.github/workflows/prs.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,26 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
ruby-version: ['2.5', '2.6', '2.7', '3.0']
19+
ruby: ['2.5', '2.6', '2.7', '3.0', '3.1']
20+
activesupport: ['5.2', '6.0', '6.1', '7.0']
21+
exclude:
22+
- ruby: '2.5'
23+
activesupport: '7.0'
24+
- ruby: '2.6'
25+
activesupport: '7.0'
26+
- ruby: '3.0'
27+
activesupport: '5.2'
28+
- ruby: '3.1'
29+
activesupport: '5.2'
30+
env:
31+
BUNDLE_GEMFILE: "${{ github.workspace }}/gemfiles/Gemfile.activesupport-${{ matrix.activesupport }}"
2032
steps:
2133
- uses: actions/checkout@v2
2234

2335
- name: Set up Ruby
2436
uses: ruby/setup-ruby@v1
2537
with:
26-
ruby-version: ${{ matrix.ruby-version }}
38+
ruby-version: ${{ matrix.ruby }}
2739
bundler-cache: true
2840

2941
- name: 'Run bundle update'
@@ -36,7 +48,7 @@ jobs:
3648
uses: coverallsapp/github-action@master
3749
with:
3850
github-token: ${{ secrets.GITHUB_TOKEN }}
39-
flag-name: run-${{ matrix.ruby-version }}
51+
flag-name: run-${{ matrix.ruby }}-${{ matrix.activesupport }}
4052
parallel: true
4153
finish:
4254
needs: 'test'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/.bundle/
22
/.yardoc
33
/Gemfile.lock
4+
/gemfiles/*.lock
45
/_yardoc/
56
/coverage/
67
/doc/

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ source 'https://rubygems.org'
55
# Specify your gem's dependencies in schema_dev.gemspec
66
gemspec
77

8-
gem 'byebug'
8+
gemfile_local = File.expand_path '../Gemfile.local', __FILE__
9+
eval File.read(gemfile_local), binding, gemfile_local if File.exist? gemfile_local

gemfiles/Gemfile.activesupport-5.2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2+
eval File.read(base_gemfile)
3+
4+
gem "activerecord", ">= 5.2.0.beta0", "< 5.3"

gemfiles/Gemfile.activesupport-6.0

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2+
eval File.read(base_gemfile)
3+
4+
gem "activerecord", ">= 6.0", "< 6.1"

gemfiles/Gemfile.activesupport-6.1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2+
eval File.read(base_gemfile)
3+
4+
gem "activerecord", ">= 6.1", "< 6.2"

gemfiles/Gemfile.activesupport-7.0

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2+
eval File.read(base_gemfile)
3+
4+
gem "activerecord", ">= 7.0", "< 7.1"

gemfiles/Gemfile.base

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source 'https://rubygems.org'
2+
gemspec path: File.expand_path('..', __FILE__)
3+
4+
File.exist?(gemfile_local = File.expand_path('../Gemfile.local', __FILE__)) and eval File.read(gemfile_local), binding, gemfile_local

lib/schema_dev/config.rb

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ def self._reset
1717
end
1818

1919
def self.read
20-
new(**YAML.safe_load(Pathname.new(CONFIG_FILE).read, [Symbol]).symbolize_keys)
20+
if ::Gem::Version.new(RUBY_VERSION) >= ::Gem::Version.new('3.1')
21+
new(**YAML.safe_load(Pathname.new(CONFIG_FILE).read, permitted_classes: [Symbol], symbolize_names: true))
22+
else
23+
new(**YAML.safe_load(Pathname.new(CONFIG_FILE).read, [Symbol], symbolize_names: true))
24+
end
2125
end
2226

2327
def self.load
@@ -30,11 +34,21 @@ def initialize(ruby:, activerecord:, db:, dbversions: nil, exclude: nil, notify:
3034
@db = Array.wrap(db)
3135
@dbversions = (dbversions || {}).symbolize_keys
3236
@exclude = Array.wrap(exclude).map(&:symbolize_keys).map { |tuple| Tuple.new(**tuple.transform_values(&:to_s)) }
33-
if @activerecord.include?('5.2')
34-
ruby3 = ::Gem::Version.new('3.0')
37+
@activerecord.each do |ar_version|
38+
ar_check = ::Gem::Version.new(ar_version)
39+
40+
if ar_check < ::Gem::Version.new('6.0')
41+
ruby3 = ::Gem::Version.new('3.0')
42+
43+
@ruby.select { |e| ::Gem::Version.new(e) >= ruby3 }.each do |v|
44+
@exclude << Tuple.new(ruby: v, activerecord: ar_version)
45+
end
46+
elsif ar_check >= ::Gem::Version.new('7.0')
47+
ruby27 = ::Gem::Version.new('2.7')
3548

36-
@ruby.select { |e| ::Gem::Version.new(e) >= ruby3 }.each do |v|
37-
@exclude << Tuple.new(ruby: v, activerecord: '5.2')
49+
@ruby.select { |e| ::Gem::Version.new(e) < ruby27 }.each do |v|
50+
@exclude << Tuple.new(ruby: v, activerecord: ar_version)
51+
end
3852
end
3953
end
4054
unless notify.nil?

schema_dev.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
2121

2222
gem.required_ruby_version = '>= 2.5.0'
2323

24-
gem.add_dependency 'activesupport', '>= 5.2', '< 6.2'
24+
gem.add_dependency 'activesupport', '>= 5.2', '< 7.1'
2525
gem.add_dependency 'faraday', '~> 1.0'
2626
gem.add_dependency 'simplecov'
2727
gem.add_dependency 'simplecov-lcov', '~> 0.8.0'

0 commit comments

Comments
 (0)