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

Test with Ruby 3.1 #498

Merged
merged 6 commits into from
Jan 29, 2022
Merged

Conversation

aried3r
Copy link
Contributor

@aried3r aried3r commented Jan 26, 2022

No description provided.

gemfiles/rails_7.0_ruby_3.1.gemfile Show resolved Hide resolved
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"
Copy link
Contributor Author

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.

Copy link
Owner

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)>'

Copy link
Owner

@bensheldon bensheldon Jan 27, 2022

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.

- 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.

Copy link
Contributor Author

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.

@aried3r aried3r marked this pull request as draft January 26, 2022 12:38
@aried3r
Copy link
Contributor Author

aried3r commented Jan 27, 2022

Should we test Ruby 3.1 also with additional Postgres versions?

@bensheldon
Copy link
Owner

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
@aried3r
Copy link
Contributor Author

aried3r commented Jan 27, 2022

I think we only need one version of CRuby and one version of JRuby to test across different different versions of Postgres.

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?

@bensheldon
Copy link
Owner

No perfect option. Let's leave it at a CRuby 3.0 because that is compatible across more versions of Rails.

@aried3r aried3r marked this pull request as ready for review January 28, 2022 11:09
@aried3r
Copy link
Contributor Author

aried3r commented Jan 28, 2022

I believe the test failure is unrelated to this PR and simply a timeout. Would you like anything else before this can get merged?

Copy link
Owner

@bensheldon bensheldon left a 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! 🙏

@bensheldon bensheldon merged commit 7d4c71a into bensheldon:main Jan 29, 2022
@bensheldon bensheldon added the dependencies Pull requests that update a dependency file label Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants