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
4 tasks
stevepolitodesign opened this issue Jun 6, 2024 · 7 comments · May be fixed by #1239
Open
4 tasks

Prepare for Rails 8 #1213

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

Comments

@stevepolitodesign
Copy link
Contributor

stevepolitodesign commented Jun 6, 2024

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.

Additionally, I think we need to account for the following:

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

@stevepolitodesign
Copy link
Contributor Author

I'm going to document my experience here as well:

❯ rails -v
Rails 8.0.0

In an effort to ensure we're using the latest code (not release) I used the command to build off 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

Which resulted in the following failure:

Fetching https://github.com/thoughtbot/suspenders.git
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
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.

This corresponds with this comment.

stevepolitodesign added a commit that referenced this issue Dec 5, 2024
In the process of supporting Rails 8 via #1213, we realized we needed to
install a local build.

This commit simply introduces a `--suspenders-local` option, and
documents how to build locally.

Co-Authored-By: Nick Charlton <[email protected]>
stevepolitodesign added a commit that referenced this issue Dec 5, 2024
In the process of supporting Rails 8 via #1213, we realized we needed to
install a local build.

This commit simply introduces a `--suspenders-local` option, and
documents how to build locally.

Co-Authored-By: Nick Charlton <[email protected]>
@stevepolitodesign
Copy link
Contributor Author

stevepolitodesign commented Dec 5, 2024

@nickcharlton

bin/setup → fails because db/schema.rb doesn't exist (is this existing behaviour?)

This is was an existing bug #1224

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