From 432cb2c0d8b12d89aef81cf35597aa90f77407eb Mon Sep 17 00:00:00 2001 From: Jim Park Date: Thu, 11 Aug 2022 15:44:17 -0700 Subject: [PATCH] fix: Deprecate Ruby 2.6 and Drop support for Ruby 2.5 (#132) * fix: print deprecation warning if using ruby < 2.7 * chore: continue testing 2.5 and 2.6 * drop support for 2.5 and deprecate 2.6 --- .github/workflows/rspec_and_release.yml | 2 +- Gemfile.lock | 10 +++---- datadog_backup.gemspec | 12 ++++---- lib/datadog_backup.rb | 5 +++- lib/datadog_backup/deprecations.rb | 11 ++++++++ spec/datadog_backup/deprecations_spec.rb | 36 ++++++++++++++++++++++++ 6 files changed, 63 insertions(+), 13 deletions(-) create mode 100644 lib/datadog_backup/deprecations.rb create mode 100644 spec/datadog_backup/deprecations_spec.rb diff --git a/.github/workflows/rspec_and_release.yml b/.github/workflows/rspec_and_release.yml index cf99cd0..2333254 100644 --- a/.github/workflows/rspec_and_release.yml +++ b/.github/workflows/rspec_and_release.yml @@ -12,7 +12,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest] # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0' - ruby: [2.7, '3.0', '3.1'] + ruby: [2.6, 2.7, '3.0', '3.1'] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 diff --git a/Gemfile.lock b/Gemfile.lock index edb398f..4fb4477 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,11 +2,11 @@ PATH remote: . specs: datadog_backup (2.0.1) - amazing_print (= 1.4.0) - concurrent-ruby (= 1.1.10) - deepsort (= 0.4.5) - diffy (= 3.4.2) - dogapi (= 1.45.0) + amazing_print (~> 1.4.0) + concurrent-ruby (~> 1.1.10) + deepsort (~> 0.4.5) + diffy (~> 3.4.2) + dogapi (~> 1.45.0) GEM remote: https://rubygems.org/ diff --git a/datadog_backup.gemspec b/datadog_backup.gemspec index b87ad26..af1f51c 100644 --- a/datadog_backup.gemspec +++ b/datadog_backup.gemspec @@ -19,13 +19,13 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r{^spec/}) spec.require_paths = ['lib'] - spec.required_ruby_version = ['>= 2.5'] + spec.required_ruby_version = ['>= 2.6'] - spec.add_dependency 'amazing_print', '1.4.0' - spec.add_dependency 'concurrent-ruby', '1.1.10' - spec.add_dependency 'deepsort', '0.4.5' - spec.add_dependency 'diffy', '3.4.2' - spec.add_dependency 'dogapi', '1.45.0' + spec.add_dependency 'amazing_print', '~> 1.4.0' + spec.add_dependency 'concurrent-ruby', '~> 1.1.10' + spec.add_dependency 'deepsort', '~> 0.4.5' + spec.add_dependency 'diffy', '~> 3.4.2' + spec.add_dependency 'dogapi', '~> 1.45.0' spec.add_development_dependency 'bundler' spec.add_development_dependency 'pry' diff --git a/lib/datadog_backup.rb b/lib/datadog_backup.rb index a6541e3..4b965fa 100644 --- a/lib/datadog_backup.rb +++ b/lib/datadog_backup.rb @@ -6,13 +6,16 @@ require_relative 'datadog_backup/local_filesystem' require_relative 'datadog_backup/options' - require_relative 'datadog_backup/cli' require_relative 'datadog_backup/core' require_relative 'datadog_backup/dashboards' require_relative 'datadog_backup/monitors' require_relative 'datadog_backup/thread_pool' require_relative 'datadog_backup/version' +require_relative 'datadog_backup/deprecations' +DatadogBackup::Deprecations.check + module DatadogBackup end + diff --git a/lib/datadog_backup/deprecations.rb b/lib/datadog_backup/deprecations.rb new file mode 100644 index 0000000..09c4074 --- /dev/null +++ b/lib/datadog_backup/deprecations.rb @@ -0,0 +1,11 @@ + + +module DatadogBackup + module Deprecations + def self.check + if RUBY_VERSION < '2.7' + LOGGER.warn "ruby-#{RUBY_VERSION} is deprecated. Ruby 2.7 or higher will be required to use this gem after datadog_backup@v3" + end + end + end +end \ No newline at end of file diff --git a/spec/datadog_backup/deprecations_spec.rb b/spec/datadog_backup/deprecations_spec.rb new file mode 100644 index 0000000..d080c75 --- /dev/null +++ b/spec/datadog_backup/deprecations_spec.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe DatadogBackup::Deprecations do + let(:logger) { double } + + before do + stub_const('LOGGER', logger) + allow(logger).to receive(:warn) + end + + %w[2.4.10 2.5.9 2.6.8].each do |ruby_version| + describe "#check#{ruby_version}" do + subject { described_class.check } + + it 'does warn' do + stub_const('RUBY_VERSION', ruby_version) + expect(logger).to receive(:warn).with(/ruby-#{ruby_version} is deprecated./) + subject + end + end + end + + %w[2.7.4 3.0.4 3.1.2 3.2.0-preview1].each do |ruby_version| + describe "#check#{ruby_version}" do + subject { described_class.check } + + it 'does not warn' do + stub_const('RUBY_VERSION', ruby_version) + expect(logger).to_not receive(:warn).with(/ruby-#{ruby_version} is deprecated./) + subject + end + end + end +end