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 Rails 7 support #4220

Merged
merged 17 commits into from
Apr 12, 2022
Merged

Add Rails 7 support #4220

merged 17 commits into from
Apr 12, 2022

Conversation

peterberkenbosch
Copy link
Contributor

@peterberkenbosch peterberkenbosch commented Dec 10, 2021

Description

With the release of Rails 7.0.0 we should start preparing Solidus edge to be supported. This PR starts with that.

Default using the latest released rails 7.0 on setup and sandbox creation:

bin/setup
bin/sandbox

There is however still an error showing up with title: TypeError in Spree::Home#index

no implicit conversion of String into Integer

Solving this with:

add mini_magick to sandbox/config/application.rb since the default :vips does not work out of the box with Solidus just yet. (see more details below).

config.active_storage.variant_processor = :mini_magick

If we want to use :vips by default we have to change core/app/models/concerns/spree/active_storage_adapter/attachment.rb#variant:

from:

def variant(style = nil)
  size = style_to_size(style)
  @attachment.variant(
    resize_to_limit: size,
    strip: true
  ).processed
end

to:

def variant(style = nil)
  size = style_to_size(style)
  @attachment.variant(
    resize_to_limit: size.map(&:to_i)
  ).processed
end

The size elements have to be an integer, and strip is not a valid command for :vips

Dependencies that we wait for new release:

  • ransack
  • devise
  • awesome_nested_set tracking PR
  • font-awesome-rails
  • rails-i18n
  • canonical-rails support for Rails 7.0.1 tracking PR
  • config.active_storage.variant_processor = :mini_magick automation with install generator?
  • Rails ~> 7.0.0 depends on Ruby >= 2.7.0
  • Netlify & CircleCI update to Ruby >= 2.7.0

Checklist:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have updated Guides and README accordingly to this change (if needed)
  • I have added tests to cover this change (if needed)
  • I have attached screenshots to this PR for visual changes (if needed)

Copy link
Member

@jarednorman jarednorman left a comment

Choose a reason for hiding this comment

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

Thanks for getting a head start on this @peterberkenbosch!

@peterberkenbosch
Copy link
Contributor Author

Updated this with the last few missing dependencies to run the sandbox.

@peterberkenbosch
Copy link
Contributor Author

Updated with the latest released gems. Wondering if we want to stop supporting Rails 5.2? Also not sure why the added circlci build for postgres_rails70 is not being picked up by circleCI, probably needs someone with more permissions on the CircleCI account to enable or approve that build step?

@jarednorman
Copy link
Member

Oooh, look at that green check mark.

@BenMorganIO
Copy link
Contributor

BenMorganIO commented Jan 28, 2022

I know I'm not supposed to leave emoji specific Github comments, but

😎

Thanks Peter!

@denys-medynskyi
Copy link

hey 👋

Looking forward to Rails 7 🎉

Anything I can do to help?
Do we have an ETA of merging this PR?

Gemfile Outdated
@@ -11,13 +11,18 @@ group :backend, :frontend, :core, :api do
else
gem 'rails', ENV['RAILS_VERSION'] || '~> 6.1.0', require: false
end

if ENV['RAILS_VERSION'] == '7.0.0'
Copy link

Choose a reason for hiding this comment

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

Does this need to be adjusted to compare against any version later than 7.0.0 since 7.0.1 is already out?

Thank you for opening this PR, by the way, we'd love to bump to Rails 7 ASAP and Solidus is one of the few things preventing that for us.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this needs to be a bit smarter. Good catch!

@jarednorman
Copy link
Member

@peterberkenbosch Now that specs are green, should we be taking a more serious look at this PR?

@peterberkenbosch
Copy link
Contributor Author

Yes! Let's do that!

Copy link
Member

@jarednorman jarednorman left a comment

Choose a reason for hiding this comment

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

Can you rebase out some of the Gemfile churn as the different versions of things get updated/released? We also don't need stuff like changing the version of devise and then removing it altogether both in the git history.

Left a couple small comments, but generally this all looks good. Thanks for taking this on, Peter. 🙏🏻

@@ -7,7 +7,7 @@ module CurrentHost
extend ActiveSupport::Concern

included do
if Gem::Requirement.new("> 5.2").satisfied_by?(Rails.gem_version)
if Gem::Requirement.new(">= 6").satisfied_by?(Rails.gem_version)
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain why you're doing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The remove deprecation warning on Rails 7. Might be better suitable for standalone PR now that I think of it. So we have 1 PR focussed only on adding Rails 7 compatibility.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's pertinent to have it on this PR. Besides, if there's a warning, CI will fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah.. thanks! Let's keep it then.

Copy link
Member

Choose a reason for hiding this comment

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

Hey @peterberkenbosch, what was the deprecation warning?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

host is already set or something like that. I'm happy to remove all non-essential changes here actually.

Copy link
Member

Choose a reason for hiding this comment

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

Just wanted to understand if that was coming from Solidus or Rails, because if it's the latter and we will receive warnings, the CI won't fail, it only fails for Solidus deprecations. cc @waiting-for-dev

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, it's from Rails, not Solidus.

@waiting-for-dev
Copy link
Contributor

Wondering if we want to stop supporting Rails 5.2?

I would say YES! Thoughts? cc @kennyadsl

not sure why the added circlci build for postgres_rails70 is not being picked up by circleCI

@peterberkenbosch, besides defining it, you need to add a new job within workflows -> build -> jobs.

However, what we need to add is a job for postgres_rails61, and update the default Rails version to 7.0 in the Gemfile.

@kennyadsl
Copy link
Member

For our current policy, we should stop supporting a specific Rails version when it no more receives security patches, and 5.2 appears to be still receiving them, see: https://guides.rubyonrails.org/maintenance_policy.html#severe-security-issues. Also, changing this will probably require a major bump for Solidus, because this would be technically a breaking change, isn't it?

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

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

Thanks 7️⃣ times (at least), @peterberkenbosch! I left some comments, let me know if I'm missing something.

Gemfile Outdated Show resolved Hide resolved
bin/sandbox Outdated
@@ -53,10 +53,10 @@ fi
cd ./sandbox
cat <<RUBY >> Gemfile

gem 'awesome_nested_set', github: 'peterberkenbosch/awesome_nested_set', branch: 'rails-7-support'
Copy link
Member

Choose a reason for hiding this comment

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

Now that collectiveidea/awesome_nested_set#460 has been merged, why not using:

gem 'awesome_nested_set', github: 'collectiveidea/awesome_nested_set'

as you did in the Gemfile?

bin/sandbox Outdated
gem 'solidus', path: '..'
gem 'solidus_auth_devise', '>= 2.1.0'
gem 'rails-i18n'
gem 'solidus_i18n'
gem 'solidus_i18n', github: 'solidusio/solidus_i18n'
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 to release a new version of solidus_i18n with the code currently in master?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so, revisiting this now. 2.1.1 should have the latest from master now anyway right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Confirming we don't need to do this anymore. There are a few deprecation warnings showing up, looking into those as well, but it's working as expected right now.

@peterberkenbosch
Copy link
Contributor Author

Thanks! Updating this PR, and will respond back to the questions, suggestions etc.

@denys-medynskyi
Copy link

hey @peterberkenbosch
Thanks 8️⃣ times.

Do you need any help with this branch getting merged?

@peterberkenbosch
Copy link
Contributor Author

hey @peterberkenbosch Thanks 8️⃣ times.

Do you need any help with this branch getting merged?

Not yet, rebasing all the cruft right now so we have a clean PR to work from.

@peterberkenbosch peterberkenbosch changed the title Allow Rails 7.0.0 Allow Rails 7 Feb 8, 2022
@peterberkenbosch
Copy link
Contributor Author

Should we track latest Rails 7 release by default on our main (unreleased) branch? We probably have to bump versions here too?

@waiting-for-dev
Copy link
Contributor

Should we track latest Rails 7 release by default on our main (unreleased) branch? We probably have to bump versions here too?

I'm not sure I get it. Where exactly should we bump versions?

@peterberkenbosch
Copy link
Contributor Author

@waiting-for-dev I was thinking the Solidus version, but that's not really needed in this PR.

@peterberkenbosch
Copy link
Contributor Author

for Rails 7.0.1 support we need a few more updates on dependencies, tracking those down now.

@peterberkenbosch peterberkenbosch changed the title Allow Rails 7 Allow Rails ~> 7.0.0 Feb 8, 2022
Rails 7 deprecates Enum#sum in favor of Ruby's Enum#sum, which requires
an initial value when elements are not numbers. In this case, as the
elements are `Spree::StockQuantities`, we reduce with `:+` so that the
first one is taken as the initial value.
Rails 7 deprecates image/jpg mime type, only accepting image/jpeg for
JPG images.

However, we can keep it as a supported image extension for Solidus
applications (`Spree::Config#allowed_image_mime_types`). Host
applications will see the deprecation message, and they will be able to
act as desired. Besides, we can keep it for the Paperclip adapter.
We create a compatibility module to wrap this kind of internal usage of
Rails API
`config.action.view.raise_on_missing_translations` [was deprecated on
Rails 6.1](https://github.com/rails/rails/releases/tag/v6.1.0) in favor
of `config.i18n.raise_on_missing_translations`. It
was [removed on Rails
7.0](https://edgeguides.rubyonrails.org/7_0_release_notes.html#action-view).
@denys-medynskyi
Copy link

Looks like failed test is a false positive 🤔 pr maybe eql shouldn't be used in this test, because as I see it is just different instance...

Failure/Error: expect(shipment.stock_location).not_to eql stock_item.stock_location

  expected: value != #<Spree::StockLocation id: 1998, name: "NY Warehouse", created_at: "2022-04-08 10:41:01", updated_at:..., position: 1, restock_inventory: true, fulfillable: true, code: nil, check_stock_on_transfer: true>
       got: #<Spree::StockLocation id: 1998, name: "NY Warehouse", created_at: "2022-04-08 10:41:01", updated_at:..., position: 1, restock_inventory: true, fulfillable: true, code: nil, check_stock_on_transfer: true>

  (compared using eql?)

  Diff:
  @@ -1,4 +1,4 @@
  -#<Spree::StockLocation:0x0000564a1895da40
  +#<Spree::StockLocation:0x0000564a18960ad8
    id: 1998,
    name: "NY Warehouse",
    created_at: Fri, 08 Apr 2022 10:41:01 UTC +00:00,
./spec/models/spree/order_inventory_spec.rb:181:in `block (6 levels) in <top (required)>'

@kennyadsl
Copy link
Member

@denys-medynskyi should be a flaky, re-running!

@denys-medynskyi
Copy link

It is green now 💚

@denys-medynskyi
Copy link

@kennyadsl can you merge it please 🙏

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

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

👍 Approved.

@denys-medynskyi we need to wait for a review from another core team member before merging.

This commit reverts part of 0cd2431

Even if we now support Rails 7, which only works from Ruby 2.7 onwards,
we also still support Rails 5.2, which works from Ruby 2.5.

Deprecating Ruby versions is a backward incompatible change, so we'll
do that in major releases.
@waiting-for-dev
Copy link
Contributor

I added a new commit reverting dropping support for Ruby 2.5 & Ruby 2.6. We still support Rails 5.2, which works from 2.5 onwards. We'll deprecate Ruby & Rails versions on major releases, as that's backward-incompatible changes.

@denys-medynskyi
Copy link

We are good to merge 🎉

@kennyadsl kennyadsl merged commit 9fbcce5 into solidusio:master Apr 12, 2022
@mslinn
Copy link

mslinn commented Jul 17, 2022

When might this merged PR get packaged into a released gem? Solidus 3.1.7 still uses Rail 6.1.

@waiting-for-dev
Copy link
Contributor

When might this merged PR get packaged into a released gem? Solidus 3.1.7 still uses Rail 6.1.

@mslinn, we're wrapping everything up and you can expect a new release in the next couple of weeks 🤞

@mslinn
Copy link

mslinn commented Jul 18, 2022

@waiting-for-dev I am new to this project. Is there anything I should watch out for if I clone master and build the gem locally?

@jarednorman
Copy link
Member

You can point your Gemfile at the latest code from GitHub, yes. Some stores do that to stay as up to date as possible.

@mslinn
Copy link

mslinn commented Jul 26, 2022

I wrote up a detailed explanation of what I did to build the gems, and created a GitHub discussion to figure out why solidus_core is not loaded when added to a Rails app, but did not get much response. Might someone take a moment to suggest ideas? ... Thanks!

@asfour75
Copy link

When might this merged PR get packaged into a released gem? Solidus 3.1.7 still uses Rail 6.1.

@mslinn, we're wrapping everything up and you can expect a new release in the next couple of weeks crossed_fingers

Thank you all for the great effort pushing solidus to suppoer rails 7 as soon as possible ..
It's been almost a year .. Yet I'm still searching for offical announcement .. are we there yet ?

@kennyadsl
Copy link
Member

kennyadsl commented Apr 19, 2023

Rails 7 support had been merged and released a while ago, maybe in 3.2 if I recall correctly.

@BenMorganIO
Copy link
Contributor

BenMorganIO commented Apr 20, 2023

@asfour75 Retro Market is on Rails 7 with Solidus 3.3 but we ran 3.2 with 7 as well.

@asfour75
Copy link

Rails 7 support had been merged and released a while ago, maybe in 3.2 if I recall correctly.

Based on the offical gihub page https://github.com/solidusio/solidus
it says:

To add Solidus, begin with a Rails 5.2, 6 or 6.1 application and a database configured and created.

so I assumed it only supports up to 6.1
Nevertheless .. I tried it yesterday on rails 7 and it worekd perfectly ..
Thanks for the note .. nice work

@asfour75
Copy link

@asfour75 Retro Market is on Rails 7 with Solidus 3.3 but we ran 3.2 with 7 as well.

Yup .. I tried 3.3 on Rails 7 .. worked smoothly ..
Thanks

@waiting-for-dev
Copy link
Contributor

Thanks for reporting. The README is currently being fixed at https://github.com/solidusio/solidus/pull/5012/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5

@peterberkenbosch peterberkenbosch deleted the rails7 branch August 24, 2023 08:45
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.

9 participants