-
Notifications
You must be signed in to change notification settings - Fork 484
Rails Update
- Using next_rails... or How to Stay Sane While Upgrading Rails to the Next Major/Minor Version
- Choosing a bundle
- Choosing gems to install
- Choosing code to run
- Choosing CI Jobs to run
- How to get to a usable new Rails version
In Rails version upgrades, issues often arise due to removal of deprecated Rails features and similar. Instead of addressing all issues in a single GIANT pull request, using next_rails and conditional CI jobs allow us to do so in multiple small pull requests without affecting the current Rails version.
next_rails allows us to boot our app against two dependency bundles. Our current bundle (Gemfile + Gemfile.lock) and a bundle for the next Ruby on Rails version (Gemfile.next + Gemfile.next.lock). If you prefix any bundler command with next then it's using the bundle for the next Ruby on Rails version. Like...
next bundle installnext bundle exec rails c
Inside our Gemfile you can use the next? method to distinguish between bundles. Like Gemfile contains by default this:
if next?
gem 'rails', '~> 8.0.0'
else
gem 'rails', '~> 7.2.0'
endIf we are using the bundle for the next Ruby on Rails version we install the rails GEM with the version 8.0.0 (or similar), if we are using our normal bundle it's using the version 7.2.0 (or similar).
This way you can add different gems to one bundle without affecting the other.
You may need to branch application code as well:
if NextRails.next?
# Do things "the Rails 8.0 way"
else
# Do things "the Rails 7.2 way"
endOr use NextRails.current? for the inverse check:
if NextRails.current?
# Do things "the Rails 7.2 way"
else
# Do things "the Rails 8.0 way"
endBy default our CI does not run jobs with the next Ruby on Rails version.
If your PR comes from a upstream branch that starts with the string next_rails- then our CI will run...
- next_rails-linters:
rubocop,haml_lint,database_consistencyetc. - next_rails-rspec: all
rspecspec - next_rails-minitest: all
minitesttests
with the bundle for the next Ruby on Rails version.
Those CI jobs are NOT required to be green to get merged.
Usually you start with getting the bundle for the next Rails version updated.
- Create a branch:
git checkout -b next_rails-bundle-update - Start the dev-env:
docker compose run --rm frontend /bin/bash -l - Make sure to choose the right gems to install
- Install the bundle:
next bundle install - Commit changes:
git add -A; git commit -av -m 'Updated Gemfile.next.lock' - Push branch upstream:
git push upstream next_rails-bundle-update - Create the PR and get it merged
That PR will most likely already show you a bunch of failing next_rails... CI jobs, that's fine as they are not required to be green.
Now the fun starts 🥳 You need to follow the Rails Upgrade Guide and get all next_rails... CI jobs green. This usually at least means running next bundle exec rails app:update and deciding what to do with the proposed changes.
For each of the changes you can submit individual PRs
- Create another branch:
git checkout -b next_rails-fix-something-rails-app-update-told-me - Fix the CI error using the methods above
- Push branch upstream:
git push upstream next_rails-fix-something-rails-app-update-told-me - Create the PR and get it merged
Repeat until all the next_rails... CI jobs turn green while the
Once those next_rails... jobs are green you...
- make the new bundle the default in
Gemfileif next? gem 'rails', '~> 9.0.0' else gem 'rails', '~> 8.0.0' gem 'foo' gem 'bar' end
- Drop all old code guarded by
NextRails.next? - Configure the new framework defaults
- Create another branch:
git checkout -b next_rails-8.0 - Push branch upstream:
git push upstream next_rails-8.0 - Create the PR and get it merged
- Development Environment Overview
- Development Environment Tips & Tricks
- Spec-Tips
- Code Style
- Rubocop
- Testing with VCR
- Test in kanku
- Authentication
- Authorization
- Autocomplete
- BS Requests
- Events
- ProjectLog
- Notifications
- Feature Toggles
- Build Results
- Attrib classes
- Flags
- The BackendPackage Cache
- Maintenance classes
- Cloud uploader
- Delayed Jobs
- Staging Workflow
- StatusHistory
- OBS API
- Owner Search
- Search
- Links
- Distributions
- Repository
- Data Migrations
- Package Versions
- Rails Update
- Ruby Update
- Updating-rake-or-rack
- Brakeman
- Run OpenQA smoketest locally
- Factory Dashboard
- Responsive Guidelines
- osc
- Importing database dumps
- Problem Statement & Solution
- Kickoff New Stuff
- Mob-Programming Sessions
- New Swagger API doc
- Documentation and Communication
- GitHub Actions
- Setup an OBS Development Environment on macOS
- Remote Pairing Setup Guide
- How to Introduce Software Design Patterns
- Query Objects
- Services
- View Components
- RFC: Core Components
- RFC: Decorator Pattern
- RFC: Backend models
- RFC: Hotwire Turbo Frames Pattern