Skip to content

Commit 03edec5

Browse files
anitagrahamparndt
andauthored
Add support for Ruby 3.x -> 4.0, Rails 6.1 -> 8.1 (#3518)
This PR and its matching PR refinery/refinerycms-i18n#104 allow `refinerycms` to run with Ruby 3 / Ruby 4. It has been tested with Ruby 3.2 through 4.0, and with Rails 6.1 through 8.1. We've removed `coffee-rails` as a dependency and converted those to JS. --------- Co-authored-by: Philip Arndt <git@p.arndt.io>
1 parent b31d093 commit 03edec5

File tree

107 files changed

+2178
-1554
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+2178
-1554
lines changed

.github/workflows/legacy.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Legacy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
strategy:
12+
matrix:
13+
database: [ sqlite3, mysql, postgresql ]
14+
extension: [ core, dragonfly, images, pages, resources ]
15+
ruby: [ 3.2, 3.3, 3.4, 4.0 ]
16+
rails: [ '~> 6.1.0', '~> 7.0.0', '~> 7.1.0' ]
17+
exclude:
18+
- ruby: 3.4
19+
rails: '~> 6.1.0'
20+
- ruby: 4.0
21+
rails: '~> 6.1.0'
22+
fail-fast: false
23+
runs-on: ubuntu-latest
24+
25+
env:
26+
CI: true
27+
DB: ${{ matrix.database }}
28+
MYSQL_PASSWORD: root
29+
PGHOST: localhost
30+
PGPASSWORD: runner
31+
PGUSER: runner
32+
RAILS_ENV: test
33+
RAILS_VERSION: ${{ matrix.rails }}
34+
RETRY_COUNT: 3
35+
36+
name: rails ${{ matrix.rails }} ruby ${{ matrix.ruby }} refinerycms-${{ matrix.extension }} ${{ matrix.database }}
37+
steps:
38+
- run: sudo apt-get update && sudo apt-get install libsqlite3-dev -y
39+
- uses: actions/checkout@v6
40+
- uses: ruby/setup-ruby@v1
41+
with:
42+
bundler-cache: true
43+
ruby-version: ${{ matrix.ruby }}
44+
45+
- name: "Install ImageMagick for images extension"
46+
if: ${{ matrix.extension == 'images' }}
47+
run: sudo apt-get install imagemagick -y
48+
49+
- name: "Set up MySQL using VM's server"
50+
if: ${{ env.DB == 'mysql' }}
51+
run: |
52+
sudo apt-get install libmysqlclient-dev -y
53+
sudo systemctl start mysql.service
54+
55+
- name: "Set up PostgreSQL using VM's server"
56+
if: ${{ env.DB == 'postgresql' }}
57+
run: |
58+
sudo apt-get install libpq-dev -y
59+
sudo systemctl start postgresql.service
60+
sudo -u postgres psql -c "CREATE USER runner WITH SUPERUSER PASSWORD 'runner'"
61+
62+
- run: bin/rake refinery:testing:dummy_app
63+
- run: bin/rspec ${{ matrix.extension }}/spec

.github/workflows/main.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ jobs:
1010
test:
1111
strategy:
1212
matrix:
13-
database: [ mysql, postgresql ]
13+
database: [ sqlite3, mysql, postgresql ]
1414
extension: [ core, dragonfly, images, pages, resources ]
15-
ruby: [ 2.7, 2.6 ]
15+
ruby: [ 4.0, 3.4, 3.3, 3.2 ]
16+
rails: [ '~> 8.1.0', '~> 8.0.0', '~> 7.2.0' ]
1617
fail-fast: false
17-
max-parallel: 20
1818
runs-on: ubuntu-latest
1919

2020
env:
@@ -25,17 +25,22 @@ jobs:
2525
PGPASSWORD: runner
2626
PGUSER: runner
2727
RAILS_ENV: test
28+
RAILS_VERSION: ${{ matrix.rails }}
2829
RETRY_COUNT: 3
2930

30-
name: ${{ matrix.extension }} ${{ matrix.ruby }} ${{ matrix.database }}
31+
name: rails ${{ matrix.rails }} ruby ${{ matrix.ruby }} refinerycms-${{ matrix.extension }} ${{ matrix.database }}
3132
steps:
3233
- run: sudo apt-get update && sudo apt-get install libsqlite3-dev -y
33-
- uses: actions/checkout@v2
34+
- uses: actions/checkout@v6
3435
- uses: ruby/setup-ruby@v1
3536
with:
3637
bundler-cache: true
3738
ruby-version: ${{ matrix.ruby }}
3839

40+
- name: "Install ImageMagick for images extension"
41+
if: ${{ matrix.extension == 'images' }}
42+
run: sudo apt-get install imagemagick -y
43+
3944
- name: "Set up MySQL using VM's server"
4045
if: ${{ env.DB == 'mysql' }}
4146
run: |
@@ -50,4 +55,6 @@ jobs:
5055
sudo -u postgres psql -c "CREATE USER runner WITH SUPERUSER PASSWORD 'runner'"
5156
5257
- run: bin/rake refinery:testing:dummy_app
58+
- run: cd spec/dummy && bin/rails assets:precompile
59+
if: ${{ matrix.rails == '~> 8.1.0' }}
5360
- run: bin/rspec ${{ matrix.extension }}/spec

Gemfile

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,55 @@
1+
# frozen_string_literal: true
2+
13
source 'https://rubygems.org'
24

35
gemspec
46

5-
path "./" do
6-
gem "refinerycms-core"
7-
gem "refinerycms-images"
8-
gem "refinerycms-pages"
9-
gem "refinerycms-resources"
7+
# Allow CI and us to test specific Rails versions
8+
gem 'rails', ENV['RAILS_VERSION'] if ENV['RAILS_VERSION']
9+
10+
# Ruby 3.4+ extracted mutex_m from stdlib, but older Rails versions need it
11+
gem 'mutex_m' if RUBY_VERSION >= '3.4' && ENV['RAILS_VERSION']&.match?(/^~> [67]\./)
12+
13+
gem 'net-imap', require: false
14+
gem 'net-pop', require: false
15+
gem 'net-smtp', require: false
16+
17+
path './' do
18+
gem 'refinerycms-core'
19+
gem 'refinerycms-dragonfly'
20+
gem 'refinerycms-images'
21+
gem 'refinerycms-pages'
22+
gem 'refinerycms-resources'
1023
end
1124

12-
gem 'refinerycms-i18n', github: 'refinery/refinerycms-i18n', branch: 'master'
25+
gem 'refinerycms-i18n', github: 'refinery/refinerycms-i18n', branch: 'main'
1326

1427
# Add support for refinerycms-acts-as-indexed
15-
gem 'refinerycms-acts-as-indexed', ['~> 4.0', '>= 4.0.0'],
16-
git: 'https://github.com/refinery/refinerycms-acts-as-indexed',
17-
branch: 'master'
28+
gem 'refinerycms-acts-as-indexed', '~> 4.0', '>= 4.0.0',
29+
github: 'refinery/refinerycms-acts-as-indexed',
30+
branch: 'main'
1831

1932
# Add the default visual editor, for now.
2033
gem 'refinerycms-wymeditor', ['~> 3.0', '>= 3.0.0']
2134

35+
# Work around Zeitwerk loading issues
36+
gem 'decorators', github: 'parndt/decorators', branch: 'zeitwerk'
37+
2238
# Database Configuration
23-
unless ENV['CI']
39+
if !ENV['CI'] || ENV['DB'] == 'sqlite3'
2440
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0.rc1', platform: :jruby
25-
gem 'sqlite3', platform: :ruby
41+
# Rails 6.1 and 7.0 require sqlite3 ~> 1.4, Rails 7.1+ can use newer versions
42+
if ENV['RAILS_VERSION']&.match?(/[67]\.[01]/)
43+
gem 'sqlite3', '~> 1.4.0', platform: :ruby
44+
else
45+
gem 'sqlite3', platform: :ruby
46+
end
2647
end
2748

2849
if !ENV['CI'] || ENV['DB'] == 'mysql'
2950
group :mysql do
3051
gem 'activerecord-jdbcmysql-adapter', '>= 1.3.0.rc1', platform: :jruby
31-
gem 'mysql2', '~> 0.4', :platform => :ruby
52+
gem 'mysql2', '~> 0.4', platform: :ruby
3253
end
3354
end
3455

@@ -43,19 +64,15 @@ group :development, :test do
4364
gem 'activejob'
4465
gem 'bootsnap', require: false
4566
gem 'listen', '~> 3.0'
67+
gem 'puma', require: false
68+
gem 'rspec-rails'
4669
end
4770

4871
group :test do
49-
gem 'refinerycms-testing', path: './testing'
5072
gem 'generator_spec', '~> 0.9.3'
5173
gem 'launchy'
52-
gem 'coveralls', require: false
74+
gem 'refinerycms-testing', path: './testing'
5375
gem 'rspec-retry'
54-
gem 'falcon'
55-
gem 'falcon-capybara'
56-
57-
# TODO: Use beta source for Rails 6 support
58-
gem 'rspec-rails', '~> 4.0.0.beta3'
5976
end
6077

6178
# Load local gems according to Refinery developer preference.

Rakefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
#!/usr/bin/env rake
2+
23
begin
34
require 'bundler/setup'
45
rescue LoadError
56
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
67
end
78

89
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
9-
10-
if File.exist?(APP_RAKEFILE)
11-
load 'rails/tasks/engine.rake'
12-
end
10+
load 'rails/tasks/engine.rake' if File.exist?(APP_RAKEFILE)
1311

1412
Dir[File.expand_path('../tasks/**/*', __FILE__)].each do |task|
1513
load task

contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ inclusion.
3333

3434
## Links ##
3535

36-
See also the [Contributing to Refinery](https://www.refinerycms.com/guides/contributing-to-refinery) guide.
36+
See also the [Contributing to Refinery](https://github.com/refinery/refinerycms/blob/main/doc/guides/8%20-%20Contributing/1%20-%20Contributing%20to%20Refinery.md) guide.
37.8 KB
Loading
12.9 KB
Loading
5.36 KB
Loading
5.64 KB
Loading
3.88 KB
Loading

0 commit comments

Comments
 (0)