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

Upgrade to Rails 7 #307

Merged
merged 19 commits into from
Jan 19, 2022
Merged

Upgrade to Rails 7 #307

merged 19 commits into from
Jan 19, 2022

Conversation

rosle
Copy link
Contributor

@rosle rosle commented Jan 6, 2022

What happened

  • Upgrade Rails to 7.0.1

There are new way to manage the JS and CSS asset. But I decided to do that later. Right now, in this PR, We will stick with Webpacker gem as before.

Insight

To upgrade our template to support Rails 7

Gem Changes Note
rails Updated 6.1.1 -> 7.0.0
webpacker Updated 5.2.0 -> 5.4.3
sass-rails Removed sass-rails is removed, please check out the new guide
sassc-rails Moved to all envs scope sass-rails is removed, please check out the new guide

The new Hotwire integrations, turbo and stimulus, are also off by default following our old template.

📝 Note

For the next steps, we will need to:

Proof Of Work

Screen Shot 2565-01-07 at 12 13 24

@rosle rosle self-assigned this Jan 6, 2022
@rosle rosle force-pushed the chore/upgrade-to-rails-7 branch from f4d7a73 to f8064a6 Compare January 7, 2022 09:02
@rosle rosle force-pushed the chore/upgrade-to-rails-7 branch from dae7b3b to 7562210 Compare January 10, 2022 09:06
@rosle rosle requested a review from a team January 10, 2022 10:43
@rosle rosle marked this pull request as ready for review January 10, 2022 11:14
@@ -8,3 +8,5 @@
apply 'config/environments/development.rb'
apply 'config/environments/production.rb'
apply 'config/environments/test.rb'

copy_file 'config/initializers/backtrace_silencers.rb'
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 initializer has been removed from the base application. so now I updated to copy file.

Copy link
Contributor

Choose a reason for hiding this comment

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

But why add it back? Do we make use of it in general?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I'm not sure about that. Seems we're modifying this file to make it work with engine structure. This change is from this issue - #147

Maybe we can remove it first and keep our eyes on the error. If we still have the issue, we can add it back again. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Since it might be hard to reproduce the issue (unless we try creating an engine 😅 ), let's keep it. It is likely that part of Rails did not change much in that version and there this is likely still needed.

@malparty
Copy link
Member

That's a very interesting piece of an update! Thanks!

I was able to run it locally and display the sample page. ✅

Though I go a few errors on the way, I'm not sure if this was already like this in the template:


  • The template rails new -m XXX command ended up with an error:

    image

  • Should we add in the README.md to run bundle install before rake db:setup? :)

    image

  • Running rake db:setup recommends to run bin/rails db:migrate but this command generates many warnings and no "success confirmation" message. 🤔

    image

@olivierobert olivierobert added this to the 5.0.0 milestone Jan 11, 2022
Copy link
Contributor

@olivierobert olivierobert left a comment

Choose a reason for hiding this comment

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

The update seems very complete so just a few minor questions and concerns

gem 'sidekiq' # background processing for Ruby
gem 'bootsnap', require: false # Reduces boot times through caching; required in config/boot.rb
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
# gem 'jbuilder' # Build JSON APIs with ease
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we rarely (or never) use jbuilder, how about removing it entirely?

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
# gem 'jbuilder' # Build JSON APIs with ease
# gem 'redis' # Use Redis adapter to run Action Cable in production
# gem 'kredis' # Use Kredis to get higher-level data types in Redis
Copy link
Contributor

Choose a reason for hiding this comment

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

Is that added by default? It feels a bit strange to have commented out dependencies 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup I brought this from the project that is generated from default rails template 🙌

Screen Shot 2565-01-12 at 16 47 12

I put comment because I'm not sure if we will use it or not (Same for jbuilder)

By putting comment on them, My idea is to help us to not forget to checkout those gems later if we want to include it or not. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Understood that it comes by default so it can be kept commented as done here

"bootstrap.native": "3.0.13",
JSON
end
run 'yarn add bootstrap@^4.5.2'
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 Bootstrap 5 should be used instead? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed Long, I'll create an issue for that. 👍

JSON
end
run 'yarn add bootstrap@^4.5.2'
run 'yarn add bootstrap.native@^3.0.13'
Copy link
Contributor

Choose a reason for hiding this comment

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

by using Boostrap 5 which doesn't use jQuery, bootstrap native is no longer needed.

@rosle
Copy link
Contributor Author

rosle commented Jan 12, 2022

Thank you for trying it out @malparty 🎊 👨‍💻 👩‍💻 🎊

  • The template rails new -m XXX command ended up with an error:
    image

For the warning

warning: parser/current is loading parser/ruby27, which recognizes2.7.5-compliant syntax, but you are running 2.7.2.
Please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.

I've also seen the parser warning too, I tried to search for the solution but it seems safe. Let me recheck it when working on upgrading Ruby to version 3. Hope that it will get rid of that warning 👍

For the error that is blocking you from generating the project. I've never faced it. But I guess it is from the spring version 🤔 not sure why I have

Screen Shot 2565-01-12 at 15 51 18
(I use asdf)

For this, I will need your help to generate the project again. I'll try removing the spring-watcher-listen which is blocking us from having newer version of Spring -> 4.0. (Maybe I'll comment out and add todo once they support Spring 4.0, I saw someone already created the issue there.) I'll ping you to test again when finish. 💪


  • Should we add in the README.md to run bundle install before rake db:setup? :)
    image
  • Running rake db:setup recommends to run bin/rails db:migrate but this command generates many warnings and no "success confirmation" message. 🤔
    image

For the db:setup, It perfectly run fine for me right after generating the project.

Screen Shot 2565-01-12 at 16 21 37

In one of the step in template, we can see it is running bundle install.

Screen Shot 2565-01-12 at 16 24 25

I'm not sure if the problem is from when generating the project from the template, it might not run successfully. 🤔 I think I need your help to try again to see if the bundle install is run successfully when it is generating the project.

and for the reason the bin/rails db:migrate does not yield any message. I think it's because we don't any the schema file in the project yet. 💭


🕵️ I'm dropping the command to test again here so anyone could try: 🕵️

rails new <app_name> -m https://raw.githubusercontent.com/nimblehq/rails-templates/chore/upgrade-to-rails-7/template.rb

@malparty
Copy link
Member

@rosle

ℹ️ These are my sprint versions:

image


✅ I've run the command a new time: it seems better as this time it ran until the end 👍

image


💡 Should we just add in the README.md to run bundle install before the rake db:setup cmd? :D

image

✅ DB migration: Yes, you are right, no schema to be deployed at the moment! This is not an issue then :)


So overall, my issue is now fixed!! Thanks! 🚀

This was referenced Jan 13, 2022
@rosle rosle force-pushed the chore/upgrade-to-rails-7 branch from 8613fd1 to 18ea757 Compare January 13, 2022 10:34
@rosle rosle mentioned this pull request Jan 18, 2022
@rosle rosle merged commit 9f625bb into develop Jan 19, 2022
@rosle rosle deleted the chore/upgrade-to-rails-7 branch March 18, 2022 04:01
@rosle rosle mentioned this pull request Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants