Slide 1

Slide 1 text

#RailsUpgrades | https://fastruby.io/rc2021 Upgrading Rails The Dual Boot Way RailsConf 2021

Slide 2

Slide 2 text

#RailsUpgrades | https://fastruby.io/rc2021 Ernesto Tagwerker 🇦🇷 (he/him)

Slide 3

Slide 3 text

#RailsUpgrades | https://fastruby.io/rc2021 @etagwerker

Slide 4

Slide 4 text

#RailsUpgrades | https://fastruby.io/rc2021 Founder & CTO at OmbuLabs

Slide 5

Slide 5 text

#RailsUpgrades | https://fastruby.io/rc2021 Founder & CTO at FastRuby.io

Slide 6

Slide 6 text

#RailsUpgrades | https://fastruby.io/rc2021 Cleiviane Costa 🇧🇷 (she/her)

Slide 7

Slide 7 text

#RailsUpgrades | https://fastruby.io/rc2021 Senior Software Engineer at FastRuby.io

Slide 8

Slide 8 text

#RailsUpgrades | https://fastruby.io/rc2021 Paperclip to ActiveStorage + Rails Upgrade Power HRG

Slide 9

Slide 9 text

#RailsUpgrades | https://fastruby.io/rc2021 @cleicar2

Slide 10

Slide 10 text

#RailsUpgrades | https://fastruby.io/rc2021 Luciano Becerra 🇦🇷 (he/him)

Slide 11

Slide 11 text

#RailsUpgrades | https://fastruby.io/rc2021 Senior Software Engineer at FastRuby.io

Slide 12

Slide 12 text

#RailsUpgrades | https://fastruby.io/rc2021 @lubc32

Slide 13

Slide 13 text

#RailsUpgrades| https://fastruby.io/rc2021 🐦 #RailsUpgrades 🐦 13

Slide 14

Slide 14 text

#RailsUpgrades| https://fastruby.io/rc2021 Why do we need this workshop?

Slide 15

Slide 15 text

#RailsUpgrades| https://fastruby.io/rc2021 `bundle update` should be easy

Slide 16

Slide 16 text

#RailsUpgrades | https://fastruby.io/rc2021 bundle update rails ?

Slide 17

Slide 17 text

#RailsUpgrades| https://fastruby.io/rc2021 Workshop Outline 17

Slide 18

Slide 18 text

#RailsUpgrades| https://fastruby.io/rc2021 - Pre-requisites: Initial setup

Slide 19

Slide 19 text

#RailsUpgrades| https://fastruby.io/rc2021 - Pre-requisites: Initial setup - Introduction to next_rails

Slide 20

Slide 20 text

#RailsUpgrades| https://fastruby.io/rc2021 - Pre-requisites: Initial setup - Introduction to next_rails - Dual Boot Setup 20

Slide 21

Slide 21 text

#RailsUpgrades| https://fastruby.io/rc2021 - Pre-requisites: Initial setup - Introduction to next_rails - Dual Boot Setup - next bundle install 21

Slide 22

Slide 22 text

#RailsUpgrades| https://fastruby.io/rc2021 - Pre-requisites: Initial setup - Introduction to next_rails - Dual Boot Setup - next bundle install - next bundle exec rails console 22

Slide 23

Slide 23 text

#RailsUpgrades| https://fastruby.io/rc2021 - Pre-requisites: Initial setup - Introduction to next_rails - Dual Boot Setup - next bundle install - next bundle exec rails console - next bundle exec rake test 23

Slide 24

Slide 24 text

#RailsUpgrades| https://fastruby.io/rc2021 - Pre-requisites: Initial setup - Introduction to next_rails - Dual Boot Setup - next bundle install - next bundle exec rails console - next bundle exec rake test - next bundle exec rails server 24

Slide 25

Slide 25 text

#RailsUpgrades| https://fastruby.io/rc2021 https:// fastruby.io/rc2021

Slide 26

Slide 26 text

#RailsUpgrades | https://fastruby.io/rc2021 Steps: - Explanation - Questions - Exercise time

Slide 27

Slide 27 text

#RailsUpgrades | https://fastruby.io/rc2021 Pre-Requisites

Slide 28

Slide 28 text

#RailsUpgrades | https://fastruby.io/rc2021 Pre-requisites: ✓ Using your own app ✓ Using our sample app

Slide 29

Slide 29 text

#RailsUpgrades | https://fastruby.io/rc2021 Using your own app: ✓ ruby 2.3.8 or above ✓ bundle install ✓ bundle exec rake test *

Slide 30

Slide 30 text

#RailsUpgrades | https://fastruby.io/rc2021 Using our sample app: ✓ docker ✓ docker-compose ✓ git

Slide 31

Slide 31 text

#RailsUpgrades| https://fastruby.io/rc2021 31 $ git clone \ [email protected]:fastruby/pecas.git $ cd pecas

Slide 32

Slide 32 text

#RailsUpgrades| https://fastruby.io/rc2021 $ docker-compose build $ docker-compose run web /bin/bash $ ./bin/setup

Slide 33

Slide 33 text

#RailsUpgrades| https://fastruby.io/rc2021 33 $ rspec spec DEPRECATION WARNING: The factory_girl gem is deprecated. Please upgrade to factory_bot. See https://github.com/thoughtbot/factory_bot/blob/ v4.9.0/UPGRADE_FROM_FACTORY_GIRL.md for further instructions. (called from require at /usr/local/lib/ruby/site_ruby/2.5.0/bundler/ runtime.rb:81) ..................................... Finished in 1.82 seconds (files took 4.7 seconds to load) 37 examples, 0 failures

Slide 34

Slide 34 text

#RailsUpgrades | https://fastruby.io/rc2021 Questions?

Slide 35

Slide 35 text

#RailsUpgrades| https://fastruby.io/rc2021 Exercise #1: Check Pre-Requisites Time: 5 to 10 minutes https://fastruby.io/rc2021#1 https://fastruby.io/rc2021#2

Slide 36

Slide 36 text

#RailsUpgrades | https://www.fastruby.io/rc2021 How outdated is our application?

Slide 37

Slide 37 text

#RailsUpgrades| https://www.fastruby.io/rc2021 Analyze our Gemfile With the next_rails gem

Slide 38

Slide 38 text

#RailsUpgrades| https://www.fastruby.io/rc2021 next_rails gem

Slide 39

Slide 39 text

#RailsUpgrades| https://www.fastruby.io/rc2021

Slide 40

Slide 40 text

#RailsUpgrades| https://www.fastruby.io/rc2021 # Gemfile group :development, :test do gem “next_rails” end

Slide 41

Slide 41 text

#RailsUpgrades| https://www.fastruby.io/rc2021 $ bundle Fetching gem metadata from https://rubygems.org/.......... ... Fetching next_rails 1.0.3 Installing next_rails 1.0.3 ... Bundle complete! 30 Gemfile dependencies, 106 gems now installed.

Slide 42

Slide 42 text

#RailsUpgrades| https://www.fastruby.io/rc2021 1) bundle_report outdated 2) bundle_report compatibility --rails-version=x.x.x next_rails commands

Slide 43

Slide 43 text

#RailsUpgrades| https://www.fastruby.io/rc2021 1) bundle_report outdated 2) bundle_report compatibility --rails-version=x.x.x next_rails commands

Slide 44

Slide 44 text

#RailsUpgrades| https://www.fastruby.io/rc2021 $ bundle_report outdated redcarpet 3.0.0: released over 5 years ago (latest version, 3.4.0, released over 2 years ago) bootstrap-sass 3.3.7: released over 2 years ago (latest version, 3.4.1, released about 2 months ago) ... mail 2.7.0: released over 1 year ago (latest version, 2.7.1, released 6 months ago) activesupport 5.1.6: released about 1 year ago (latest version, 5.2.3, released 11 days ago) railties 5.1.6: released about 1 year ago (latest version, 5.2.3, released 11 days ago) 0 gems are sourced from git 65 of the 102 gems are out-of-date (64%)

Slide 45

Slide 45 text

#RailsUpgrades| https://www.fastruby.io/rc2021 $ bundle_report outdated redcarpet 3.0.0: released over 5 years ago (latest version, 3.4.0, released over 2 years ago) bootstrap-sass 3.3.7: released over 2 years ago (latest version, 3.4.1, released about 2 months ago) ... mail 2.7.0: released over 1 year ago (latest version, 2.7.1, released 6 months ago) activesupport 5.1.6: released about 1 year ago (latest version, 5.2.3, released 11 days ago) railties 5.1.6: released about 1 year ago (latest version, 5.2.3, released 11 days ago) 0 gems are sourced from git 65 of the 102 gems are out-of-date (64%)

Slide 46

Slide 46 text

#RailsUpgrades| https://www.fastruby.io/rc2021 $ bundle_report outdated redcarpet 3.0.0: released over 5 years ago (latest version, 3.4.0, released over 2 years ago) bootstrap-sass 3.3.7: released over 2 years ago (latest version, 3.4.1, released about 2 months ago) ... mail 2.7.0: released over 1 year ago (latest version, 2.7.1, released 6 months ago) activesupport 5.1.6: released about 1 year ago (latest version, 5.2.3, released 11 days ago) railties 5.1.6: released about 1 year ago (latest version, 5.2.3, released 11 days ago) 0 gems are sourced from git 65 of the 102 gems are out-of-date (64%)

Slide 47

Slide 47 text

#RailsUpgrades| https://www.fastruby.io/rc2021 $ bundle_report outdated redcarpet 3.0.0: released over 5 years ago (latest version, 3.4.0, released over 2 years ago) bootstrap-sass 3.3.7: released over 2 years ago (latest version, 3.4.1, released about 2 months ago) ... mail 2.7.0: released over 1 year ago (latest version, 2.7.1, released 6 months ago) activesupport 5.1.6: released about 1 year ago (latest version, 5.2.3, released 11 days ago) railties 5.1.6: released about 1 year ago (latest version, 5.2.3, released 11 days ago) 0 gems are sourced from git 65 of the 102 gems are out-of-date (64%)

Slide 48

Slide 48 text

#RailsUpgrades| https://www.fastruby.io/rc2021 1) bundle_report outdated 2) bundle_report compatibility --rails-version=5.0.0 next_rails commands

Slide 49

Slide 49 text

#RailsUpgrades| https://www.fastruby.io/rc2021 $ bundle_report compatibility --rails-version=5.0.0 => Incompatible with Rails 5.0.0 (with new versions that are compatible): These gems will need to be upgraded before upgrading to Rails 5.0.0. rails-dom-testing 1.0.9 - upgrade to 2.0.3 sass-rails 4.0.5 - upgrade to 6.0.0 => Incompatible with Rails 5.0.0 (with no new compatible versions): These gems will need to be removed or replaced before upgrading to Rails 5.0.0. coffee-rails 4.0.1 - new version, 5.0.0, is not compatible with Rails 5.0.0 3 gems incompatible with Rails 5.0.0

Slide 50

Slide 50 text

#RailsUpgrades| https://www.fastruby.io/rc2021 $ bundle_report compatibility --rails-version=5.0.0 => Incompatible with Rails 5.0.0 (with new versions that are compatible): These gems will need to be upgraded before upgrading to Rails 5.0.0. rails-dom-testing 1.0.9 - upgrade to 2.0.3 sass-rails 4.0.5 - upgrade to 6.0.0 => Incompatible with Rails 5.0.0 (with no new compatible versions): These gems will need to be removed or replaced before upgrading to Rails 5.0.0. coffee-rails 4.0.1 - new version, 5.0.0, is not compatible with Rails 5.0.0 3 gems incompatible with Rails 5.0.0

Slide 51

Slide 51 text

#RailsUpgrades| https://www.fastruby.io/rc2021 $ bundle_report compatibility --rails-version=5.0.0 => Incompatible with Rails 5.0.0 (with new versions that are compatible): These gems will need to be upgraded before upgrading to Rails 5.0.0. rails-dom-testing 1.0.9 - upgrade to 2.0.3 sass-rails 4.0.5 - upgrade to 6.0.0 => Incompatible with Rails 5.0.0 (with no new compatible versions): These gems will need to be removed or replaced before upgrading to Rails 5.0.0. coffee-rails 4.0.1 - new version, 5.0.0, is not compatible with Rails 5.0.0 3 gems incompatible with Rails 5.0.0

Slide 52

Slide 52 text

#RailsUpgrades| https://www.fastruby.io/rc2021 Exercise #2: (Time: 7 minutes) 1) Install next_rails gem 2) Run bundle_report outdated 3) Run bundle_report compatibility --rails-version=x.x.x https://www.fastruby.io/rc2021#3

Slide 53

Slide 53 text

#RailsUpgrades | https://www.fastruby.io/rc2021 Deprecation Warnings

Slide 54

Slide 54 text

#RailsUpgrades| https://www.fastruby.io/rc2021

Slide 55

Slide 55 text

#RailsUpgrades| https://www.fastruby.io/rc2021

Slide 56

Slide 56 text

#RailsUpgrades| https://www.fastruby.io/rc2021 $ DEPRECATION_TRACKER=save rspec

Slide 57

Slide 57 text

#RailsUpgrades| https://www.fastruby.io/rc2021 $ DEPRECATION_TRACKER=save rspec spec/support/deprecation_warning.shitlist.json

Slide 58

Slide 58 text

#RailsUpgrades | https://www.fastruby.io/rc2021 Dual Boot: Setup

Slide 59

Slide 59 text

#RailsUpgrades| https://www.fastruby.io/rc2021 $ next --init

Slide 60

Slide 60 text

#RailsUpgrades| https://www.fastruby.io/rc2021 $ next --init Gemfile Gemfile.next

Slide 61

Slide 61 text

#RailsUpgrades| https://www.fastruby.io/rc2021 Gemfile Gemfile.next Gemfile.lock Gemfile.next.lock bundle install next bundle install

Slide 62

Slide 62 text

#RailsUpgrades| https://www.fastruby.io/rc2021 # Gemfile def next? File.basename(__FILE__) == "Gemfile.next" end $ next --init

Slide 63

Slide 63 text

#RailsUpgrades| https://www.fastruby.io/rc2021 Exercise #3: (Time: 5 minutes) 1) Run next --init 2) Check that a Gemfile.next was created 3) Check that you have the next? method in your Gemfile https://www.fastruby.io/rc2021#4

Slide 64

Slide 64 text

#RailsUpgrades| https://www.fastruby.io/rc2021 # Gemfile if next? gem 'rails', '~> 5.0.7' else gem 'rails', '4.2.11.1' end

Slide 65

Slide 65 text

#RailsUpgrades| https://www.fastruby.io/rc2021 $ next bundle install

Slide 66

Slide 66 text

#RailsUpgrades| https://www.fastruby.io/rc2021 $ next bundle install ... Bundler could not find compatible versions for gem "actionpack": In snapshot (Gemfile.next.lock): actionpack (= 4.2.11.3) In Gemfile.next: rails (~> 5.0.0) was resolved to 5.0.1.rc1, which depends on actionpack (= 5.0.1.rc1) sass-rails (~> 4.0.3) was resolved to 4.0.5, which depends on railties (>= 4.0.0, < 5.0) was resolved to 4.2.11.3, which depends on actionpack (= 4.2.11.3) Running `bundle update` will rebuild your snapshot from scratch, using only the gems in your Gemfile, which may resolve the conflict.

Slide 67

Slide 67 text

#RailsUpgrades| https://www.fastruby.io/rc2021 $ next bundle install Gemfile.next.lock

Slide 68

Slide 68 text

#RailsUpgrades| https://www.fastruby.io/rc2021 Exercise #4: (Time: 10 minutes) 1) Run next bundle install https://www.fastruby.io/rc2021#4

Slide 69

Slide 69 text

#RailsUpgrades | https://fastruby.io/rc2021, Run the console

Slide 70

Slide 70 text

#RailsUpgrades| https://fastruby.io/rc2021 70 $ bundle exec rails console $ next bundle exec rails console

Slide 71

Slide 71 text

#RailsUpgrades| https://fastruby.io/rc2021 71 $ bundle exec rails console $ next bundle exec rails console

Slide 72

Slide 72 text

#RailsUpgrades| https://fastruby.io/rc2021 72 $ bundle exec rails console $ next bundle exec rails console

Slide 73

Slide 73 text

#RailsUpgrades| https://fastruby.io/rc2021 73 $ bundle exec rails console irb(main):001:0> Rails.version => "4.2.11.3" irb(main):002:0> $ next bundle exec rails console irb(main):001:0> Rails.version => "5.0.7.2" irb(main):002:0>

Slide 74

Slide 74 text

#RailsUpgrades| https://fastruby.io/rc2021 74 Every failing scenario is a story

Slide 75

Slide 75 text

#RailsUpgrades| https://fastruby.io/rc2021 Exercise #5 (Time 5 to 10 min) 1)bundle exec rails console 2)next bundle exec rails console

Slide 76

Slide 76 text

#RailsUpgrades | https://fastruby.io/rc2021, Run the test suite

Slide 77

Slide 77 text

#RailsUpgrades| https://fastruby.io/rc2021 77 $ bundle exec rspec $ next bundle exec rspec

Slide 78

Slide 78 text

#RailsUpgrades| https://fastruby.io/rc2021 78 $ bundle exec rspec $ next bundle exec rspec

Slide 79

Slide 79 text

#RailsUpgrades| https://fastruby.io/rc2021 79 Deprecation warnings

Slide 80

Slide 80 text

#RailsUpgrades| https://fastruby.io/rc2021 80 Every deprecation warning is a story

Slide 81

Slide 81 text

#RailsUpgrades| https://fastruby.io/rc2021 Exercise #6 (Time 5 to 10 min) 1)bundle exec rails rspec 2)next bundle exec rspec

Slide 82

Slide 82 text

#RailsUpgrades | https://fastruby.io/rc2021, How To Stay Current

Slide 83

Slide 83 text

#RailsUpgrades| https://fastruby.io/rc2021 Treat new deprecation warnings as exceptions 83

Slide 84

Slide 84 text

#RailsUpgrades| https://fastruby.io/rc2021 # config/environments/test.rb Rails.application.configure do # Raise on deprecation notices config.active_support.deprecation = :raise # … end 84

Slide 85

Slide 85 text

#RailsUpgrades| https://fastruby.io/rc2021 Add bundler-audit to your default rake task 85

Slide 86

Slide 86 text

#RailsUpgrades| https://fastruby.io/rc2021 # Rakefile # ... task default: “bundle:audit” 86

Slide 87

Slide 87 text

#RailsUpgrades| https://fastruby.io/rc2021 namespace :bundle do desc "Audit bundle for any known vulnerabilities" task :audit do unless system "bundle-audit check --update" exit 1 end end end 87

Slide 88

Slide 88 text

#RailsUpgrades| https://fastruby.io/rc2021 Keep up with upcoming releases 88

Slide 89

Slide 89 text

#RailsUpgrades| https://fastruby.io/rc2021 89 # Gemfile if next? gem 'rails', github: 'rails/rails' else gem 'rails', '~> 6.1.0' end

Slide 90

Slide 90 text

#RailsUpgrades| https://fastruby.io/rc2021 Setup your CI server

Slide 91

Slide 91 text

#RailsUpgrades | https://fastruby.io/rc2021 Trust The Process

Slide 92

Slide 92 text

#RailsUpgrades| https://fastruby.io/rc2021 92 Gradual version jumps

Slide 93

Slide 93 text

#RailsUpgrades| https://fastruby.io/rc2021 ... ✅ 2.3 👉 3.0 ✅ 3.0 👉 3.1 ✅ 3.1 👉 3.2 ✅ 3.2 👉 4.0 ✅ 4.0 👉 4.1 ✅ 4.1 👉 4.2 ✅ 4.2 👉 5.0 ✅ 5.0 👉 5.1 ✅ 5.1 👉 5.2 ✅ 5.2 👉 6.0 ✅ 6.0 👉 6.1 ✅ 6.1 👉 7.0 93 Gemfile Gemfile.next { }

Slide 94

Slide 94 text

#RailsUpgrades| https://fastruby.io/rc2021 For every version jump: bundle install bundle exec rake test Smoke test 94

Slide 95

Slide 95 text

#RailsUpgrades| https://fastruby.io/rc2021 Ship backwards- compatible changes first 95

Slide 96

Slide 96 text

#RailsUpgrades| https://fastruby.io/rc2021 Tiny PRs over One huge PR 96

Slide 97

Slide 97 text

#RailsUpgrades| https://fastruby.io/rc2021 1. Tweak 2. Test 3. Merge And Iterate

Slide 98

Slide 98 text

#RailsUpgrades| https://fastruby.io/rc2021 Results - Your app running on the next version of Rails 98

Slide 99

Slide 99 text

#RailsUpgrades| https://fastruby.io/rc2021 Results - Your app running on the next version of Rails - A roadmap to upgrade your app 99

Slide 100

Slide 100 text

#RailsUpgrades| https://fastruby.io/rc2021 Results - Your app running on the next version of Rails - A roadmap to upgrade your app - A new tool for your toolbelt 100

Slide 101

Slide 101 text

#RailsUpgrades | https://fastruby.io/rc2021 Feedback is welcome

Slide 102

Slide 102 text

#RailsUpgrades | https://fastruby.io/rc2021 @FastRubyIO Feedback is welcome

Slide 103

Slide 103 text

#RailsUpgrades | https://fastruby.io/rc2021 @FastRubyIO fastruby.io/blog Feedback is welcome

Slide 104

Slide 104 text

#RailsUpgrades | https://fastruby.io/rc2021 ombulabs.com/jobs We are hiring!

Slide 105

Slide 105 text

#RailsUpgrades| https://fastruby.io/rc2021 105 Thank You!

Slide 106

Slide 106 text

#RailsUpgrades | https://fastruby.io/rc2021 Questions?

Slide 107

Slide 107 text

#RailsUpgrades| https://fastruby.io/rc2021 Resources 1.https://github.com/clio/ten_years_rails 2.https://github.com/alphagov/e-petitions 3.https://github.com/rubyperu/ready4rails 4.https://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#the-upgrade-process 5.https://fastruby.io/blog/tags/upgrades 6.https://semver.org 7.https://github.com/Shopify/bootboot 8.https://github.com/fastruby/rails_upgrader 9.http://railsdiff.org 10.https://github.com/hintmedia/moderate_parameters 11.https://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#the-update-task 12.https://www.fastruby.io/blog/rails/upgrade/dual-booting-with-conditionals.html 13.https://www.fastruby.io/blog/upgrade-rails/dual-boot/dual-boot-with-rails-6-0-beta.html 14.http://recursion.org/incremental-rails-upgrade