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

Prepare for Rails 8 #1213

Open
stevepolitodesign opened this issue Jun 6, 2024 · 5 comments · May be fixed by #1239
Open

Prepare for Rails 8 #1213

stevepolitodesign opened this issue Jun 6, 2024 · 5 comments · May be fixed by #1239

Comments

@stevepolitodesign
Copy link
Contributor

With the upcoming release of Rails 8, we might want to consider re-generating the Engine to extract the dummy app. This way, our tests are running against a Rails 8 dummy app, and might catch regressions.

@stevepolitodesign
Copy link
Contributor Author

As an aside, I wonder if the ability to upgrade an Engine would make for a good commit? I'll have to see if the upgrade process works on Engines.

@nickcharlton
Copy link
Member

I've started to properly investigate this today, with an eye to trying to see how we could automate the testing flow.

The plan is to run through these steps, which @stevepolitodesign shared with me previously:

  1. Generate a new application off the latest build
  2. cd into the app
    a. Run bin/setup
    b. Run bin/rails g scaffold post title
    c. Run bin/rails suspenders:db:migrate
    d. Run bundle exec standardrb --fix
    e. Commit all changes
  3. Push app to GitHub
  4. Ensure CI passes on GitHub

First attempt, with the current release

$ rails -v
Rails 8.0.0
$ rails new app_name \
 --skip-rubocop \
 --skip-test \
 -d=postgresql \
 -m=https://raw.githubusercontent.com/thoughtbot/suspenders/main/lib/install/web.rb
    generate  suspenders:install:web
       rails  generate suspenders:install:web
Could not find generator 'suspenders:install:web'. (Rails::Command::CorrectableNameError)
Run `bin/rails generate --help` for more options.

Second attempt, with current main

$ rails new app_name \
 --suspenders-main \
 --skip-rubocop \
 --skip-test \
 -d=postgresql \
 -m=https://raw.githubusercontent.com/thoughtbot/suspenders/main/lib/install/web.rb
Could not find compatible versions

Because every version of suspenders depends on rails ~> 7.0
  and Gemfile depends on rails ~> 8.0.0,
  suspenders cannot be used.
So, because Gemfile depends on suspenders >= 0,
  version solving has failed.

All good so far — we can assume a new release is around the corner, so running against current main is fine.

Next, I'll run it locally (which will need a few changes), and try again.

@nickcharlton
Copy link
Member

[our hero returns from lunch]

Third attempt, some changes, running locally

diff --git a/lib/suspenders/version.rb b/lib/suspenders/version.rb
index 00621e5..54f5c6e 100644
--- a/lib/suspenders/version.rb
+++ b/lib/suspenders/version.rb
@@ -1,6 +1,6 @@
 module Suspenders
   VERSION = "20240516.0".freeze
-  RAILS_VERSION = "~> 7.0".freeze
+  RAILS_VERSION = "~> 8.0".freeze
   MINIMUM_RUBY_VERSION = ">= 3.1".freeze
   MINIMUM_NODE_VERSION = "20.0.0".freeze
 end
diff --git a/lib/install/web.rb b/lib/install/web.rb
index b071c4d..4fc36a4 100644
--- a/lib/install/web.rb
+++ b/lib/install/web.rb
@@ -27,6 +27,8 @@ def apply_template!
       gem_group :development, :test do
         if ARGV.include?("--suspenders-main")
           gem "suspenders", github: "thoughtbot/suspenders", branch: "main"
+        elsif ARGV.include?("--suspenders-local")
+          gem "suspenders", path: File.expand_path("~/projects/thoughtbot/suspenders")
         else
           gem "suspenders"
         end
$ rails new app_name \
 --suspenders-local \
 --skip-rubocop \
 --skip-test \
 -d=postgresql \
 -m=~/projects/thoughtbot/suspenders/lib/install/web.rb

Which is successful, then next:

  1. bin/setup → fails because db/schema.rb doesn't exist (is this existing behaviour?)
  • We can run bin/setup by first running rails db:migrate though
  1. bin/rails g scaffold post title → successful
  2. bin/rails db:migrate → successful
  3. bundle exec rspec → successful

@nickcharlton
Copy link
Member

I've got a branch in progress for loosening the constraint and also to upgrade the dummy app. I'm following a pattern here I do on Administrate, where at the same time as loosening the constraint, we also upgrade the dummy app (we call it example_app over there, but it has multiple functions).

First, though, I need to do this so that we get a valid version of the sqlite3 gem:

diff --git a/Gemfile b/Gemfile
index 5688624..35eb962 100644
--- a/Gemfile
+++ b/Gemfile
@@ -6,7 +6,7 @@ gemspec
 
 gem "puma"
 
-gem "sqlite3"
+gem "sqlite3", ">= 2.1"
 
 # Start debugger with binding.b [https://github.com/ruby/debug]
 # gem "debug", ">= 1.0.0"

Then I can run: bin/rails app:update (from the root of the project does the right thing).

@nickcharlton nickcharlton linked a pull request Nov 29, 2024 that will close this issue
@nickcharlton
Copy link
Member

I've opened a PR now, with all the significant changes, including upgrading the dummy app. That said, I'd likely want to pull out some of those changes into other PRs (they're not directly related to upgrading and more me being able to run through the tasks).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants