Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Rails 8, use Appraisal to test gem against older Rails versions #100

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Contributor Author

@n-rodriguez n-rodriguez Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise migrations don't apply when running CI against Rails 7.0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And to be consistent with other migrations

def change
create_table :admins do |t|
t.string :name
Expand Down