Skip to content

Commit

Permalink
Add support for Rails 8, use Appraisal to test gem against older Rail…
Browse files Browse the repository at this point in the history
…s versions (#100)

See svenfuchs/rails-i18n#1130 (comment) for
upper constraint removal
  • Loading branch information
n-rodriguez authored Nov 18, 2024
1 parent af70f76 commit bb8ded3
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 3 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ jobs:
- '3.2'
- '3.1'
- 'head'
rails:
- rails_8.0
- rails_7.2
- rails_7.1
- rails_7.0
exclude:
- ruby: '3.1'
rails: 'rails_8.0'

env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.rails }}.gemfile

steps:
- name: Checkout
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ test/dummy/db/*.sqlite3
test/dummy/db/*.sqlite3-shm
test/dummy/db/*.sqlite3-wal

# Ignore Gemfile.lock
Gemfile.lock
gemfiles/*.lock

# Generated test files
tmp/*
36 changes: 36 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# frozen_string_literal: true

appraise 'rails_7.0' do
gem 'rails', '~> 7.0.0'
gem 'sqlite3', '~> 1.5.0'

# Fix: LoadError: cannot load such file -- base64
install_if '-> { Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.3.0") }' do
gem 'base64'
gem 'bigdecimal'
gem 'mutex_m'
gem 'drb'
gem 'logger'
end
end

appraise 'rails_7.1' do
gem 'rails', '~> 7.1.0'
gem 'sqlite3', '~> 1.5.0'

# Fix:
# warning: logger was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.5.0.
# Add logger to your Gemfile or gemspec.
install_if '-> { Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") }' do
gem 'logger'
end
end

appraise 'rails_7.2' do
gem 'rails', '~> 7.2.0'
gem 'sqlite3', '~> 1.5.0'
end

appraise 'rails_8.0' do
gem 'rails', '~> 8.0.0'
end
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ source "https://rubygems.org"
# Specify your gem's dependencies in devise-otp.gemspec
gemspec

gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"

gem "capybara"
gem "minitest-reporters", ">= 0.5.0"
gem "puma"
gem "rake"
gem "rdoc"
gem "shoulda"
gem "sprockets-rails"
gem "sqlite3", "~> 1.4"
gem "sqlite3", "~> 2.1"
gem "standardrb"
2 changes: 1 addition & 1 deletion devise-otp.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
gem.files = `git ls-files`.split($/)
gem.require_paths = ["lib"]

gem.add_dependency "rails", ">= 7.0", "< 9.0"
gem.add_dependency "rails", ">= 7.0"
gem.add_dependency "devise", ">= 4.8.0", "< 5.0"
gem.add_dependency "rotp", ">= 2.0.0"
gem.add_dependency "rqrcode", "~> 2.0"
Expand Down
25 changes: 25 additions & 0 deletions gemfiles/rails_7.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
gem "capybara"
gem "minitest-reporters", ">= 0.5.0"
gem "puma"
gem "rake"
gem "rdoc"
gem "shoulda"
gem "sprockets-rails"
gem "sqlite3", "~> 1.5.0"
gem "standardrb"
gem "rails", "~> 7.0.0"

install_if -> { Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.3.0") } do
gem "base64"
gem "bigdecimal"
gem "mutex_m"
gem "drb"
gem "logger"
end

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

source "https://rubygems.org"

gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
gem "capybara"
gem "minitest-reporters", ">= 0.5.0"
gem "puma"
gem "rake"
gem "rdoc"
gem "shoulda"
gem "sprockets-rails"
gem "sqlite3", "~> 1.5.0"
gem "standardrb"
gem "rails", "~> 7.1.0"

install_if -> { Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") } do
gem "logger"
end

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

source "https://rubygems.org"

gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
gem "capybara"
gem "minitest-reporters", ">= 0.5.0"
gem "puma"
gem "rake"
gem "rdoc"
gem "shoulda"
gem "sprockets-rails"
gem "sqlite3", "~> 1.5.0"
gem "standardrb"
gem "rails", "~> 7.2.0"

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

source "https://rubygems.org"

gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
gem "capybara"
gem "minitest-reporters", ">= 0.5.0"
gem "puma"
gem "rake"
gem "rdoc"
gem "shoulda"
gem "sprockets-rails"
gem "sqlite3", "~> 2.1"
gem "standardrb"
gem "rails", "~> 8.0.0"

gemspec path: "../"
2 changes: 1 addition & 1 deletion test/dummy/db/migrate/20240604000001_create_admins.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateAdmins < ActiveRecord::Migration[7.1]
class CreateAdmins < ActiveRecord::Migration[5.0]
def change
create_table :admins do |t|
t.string :name
Expand Down

0 comments on commit bb8ded3

Please sign in to comment.