Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Journey of a complex gem upgrade

Edouard Chin
June 09, 2018
310

Journey of a complex gem upgrade

Edouard Chin

June 09, 2018
Tweet

Transcript

  1. Easy to upgrade and solely used in test/development Tough to

    upgrade, takes a long time and effort Relatively easy to bump but critical for your infra
  2. Make CI fail only when new broken code is introduced

    Existing broken tests will be marked and allowed to fail
  3. mark_as :failing_on_rails_next test 'example test' do raise StandardError, 'This test

    fails but will be considered as passing' end # What's the difference between both test 'example test' do skip('This test is failing lets not run it') if running_on_rails_next? raise StandardError, 'This test fails but will be skipped' end
  4. mark_as :failing_on_rails_next test 'example test' do raise StandardError, ‘This test

    is marked as failing’ end desc 'This task is great' task :great_task do # ... end desc 'Another cool task' task :cool_task do # ... end
  5. # frozen_string_literal: true class MyTest < MiniTest::Test include MarkingModule mark_as

    :failing_on_rails_next def test_example … end end puts MyTest.new('test_example').failing_on_rails_next? # true
  6. # Snippet taken from minitest.rb at_exit { exit exit_code ||

    false } exit_code = Minitest.run ARGV
  7. module Minitest module Reporters class RailsNextReporter < BaseReporter ALLOWED =

    :allowed attr_writer :state def after_test(test) return unless test_will_fail?(test) @state = ALLOWED end def test_will_fail?(test) return false if not_on_rails_next test.failing_on_rails_next? end def record(result) result.failures.clear if @state == ALLOWED end end end end
  8. — test_foo: - DEPRECATION WARNING: This code is deprecated -

    DEPRECATION WARNING: Another deprecation test_bar - DEPRECATION WARNING: This code is deprecated class MyTest < MiniTest::Test def test_foo ActiveSupport::Deprecation.warn(‘This code is deprecated') ActiveSupport::Deprecation.warn(‘Another deprecation’) end def test_bar ActiveSupport::Deprecation.warn(‘This code is deprecated’) end end
  9. 4. Have a clear distinction on who should own what

    and parallelize the work 5. Add some gamification