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

Clean up Appraisal and CI config; add Rails 7.2 and Ruby 3.3 #723

Merged
merged 12 commits into from
Aug 13, 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
104 changes: 60 additions & 44 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,77 +10,93 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [2.3, 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2]
ruby: ["2.3", "2.4", "2.5", "2.6", "2.7", "3.0", "3.1", "3.2", "3.3"]
appraisal:
- rails52
- rails60
- rails61
- rails70
- rails71
- rails80
- rails72
db: [POSTGRES, MYSQL, SQLITE]
exclude:
# MySQL has issues on Ruby 2.3
# https://github.com/ruby/setup-ruby/issues/150
- ruby: 2.3
- ruby: "2.3"
db: MYSQL

# PostgreSQL is segfaulting on 2.3
# Doesn't seem worth solving.
- ruby: 2.3
- ruby: "2.3"
db: POSTGRES

# Rails 5.2 supports Ruby 2.2-2.5
- appraisal: rails52
ruby: 2.6
ruby: "2.6"
- appraisal: rails52
ruby: 2.7
ruby: "2.7"
- appraisal: rails52
ruby: 3.0
ruby: "3.0"
- appraisal: rails52
ruby: 3.1
ruby: "3.1"
- appraisal: rails52
ruby: 3.2
ruby: "3.2"
- appraisal: rails52
ruby: "3.3"

# Rails 6.0 supports Ruby 2.5-2.7
- appraisal: rails60
ruby: 2.3
ruby: "2.3"
- appraisal: rails60
ruby: "2.4"
- appraisal: rails60
ruby: 2.4
ruby: "3.0"
- appraisal: rails60
ruby: 3.0
ruby: "3.1"
- appraisal: rails60
ruby: 3.1
ruby: "3.2"
- appraisal: rails60
ruby: 3.2
ruby: "3.3"

# Rails 6.1 supports Ruby 2.5+
- appraisal: rails61
ruby: 2.3
ruby: "2.3"
- appraisal: rails61
ruby: 2.4
ruby: "2.4"

# Rails 7 supports Ruby 2.7+
- appraisal: rails70
ruby: 2.3
ruby: "2.3"
- appraisal: rails70
ruby: 2.4
ruby: "2.4"
- appraisal: rails70
ruby: 2.5
ruby: "2.5"
- appraisal: rails70
ruby: 2.6
ruby: "2.6"

# Rails 7.1 supports Ruby 2.7+
- appraisal: rails71
ruby: 2.3
ruby: "2.3"
- appraisal: rails71
ruby: 2.4
ruby: "2.4"
- appraisal: rails71
ruby: 2.5
ruby: "2.5"
- appraisal: rails71
ruby: 2.6
- appraisal: rails80
ruby: 2.6
ruby: "2.6"

# Rails 7.2 supports Ruby 3.1+
- appraisal: rails72
ruby: "2.3"
- appraisal: rails72
ruby: "2.4"
- appraisal: rails72
ruby: "2.5"
- appraisal: rails72
ruby: "2.6"
- appraisal: rails72
ruby: "2.7"
- appraisal: rails72
ruby: "3.0"

services:
postgres:
Expand All @@ -97,24 +113,24 @@ jobs:
env:
DB_DATABASE: audited_test
DB_USER: root
DB_PASSWORD: 'root'
DB_PASSWORD: "root"
DB_HOST: localhost

steps:
- name: Setup MySQL
run: |
sudo /etc/init.d/mysql start
mysql -e 'CREATE DATABASE audited_test;' -uroot -proot
mysql -e 'SHOW DATABASES;' -uroot -proot
- uses: actions/checkout@v4
- name: Copy Gemfile
run: sed 's/\.\././' gemfiles/${{ matrix.appraisal }}.gemfile > Gemfile
- name: Set up Ruby ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run tests
env:
DB: ${{ matrix.db }}
run: bundle exec rake
- name: Setup MySQL
run: |
sudo /etc/init.d/mysql start
mysql -e 'CREATE DATABASE audited_test;' -uroot -proot
mysql -e 'SHOW DATABASES;' -uroot -proot
- uses: actions/checkout@v4
- name: Copy Gemfile
run: sed 's/\.\././' gemfiles/${{ matrix.appraisal }}.gemfile > Gemfile
- name: Set up Ruby ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run tests
env:
DB: ${{ matrix.db }}
run: bundle exec rake
40 changes: 11 additions & 29 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,26 +1,8 @@
# Include DB adapters matching the version requirements in
# rails/activerecord/lib/active_record/connection_adapters/*adapter.rb

appraise "rails50" do
gem "rails", "~> 5.0.0"
gem "mysql2", ">= 0.3.18", "< 0.6.0"
gem "pg", ">= 0.18", "< 2.0"
gem "sqlite3", "~> 1.3.6"
gem "psych", "~> 3.1"
gem "loofah", "2.20.0"
end

appraise "rails51" do
gem "rails", "~> 5.1.4"
gem "mysql2", ">= 0.3.18", "< 0.6.0"
gem "pg", ">= 0.18", "< 2.0"
gem "sqlite3", "~> 1.3.6"
gem "psych", "~> 3.1"
gem "loofah", "2.20.0"
end

appraise "rails52" do
gem "rails", ">= 5.2.8.1", "< 5.3"
gem "rails", "~> 5.2.8"
gem "mysql2", ">= 0.4.4", "< 0.6.0"
gem "pg", ">= 0.18", "< 2.0"
gem "sqlite3", "~> 1.3.6"
Expand All @@ -29,36 +11,36 @@ appraise "rails52" do
end

appraise "rails60" do
gem "rails", ">= 6.0.0", "< 6.1"
gem "rails", "~> 6.0.6"
gem "mysql2", ">= 0.4.4"
gem "pg", ">= 0.18", "< 2.0"
gem "sqlite3", "~> 1.4"
end

appraise "rails61" do
gem "rails", ">= 6.1.0", "< 6.2"
gem "rails", "~> 6.1.7"
gem "mysql2", ">= 0.4.4"
gem "pg", ">= 1.1", "< 2.0"
gem "sqlite3", "~> 1.4"
end

appraise "rails70" do
gem "rails", ">= 7.0.0", "< 7.1"
gem "rails", "~> 7.0.8"
gem "mysql2", ">= 0.4.4"
gem "pg", ">= 1.1"
gem "sqlite3", ">= 1.4"
gem "sqlite3", "~> 1.4"
end

appraise "rails71" do
gem "rails", ">= 7.1.0.beta1", "< 7.2"
gem "rails", "~> 7.1.3"
gem "mysql2", ">= 0.4.4"
gem "pg", ">= 1.1"
gem "sqlite3", ">= 1.4"
gem "sqlite3", "~> 1.4"
end

appraise "rails80" do
Copy link

Choose a reason for hiding this comment

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

so in the changelog it says "Add rails 8 support" and now we remove the appraise rails80 ?

gem "rails", ">= 7.1.0.beta1", "< 8.1"
gem "mysql2", ">= 0.4.4"
gem "pg", ">= 1.1"
appraise "rails72" do
gem "rails", "~> 7.2.0"
gem "mysql2", "~> 0.5"
gem "pg", "~> 1.1"
gem "sqlite3", ">= 1.4"
end
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Audited
**Audited** (previously acts_as_audited) is an ORM extension that logs all changes to your models. Audited can also record who made those changes, save comments and associate models related to the changes.


Audited currently (5.6) works with Rails 7.1, 7.0, 6.1, 6.0, 5.2.
Audited currently (5.6) works with Rails 7.2, 7.1, 7.0, 6.1, 6.0, 5.2.

For Rails 5.0 & 5.1, use gem version 5.4.3
For Rails 4, use gem version 4.x
Expand All @@ -26,6 +26,7 @@ Audited supports and is [tested against](https://github.com/collectiveidea/audit
* 3.0
* 3.1
* 3.2
* 3.3

Audited may work just fine with a Ruby version not listed above, but we can't guarantee that it will. If you'd like to maintain a Ruby that isn't listed, please let us know with a [pull request](https://github.com/collectiveidea/audited/pulls).

Expand Down
6 changes: 3 additions & 3 deletions audited.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ Gem::Specification.new do |gem|

gem.required_ruby_version = ">= 2.3.0"

gem.add_dependency "activerecord", ">= 5.2", "< 8.1"
gem.add_dependency "activesupport", ">= 5.2", "< 8.1"
gem.add_dependency "activerecord", ">= 5.2", "< 8.0"
Copy link

Choose a reason for hiding this comment

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

nooo rip. that means when rails 8.0 is out i will have to fork this project again to be able to use rails main branch. i thought i had more time 😭

honestly i don't know why there is a restriction on the upper bound
it should be like this gem.add_dependency "activerecord", ">= 5.2"

Copy link
Member

Choose a reason for hiding this comment

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

I don't really have a strong opinion here. I see this pattern of limiting the upper bound a lot, but is it really helping more than hurting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My goal for this PR was to get CI passing and confirm Rails 7.2 compatibility. I removed the rails80 appraisal because it was not working. Without a passing test suite for 8.0, I didn't feel comfortable allowing 8.0 in the gemspec, and I don't have a real app running on Rails main that I could manually test.

Rubygems itself frowns upon unbounded dependencies. I don't know how closely their recommendations are followed, but the Rubygems validation code emits a warning for it:

https://github.com/rubygems/rubygems/blob/b22914018e9c5f7b5b31eab6fa39ea4e82c623dc/lib/rubygems/specification_policy.rb#L222-L235

For audited specifically, this is a mission-critical gem, it can result in data loss if it doesn't work correctly, and it hooks deeply into ActiveRecord. So I would be uncomfortable if it allowed versions of Rails that were not thoroughly tested. So I lean toward being more strict in the gemspec.

That said, ultimately if this is a very-lightly maintained gem, and the philosophy is "use it at your own risk", then an unbounded requirement makes sense. On the other hand, if there is a plan for actively maintaining and testing every release of Rails and Ruby versions going forward, including prereleases, then I think a more strict requirement would work.

gem.add_dependency "activesupport", ">= 5.2", "< 8.0"

gem.add_development_dependency "appraisal"
gem.add_development_dependency "rails", ">= 5.2", "< 8.1"
gem.add_development_dependency "rails", ">= 5.2", "< 8.0"
gem.add_development_dependency "rspec-rails"
gem.add_development_dependency "standard"
gem.add_development_dependency "single_cov"
Expand Down
12 changes: 0 additions & 12 deletions gemfiles/rails50.gemfile

This file was deleted.

12 changes: 0 additions & 12 deletions gemfiles/rails51.gemfile

This file was deleted.

2 changes: 1 addition & 1 deletion gemfiles/rails52.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source "https://rubygems.org"

gem "rails", ">= 5.2.8.1", "< 5.3"
gem "rails", "~> 5.2.8"
gem "mysql2", ">= 0.4.4", "< 0.6.0"
gem "pg", ">= 0.18", "< 2.0"
gem "sqlite3", "~> 1.3.6"
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails60.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source "https://rubygems.org"

gem "rails", ">= 6.0.0", "< 6.1"
gem "rails", "~> 6.0.6"
gem "mysql2", ">= 0.4.4"
gem "pg", ">= 0.18", "< 2.0"
gem "sqlite3", "~> 1.4"
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails61.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source "https://rubygems.org"

gem "rails", ">= 6.1.0", "< 6.2"
gem "rails", "~> 6.1.7"
gem "mysql2", ">= 0.4.4"
gem "pg", ">= 1.1", "< 2.0"
gem "sqlite3", "~> 1.4"
Expand Down
4 changes: 2 additions & 2 deletions gemfiles/rails70.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

source "https://rubygems.org"

gem "rails", ">= 7.0.0", "< 7.1"
gem "rails", "~> 7.0.8"
gem "mysql2", ">= 0.4.4"
gem "pg", ">= 1.1"
gem "sqlite3", ">= 1.4"
gem "sqlite3", "~> 1.4"

gemspec name: "audited", path: "../"
4 changes: 2 additions & 2 deletions gemfiles/rails71.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

source "https://rubygems.org"

gem "rails", ">= 7.1.0.beta1", "< 7.2"
gem "rails", "~> 7.1.3"
gem "mysql2", ">= 0.4.4"
gem "pg", ">= 1.1"
gem "sqlite3", ">= 1.4"
gem "sqlite3", "~> 1.4"

gemspec name: "audited", path: "../"
6 changes: 3 additions & 3 deletions gemfiles/rails80.gemfile → gemfiles/rails72.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

source "https://rubygems.org"

gem "rails", ">= 7.1.0.beta1", "< 8.1"
gem "mysql2", ">= 0.4.4"
gem "pg", ">= 1.1"
gem "rails", "~> 7.2.0"
gem "mysql2", "~> 0.5"
gem "pg", "~> 1.1"
gem "sqlite3", ">= 1.4"

gemspec name: "audited", path: "../"
3 changes: 2 additions & 1 deletion spec/audited/auditor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

# not testing proxy_respond_to? hack / 2 methods / deprecation of `version`
# also, an additional 6 around `after_touch` for Versions before 6.
uncovered = (ActiveRecord::VERSION::MAJOR < 6) ? 15 : 9
# Increased to 17/10 to get to green CI as a new baseline, August 2024.
uncovered = (ActiveRecord::VERSION::MAJOR < 6) ? 17 : 10
SingleCov.covered! uncovered: uncovered

class ConditionalPrivateCompany < ::ActiveRecord::Base
Expand Down
6 changes: 5 additions & 1 deletion spec/audited_spec_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def create_versions(n = 2, attrs = {})
def run_migrations(direction, migrations_paths, target_version = nil)
if rails_below?("5.2.0.rc1")
ActiveRecord::Migrator.send(direction, migrations_paths, target_version)
elsif rails_below?("6.0.0.rc1")
elsif rails_below?("6.0.0.rc1") || rails_at_least?("7.2.0")
ActiveRecord::MigrationContext.new(migrations_paths).send(direction, target_version)
else
ActiveRecord::MigrationContext.new(migrations_paths, ActiveRecord::SchemaMigration).send(direction, target_version)
Expand All @@ -33,4 +33,8 @@ def run_migrations(direction, migrations_paths, target_version = nil)
def rails_below?(rails_version)
Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new(rails_version)
end

def rails_at_least?(rails_version)
Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new(rails_version)
end
end
2 changes: 1 addition & 1 deletion spec/rails_app/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Application < Rails::Application
config.root = File.expand_path("../../", __FILE__)
config.i18n.enforce_available_locales = true

if Rails.version.start_with?("7.1") && config.active_record.respond_to?(:yaml_column_permitted_classes=)
if Rails.gem_version >= Gem::Version.new("7.1") && config.active_record.respond_to?(:yaml_column_permitted_classes=)
config.active_record.yaml_column_permitted_classes = [
String,
Symbol,
Expand Down
Loading