Skip to content

Instantly share code, notes, and snippets.

@bestwebua
Forked from tgaff/upgrade26.md
Created November 30, 2020 10:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bestwebua/696d15ea9930685e2f980e1d8a14afd7 to your computer and use it in GitHub Desktop.
Save bestwebua/696d15ea9930685e2f980e1d8a14afd7 to your computer and use it in GitHub Desktop.
ruby 2.3 to 2.6 upgrade

local

brew upgrade ruby-install
ruby-install ruby 2.6.5

install bundler 2.1.4 (may not be necessary)

Depending on ruby version manager (rvm/chruby/rbenv) you may need to change directories or select ruby 2.6.5 then

gem install bundler 2.1.4

cd in and bundle up

cd connect_backend
bundle install

overall trends

bundler

Bundler is one of the best tools in the ruby world.

Since the whole 2.0 update it has however become a bit of a pain. We now have to make sure we're on the exact same patch level of bundler EVERYWHERE or face ongoing issues.

What this means is that for every bundler bump we have to update it in:

  • ebconfig files for aws
  • docker files
    • did you know we have two of these for backend?
  • every dev machine :-/
  • circle-ci scripts
    • jenkins if we're using it there too (haven't got that far but worried about rake tasks)

I've now locked bundler in the Gemfile. I don't know if this is the right move; so feel free to reconsider this a few months later. I'm hoping it helps to prevent random bumps.

syntax changes

types:

  1. style changes - optional but rubocop might yell
  2. syntax changes - required to parse (only 1 so far)
  3. removals/replacements

rescue in a block without a begin

level: style (rubocop)

       required.map do |param|
-        begin
           param_values << params.require(param)
-        rescue ActionController::ParameterMissing => exception
+      rescue ActionController::ParameterMissing => exception
           errors << exception.message
-        end

single-line function call w/block requires parentheses around argument

level: syntax error

-  before_action only: [:sync_blm_booklist, :import_sections_from_compete, :send_welcome_emails] { ensure_catalog_authorized!(param_key: :catalog_id) }
+  before_action(only: [:sync_blm_booklist, :import_sections_from_compete, :send_welcome_emails]) { ensure_catalog_authorized!(param_key: :catalog_id) }

regex tests should start with regex

level: style - likely optimization

When declaring a regex comparison call the comparison against the existing regex. Avoids converting string to regex.

-    if params[:run_charges] =~ /RUN ALL CHARGES/
+    if /RUN ALL CHARGES/.match?(params[:run_charges])
-    unless recipient_email =~ /.+@.+\..+/
+    unless /.+@.+\..+/.match?(recipient_email)

$. for file line-number removed in 2.6

level: removal/replacement

Prior to 2.6 you could get the row-index of the current csv using $.. This was good for reporting row-errors. The docs for 2.6 & 2.7 still show this but at a minimum it no longer works for CSVs. Using .with_index on the iterator is a fairly easy alternative.

-      CSV.foreach(@csv_path) do |row_data|
+      CSV.foreach(@csv_path).with_index(1) do |row_data, row_number|
         row = Row.new(row_data, catalog_id: @catalog.id)
         row_result = row.find_license_or_error

         if row_result.key? :errors
-          add_row_numbers(row_result[:errors], $.) # $. is the File backed line number
+          add_row_numbers(row_result[:errors], row_number)

exception to_s formatting slightly different

level: style

-      expect(response_json['error']['exception']).to eq("bad URI(is not URI?): ://")
+      expect(response_json['error']['exception']).to eq("bad URI(is not URI?): \"://\"")

update ElasticBeanstalk instances

There's absolutely no way to do this from the AWS webUI. Two options then:

  1. build a new environment in the webUI, carefully copying all settings over
  2. use the command-line tool to "upgrade" an existing environment

For #2: aws command-line

thank you Cédric!

updating the environment:

aws --region us-east-1 elasticbeanstalk update-environment --solution-stack-name "64bit Amazon Linux 2018.03 v2.11.2 running Ruby 2.6 (Passenger Standalone)" --environment-name [REPLACE WITH NAME]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment