-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Test against rails 8.0 #3702
Test against rails 8.0 #3702
Conversation
gemfiles/rails_8.0.gemfile
Outdated
platforms :ruby, :mswin, :mingw, :x64_mingw do | ||
gem "mysql2", ">= 0.3.14" | ||
gem "pg", ">= 1.0.0" | ||
gem "sqlite3", "~> 1.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From Rails 8.0, it looks like the version of sqlite3 needs to be upgraded to v2.1 or higher.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed, I upgraded it, and now it seems to work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like sqlite3 2.2 requires ruby 3.1.
What would be the best approach? Require ruby 3.1 for the next release, or stay backwards compatible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jewilmeer
Thank you for your support with Rails 8.0! It’s really helpful!
Seems like sqlite3 2.2 requires ruby 3.1.
This might help you.
In RailsAdmin, we use gem 'appraisal'
to manage gems for each Rails version.
https://github.com/thoughtbot/appraisal?tab=readme-ov-file#setup
For versions other than Rails 8.0, there are no issues with the traditional gem versions, and no changes to Gemfile are necessary.
Instead, since bee3539#diff-4fc39a0aadaf0ef5048e145a93b08c08740e7efd36c6890426664cea221a622eR51 is explicitly mentioned, this alone should make the Rails 8.0 tests work.
What would be the best approach? Require ruby 3.1 for the next release, or stay backwards compatible?
This is just my opinion, but since Ruby 3.1 hasn't reached EOL yet, I think it's fine to include Ruby 3.1 in the next release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I've changed the Gemfile back to the older sqlite3 version, and in the appraisal file I've made an exception for rails 8
It looks like a lot of unrelated things are broken, not sure how to proceed. |
@jewilmeer Indeed, I was able to reproduce the issue on master. I suspect that because the json gem isn't pinned, the latest CI runs install a version that is greater than 2.7.6, the newer versions'
The test fails because RailsAdmin's Json field class calls JSON.pretty_generate, and the test's regex is expecting at least one newline from its result. As a quick test, I made the following change, and the tests pass: diff --git a/spec/rails_admin/config/fields/types/json_spec.rb b/spec/rails_admin/config/fields/types/json_spec.rb
index a1e03958..a749d930 100644
--- a/spec/rails_admin/config/fields/types/json_spec.rb
+++ b/spec/rails_admin/config/fields/types/json_spec.rb
@@ -24,7 +24,7 @@ RSpec.describe RailsAdmin::Config::Fields::Types::Json do
it 'returns correct value for empty json' do
allow(object).to receive(:json_field) { {} }
actual = field.with(bindings).formatted_value
- expect(actual).to match(/{\n+}/)
+ expect(actual).to match(/{\n*}/)
end
it 'retuns correct value' do
@@ -72,7 +72,7 @@ RSpec.describe RailsAdmin::Config::Fields::Types::Json do
it 'returns correct value for empty json' do
allow(object).to receive(:json_field) { {} }
actual = field.with(bindings).export_value
- expect(actual).to match(/{\n+}/)
+ expect(actual).to match(/{\n*}/)
end
it 'returns correct value' do I don't see any need for the newline, so I'd lean towards just updating the test (whether to split the change into a separate PR is up to you and the maintainers), but I'm also not a frequent user of RailsAdmin. |
@dsinn Thanks for figuring this out. I'm not sure what the idea of the gem versioning of the gem is. Pinning certain gems at a higher version might force some of the gem users to upgrade. Not sure if the idea is to keep it as wide as possible. But I'm also not sure if the json spec makes a lot of sense. We might want to test if the result is parseable as JSON, instead of matching against a string with regexp. |
Gemfile
Outdated
@@ -49,7 +49,7 @@ group :active_record do | |||
platforms :ruby, :mswin, :mingw, :x64_mingw do | |||
gem 'mysql2', '>= 0.3.14' | |||
gem 'pg', '>= 1.0.0' | |||
gem 'sqlite3', '~> 1.3' | |||
gem 'sqlite3', '~> 2.2' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing a Gemfile entry causes every files under gemfiles/
to change, once you run appraisal generate
. If your intention is to use sqlite3 ~> 2.2 only for Rails 8, you need to move this to Appraisal so other Rails versions can stay on sqlite 1.x.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've upgraded the sqlite version for all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't. That's why builds for older Rails versions are failing.
https://github.com/railsadminteam/rails_admin/actions/runs/11931789920/job/33255380343?pr=3702
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jewilmeer
Please check, as this #3702 (comment) is linked with @mshibuya's comment.
I support the JSON spec change #3702 (comment) proposed by @dsinn, as the existence of newline is irrelevant to the purpose of the spec here. |
I've managed to update to sqlite3 2.2 only for rails 8, but the dummy app in the specs is not happy with in. I don't have the knowledge to resolve it myself. Can any of you help out? |
OK I can take care of the rest. Thanks. |
- Fix Rails 7.0/7.1 builds - Remove spec/dummy_app/Gemfile.rails6, as it's not used much
@mshibuya |
Just released 3.3.0, which includes this change 🚀 |
As rails 8 came out, and not a lot has changed internally since 7.2, it might just work :-)