-
-
Notifications
You must be signed in to change notification settings - Fork 208
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 with Ruby 3.1 #498
Test with Ruby 3.1 #498
Conversation
Appraisals
Outdated
if ruby_31_or_higher && !jruby | ||
appraise "rails-7.0-ruby-3.1" do | ||
gem "capybara", "~> 3.36" # For Ruby 3.1 support https://github.com/teamcapybara/capybara/pull/2468 | ||
gem "psych", "~> 4.0" |
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.
This should not be necessary, as Ruby 3.1 ships with psych 4. https://www.ruby-lang.org/en/news/2021/12/25/ruby-3-1-0-released/
The error that we're seeing in the test run comes from the test app, which uses aliases. See also https://gist.github.com/yahonda/2776d8d7b6ea7045359f38c10449937b#rails-60z and rails/rails#44090.
I'll try to reproduce this locally but I'm not exactly sure where test_app
takes its gems from. Is it really from appraisal or from this file? https://github.com/bensheldon/good_job/blob/main/Gemfile.lock It would explain the error perhaps, but would also mean that CI always uses the same rails version at least for tests using test_app
.
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 added puts Rails.gem_version
to an initializer inside of test_app
and then ran LOUD=1 bundle exec appraisal rspec
. It was putting out the expected Rails versions from the Appraisal gemfiles.
I just did the most shallow of reproduction locally, by checking out your PR and trying to run bundle exec rspec
and I did get the psych error:
❯ bundle exec rspec
An error occurred while loading ./spec/app/jobs/example_job_spec.rb.
Failure/Error: Rails.application.initialize!
Psych::BadAlias:
Unknown alias: defaults
# ./spec/test_app/config/environment.rb:5:in `<top (required)>'
# ./spec/rails_helper.rb:14:in `require'
# ./spec/rails_helper.rb:14:in `<top (required)>'
# ./spec/app/jobs/example_job_spec.rb:2:in `require'
# ./spec/app/jobs/example_job_spec.rb:2:in `<top (required)>'
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.
Ah, ok, I understand now.
As part of the test setup, before invoking bundle exec appraisal rspec
the test runner sets up the database. That command is executed outside of Appraisal by the Rails version in the root Gemfile, which is Rails 6.1 which isn't compatible with Ruby 3.1.
good_job/.github/workflows/test.yml
Lines 99 to 101 in 6f0a3fa
- name: Set up test database | |
run: bin/rails db:test:prepare | |
working-directory: spec/test_app |
I think the simplest, though maybe embarrassingly simple solution would be to change that command to be bundle exec appraisal spec/test_app/bin/rails db:test:prepare
(removing the change working-directory
). It would run across all the appraisals unnecessarily, but I think the command should be idempotent and it means not having to duplicate the ruby/dependency logic in more places.
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.
Yeah, that's what I thought. I'll try that, thank you.
Should we test Ruby 3.1 also with additional Postgres versions? |
I already think the matrix is a bit excessive 😬 I think we only need one version of CRuby and one version of JRuby to test across different different versions of Postgres. Everything else can be locked to a specific Postgres version. |
Version 4 is the default in Ruby 3.1
Is it coincidence that it was the previously latest CRuby? Or in other words, should it always be the latest stable Ruby version (now 3.1) that's tested across different versions of Postgres or should we leave it with 3.0? |
No perfect option. Let's leave it at a CRuby 3.0 because that is compatible across more versions of Rails. |
I believe the test failure is unrelated to this PR and simply a timeout. Would you like anything else before this can get merged? |
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.
@aried3r this is fantastic. Thank you! I'll re-run CI to get rid of that unrelated timeout and merge. Thank you again! 🙏
No description provided.