-
Notifications
You must be signed in to change notification settings - Fork 442
next_rails
With the help of next_rails, a toolkit to upgrade Rails application, we can easily upgrade Rails to the next major/minor version. In Rails version upgrades, issues are often arising due to upstream changes like the removal of deprecated features. Instead of addressing issues in a single pull request, next_rails
allows us to do so in multiple pull requests. It makes the whole upgrade process easier to review and more approachable.
next_rails
is just like any other gem in the Gemfile
. Once installed, we set it up with next --init
and this command slightly changed the Gemfile
while also creating a new file Gemfile.next
. This new file is a symlink to Gemfile
. The following changes were introduced:
def next?
File.basename(__FILE__) == 'Gemfile.next'
end
if next?
gem 'rails', '~> 6.1'
else
gem 'rails', '~> 6.0'
end
To run Bundler with the next Rails version, you can prefix any Bundler call with next
like next bundle install
or next bundle exec rails s
. This will use the gems defined in Gemfile.next.lock
, not in Gemfile.lock
.
In the RailsVersion module, we define a module method for the next Rails version:
# Example for Rails 6.1.x
def self.is_6_1?
Rails::VERSION::MAJOR == 6 && Rails::VERSION::MINOR == 1
end
With this module, we can then check in a guard clause if the application is currently running with the next Rails version:
if RailsVersion.is_6_1?
# code for the next Rails version
else
# code for the current Rails version
end
While we are tackling the various issues arising from the next Rails version upgrade, we keep those guard clauses around and everything will keep working as usual in the current Rails version.
To have the continuous integration test your changes, be sure to prefix your branch name with next_rails-
. This branch has to be upstream, so pushed directly to https://github.com/openSUSE/open-build-service, not to your fork.
We can safely upgrade the Rails version in the Gemfile once all issues arising from the next Rails version have been addressed. The code for the newly upgraded Rails version is kept and the guard clauses with its code for the previous Rails version can then be removed.
The version of Rails and other gems tracked in Gemfile.next.lock
have to be updated from time to time to follow the dependency updates happening on the default Gemfile.lock
. This is how you can achieve this:
- Overwrite
Gemfile.next.lock
with a copy ofGemfile.lock
:
cp src/api/Gemfile.lock src/api/Gemfile.next.lock
- Inside your development environment, update the Rails version:
next bundle update rails
- Cache the new gems from
Gemfile.next.lock
:
This is needed for the CI since we use bundler install --local
.
next bundle cache
- Commit and push the changes to an upstream branch with the
next_rails-
prefix, then submit a pull request.
- Development Environment Overview
- Development Environment Tips & Tricks
- Spec-Tips
- Code Style
- Rubocop
- Testing with VCR
- 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
- next_rails
- Ruby Update
- Rails Profiling
- Installing a local LDAP-server
- Remote Pairing Setup Guide
- Factory Dashboard
- osc
- Setup an OBS Development Environment on macOS
- Run OpenQA smoketest locally
- Responsive Guidelines
- Importing database dumps
- Problem Statement & Solution
- Kickoff New Stuff
- New Swagger API doc
- Documentation and Communication
- GitHub Actions
- How to Introduce Software Design Patterns
- Query Objects
- Services
- View Components
- RFC: Core Components
- RFC: Decorator Pattern
- RFC: Backend models