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 Ruby 3.1 to Circle tests #2129

Merged
merged 2 commits into from
Jan 25, 2022
Merged

Conversation

jordan-brough
Copy link
Contributor

@jordan-brough jordan-brough commented Jan 21, 2022

This PR builds on #2127 and #2128 to add test coverage for Ruby 3.1.
i.e.: Ignore the first 2 commits in this PR. (update: Those PRs were merged and I've rebased this)

A couple things:

  • Remove usage of YAML aliases in the test example_app to work around a Psych 4 incompatibility with Rails 6. (See the commit message on that commit for more details).
  • Add Circle configs for testing Ruby 3.1, and limit it to testing Rails 6.1. I don't think Rails 6.0 is compatible with Ruby 3.1 (e.g. see here) and I was seeing some test failures that seemed to confirm that, iirc. When Rails 7 test coverage is added then Ruby 3.1 can cover that as well of course.
  • This uses CircleCI's new cimg/ruby docker image, which replaces the old circleci/ruby docker image, because the Ruby 3.1 hasn't been added to the latter and it sounds like it won't be. We could probably update everything to cimg/ruby if we want. Or we could test it out a bit on Ruby 3.1 for a while first.

Does that all seem reasonable?

@jordan-brough jordan-brough force-pushed the test-ruby-3.1 branch 2 times, most recently from 73b826e to a27ec17 Compare January 24, 2022 17:33
Ruby 3.1 ships with Psych 4. Psych 4 switched it's default YAML parsing mode to
a safer mode, including not allowing aliases. This broke parsing of
"secrets.yml" in Rails, if the secrets file contains any aliases.

Some discussion: https://bugs.ruby-lang.org/issues/17866

Rails PR 42687 implemented a fix, and that fix was included in Rails 7 here:
rails/rails@0ebb708

It was also included in the Rails 6-1-stable branch here:
rails/rails@aac3edb

But that commit happened after Rails 6.1.4 was published, and no patch-level
releases have been made for Rails 6.1 since that commit. Only security-level
releases have been published. I assume if Rails 6.1.5 is released that it will
contain the fix.

Until Rails 6.1.5 is released, the best option to be able to test Ruby 3.1
against Rails 6.1 apps is probably to just eliminate any aliases in yaml files
that Rails uses.
Using new CircleCI image "cimg/ruby"
@jordan-brough jordan-brough changed the title [DRAFT] Add Ruby 3.1 to Circle tests Add Ruby 3.1 to Circle tests Jan 24, 2022
@jordan-brough jordan-brough marked this pull request as ready for review January 24, 2022 17:45
@jordan-brough
Copy link
Contributor Author

@nickcharlton @pablobm The other 2 PRs were merged (thank you!) so I rebased this, and the tests are green so I'm marking this "ready for review". There are a few thoughts/questions in the PR description that might merit feedback/changes.

- run: bundle exec appraisal install
- run: bundle exec appraisal rails61 rspec
docker:
- image: cimg/ruby:3.1-browsers
Copy link
Member

Choose a reason for hiding this comment

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

Do we need the browsers image here, or is the standard ruby:3.1 with the orb enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I understand correctly, the browsers variant supplies the dependencies needed for the orb to work:

The browsers variant is designed to work in conjunction with the CircleCI Browser Tools orb. You can use the orb to install a version of Google Chrome and/or Firefox into your build.

https://circleci.com/developer/images/image/cimg/ruby#browsers

But I'll push up a quick test commit just to confirm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nickcharlton I pushed a commit with cimg/ruby:3.1 and it seems to work just fine. And looking at the 4 test runs of the previous commit vs the 4 test runs of that commit and it doesn't seem to take significantly longer to install chrome or anything like that on cimg/ruby:3.1 afaict. Shall we just go with this? I'm also opening a ticket w/ CircleCI to ask them what the -browsers image is needed for. Do you read that blurb from them differently? I'm not sure why one would need it.

Copy link
Contributor Author

@jordan-brough jordan-brough Jan 25, 2022

Choose a reason for hiding this comment

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

Ah, actually I forgot for a bit that this PR only uses cimg/ruby in the 3.1 tests. And there is a difference of 7s (with -browsers) vs 23s (without `-browsers) for "Install Google Chrome". We could try testing each version a few more times to confirm the speed difference. I've also opened that ticket w/ Circle to confirm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nickcharlton I went ahead and did some speed testing and it does seem like the difference is probably that some stuff is preinstalled on -browsers, which makes the browser installation faster. However, I'd bet it probably makes the image download longer also.

What I saw:

test run "-browsers"? env spin up (incl download) chrome install total
link yes 30s 9s 39s
link yes 6s 7s 13s
link yes 13s 7s 20s
link no 5s 18s 23s
link no 12s 17s 29s
link no 3s 19s 22s

Lmk what you think and which you prefer. Circle has enough variability in timing that it's hard to really get a firm idea of things 😕

Copy link
Member

Choose a reason for hiding this comment

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

Oh I see. Right, it is intentional on Circle's part. I didn't think to even look at that, so thanks for highlighting it.

I think we should go with what they recommend — it's a pity your table shows how variable the runs are (thanks for doing that!).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 sounds good. I've force-pushed to remove the commit that tried out the non--browsers variant.

@nickcharlton
Copy link
Member

Thanks for this! I'm going to go ahead and merge it now!

@nickcharlton nickcharlton merged commit e997c09 into thoughtbot:main Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants