Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for EOL versions & test against newer ones #58

Merged
merged 10 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ jobs:
name: Ruby ${{ matrix.ruby }} / ${{ matrix.gemfile }}
strategy:
matrix:
gemfile: [gemfiles/activesupport_5.2.gemfile, gemfiles/activesupport_6.0.gemfile]
ruby: ["2.5", "2.6", "2.7"]
gemfile: [gemfiles/activesupport_5.2.gemfile, gemfiles/activesupport_6.0.gemfile, gemfiles/activesupport_6.1.gemfile, gemfiles/activesupport_7.0.gemfile, gemfiles/activesupport_edge.gemfile]
ruby: ["2.6", "2.7", "3.0", "3.1"]
exclude:
# Active Support requires Ruby >= 2.7 as of 7.0
- gemfile: "gemfiles/activesupport_7.0.gemfile"
ruby: "2.6"
- gemfile: "gemfiles/activesupport_edge.gemfile"
ruby: "2.6"
env:
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
steps:
Expand All @@ -24,7 +30,7 @@ jobs:
bundler-cache: true

- name: RuboCop
run: bundle exec rubocop || true # Ignore failures until #56 fixes Rubocop config
run: bundle exec rubocop

- name: Tests
run: bundle exec rake test
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ inherit_gem:
rubocop-shopify: rubocop.yml

AllCops:
TargetRubyVersion: 2.5
TargetRubyVersion: 2.6
Exclude:
- gemfiles/vendor/**/*

Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Change log

## master (unreleased)
## main (unreleased)

* [#58](https://github.com/Shopify/deprecation_toolkit/pull/58): Drop support for Ruby < 2.6 & Active Support < 5.2. (@sambostock)
* [#58](https://github.com/Shopify/deprecation_toolkit/pull/58): Ensure compatibility with Rails 7. (@sambostock)

## 1.4.0 (2019-04-29)
* [#37](https://github.com/Shopify/deprecation_toolkit/pull/37): Add Rspec support. (@andrewmarkle)
Expand Down
15 changes: 9 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ source "https://rubygems.org"

gemspec

group :deployment do
gem "rake"
gem "rubocop"
end
gem "bundler"
gem "minitest"
gem "rake"
gem "rspec"
gem "rubocop-shopify"

group :test do
gem "rubocop-shopify"
if defined?(@activesupport_gem_requirement) && @activesupport_gem_requirement
# causes Dependabot to ignore the next line
activesupport = "activesupport"
gem activesupport, @activesupport_gem_requirement
end
56 changes: 26 additions & 30 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,42 @@ PATH
remote: .
specs:
deprecation_toolkit (1.5.1)
activesupport (>= 4.2)
activesupport (>= 5.2)

GEM
remote: https://rubygems.org/
specs:
activesupport (6.0.2.2)
activesupport (7.0.2.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
ast (2.4.2)
concurrent-ruby (1.1.6)
diff-lcs (1.3)
i18n (1.8.2)
concurrent-ruby (1.1.9)
diff-lcs (1.5.0)
i18n (1.10.0)
concurrent-ruby (~> 1.0)
minitest (5.14.0)
minitest (5.15.0)
parallel (1.21.0)
parser (3.1.1.0)
ast (~> 2.4.1)
rainbow (3.1.1)
rake (12.3.2)
rake (13.0.6)
regexp_parser (2.2.1)
rexml (3.2.5)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.2)
rspec (3.11.0)
rspec-core (~> 3.11.0)
rspec-expectations (~> 3.11.0)
rspec-mocks (~> 3.11.0)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
rspec-support (~> 3.11.0)
rspec-mocks (3.11.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
rspec-support (~> 3.11.0)
rspec-support (3.11.0)
rubocop (1.25.1)
parallel (~> 1.10)
parser (>= 3.1.0.0)
Expand All @@ -53,22 +52,19 @@ GEM
rubocop-shopify (2.5.0)
rubocop (~> 1.25)
ruby-progressbar (1.11.0)
thread_safe (0.3.6)
tzinfo (1.2.7)
thread_safe (~> 0.1)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unicode-display_width (2.1.0)
zeitwerk (2.3.0)

PLATFORMS
ruby

DEPENDENCIES
bundler (>= 1.16)
bundler
deprecation_toolkit!
minitest (~> 5.0)
minitest
rake
rspec (~> 3.0)
rubocop
rspec
rubocop-shopify

BUNDLED WITH
Expand Down
11 changes: 3 additions & 8 deletions deprecation_toolkit.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,16 @@ Gem::Specification.new do |spec|

spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "https://github.com/shopify/deprecation_toolkit"
spec.metadata["changelog_uri"] = "https://github.com/Shopify/deprecation_toolkit/blob/master/CHANGELOG.md"
spec.metadata["changelog_uri"] = "https://github.com/Shopify/deprecation_toolkit/blob/main/CHANGELOG.md"

spec.metadata["allowed_push_host"] = "https://rubygems.org"

spec.required_ruby_version = ">= 2.5"
spec.required_ruby_version = ">= 2.6"

spec.files = %x(git ls-files -z).split("\x0").reject do |f|
f.match(%r{^(test)/})
end
spec.require_paths = ["lib"]

spec.add_runtime_dependency("activesupport", ">= 4.2")

spec.add_development_dependency("bundler", ">= 1.16")
spec.add_development_dependency("minitest", "~> 5.0")
spec.add_development_dependency("rake", "~> 10.0")
spec.add_development_dependency("rspec", "~> 3.0")
spec.add_runtime_dependency("activesupport", ">= 5.2")
end
11 changes: 2 additions & 9 deletions gemfiles/activesupport_5.2.gemfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# frozen_string_literal: true

source "https://rubygems.org"
@activesupport_gem_requirement = "~> 5.2"

gem "activesupport", "~> 5.2"

group :deployment do
gem "rake"
gem "rubocop"
end

gemspec path: "../"
eval_gemfile "../Gemfile"
11 changes: 2 additions & 9 deletions gemfiles/activesupport_6.0.gemfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# frozen_string_literal: true

source "https://rubygems.org"
@activesupport_gem_requirement = "~> 6.0"

gem "activesupport", "~> 6.0"

group :deployment do
gem "rake"
gem "rubocop"
end

gemspec path: "../"
eval_gemfile "../Gemfile"
5 changes: 5 additions & 0 deletions gemfiles/activesupport_6.1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

@activesupport_gem_requirement = "~> 6.1"

eval_gemfile "../Gemfile"
5 changes: 5 additions & 0 deletions gemfiles/activesupport_7.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

@activesupport_gem_requirement = "~> 7.0"

eval_gemfile "../Gemfile"
5 changes: 5 additions & 0 deletions gemfiles/activesupport_edge.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

@activesupport_gem_requirement = { github: "rails/rails" }

eval_gemfile "../Gemfile"
4 changes: 2 additions & 2 deletions lib/deprecation_toolkit.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require "active_support"

load("tasks/ci_recorder.rake")

module DeprecationToolkit
Expand Down Expand Up @@ -35,6 +37,4 @@ def self.attach_subscriber
end

require "deprecation_toolkit/minitest_hook" unless defined? RSpec
require "active_support"

require "deprecation_toolkit/warning"
47 changes: 11 additions & 36 deletions lib/deprecation_toolkit/warning.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,43 +43,18 @@ def deprecation_triggered?(str)
end
end

# Warning is a new feature in ruby 2.5, so support older versions
# Note that the `Warning` module exists in Ruby 2.4 but has a bug https://bugs.ruby-lang.org/issues/12944
if RUBY_VERSION < "2.5.0" && RUBY_ENGINE == "ruby"
module Kernel
class << self
alias_method :__original_warn, :warn

def warn(*messages)
message = messages.join("\n")
message += "\n" unless message.end_with?("\n")

if DeprecationToolkit::Warning.deprecation_triggered?(message)
ActiveSupport::Deprecation.warn(message)
else
__original_warn(messages)
end
end
end

def warn(*messages)
Kernel.warn(messages)
end
end
else
module DeprecationToolkit
module WarningPatch
def warn(str)
str = DeprecationToolkit::Warning.handle_multipart(str)
return unless str

if DeprecationToolkit::Warning.deprecation_triggered?(str)
ActiveSupport::Deprecation.warn(str)
else
super
end
module DeprecationToolkit
module WarningPatch
def warn(str)
str = DeprecationToolkit::Warning.handle_multipart(str)
return unless str

if DeprecationToolkit::Warning.deprecation_triggered?(str)
ActiveSupport::Deprecation.warn(str)
else
super
end
end
end
Warning.singleton_class.prepend(DeprecationToolkit::WarningPatch)
end
Warning.singleton_class.prepend(DeprecationToolkit::WarningPatch)
22 changes: 10 additions & 12 deletions test/deprecation_toolkit/warning_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,19 @@ class WarningTest < ActiveSupport::TestCase
end
end

if RUBY_VERSION >= "2.5"
test "Ruby 2.7 two-part keyword argument warning are joined together" do
Configuration.warnings_treated_as_deprecation = [/Using the last argument as keyword parameters/]
test "Ruby 2.7 two-part keyword argument warning are joined together" do
Configuration.warnings_treated_as_deprecation = [/Using the last argument as keyword parameters/]

error = assert_raises(Behaviors::DeprecationIntroduced) do
warn("/path/to/caller.rb:1: warning: Using the last argument as keyword parameters is deprecated; " \
"maybe ** should be added to the call")
warn("/path/to/calleee.rb:1: warning: The called method `method_name' is defined here")

trigger_deprecation_toolkit_behavior
end
error = assert_raises(Behaviors::DeprecationIntroduced) do
warn("/path/to/caller.rb:1: warning: Using the last argument as keyword parameters is deprecated; " \
"maybe ** should be added to the call")
warn("/path/to/calleee.rb:1: warning: The called method `method_name' is defined here")

assert_match(/Using the last argument as keyword parameters/, error.message)
assert_match(/The called method/, error.message)
trigger_deprecation_toolkit_behavior
end

assert_match(/Using the last argument as keyword parameters/, error.message)
assert_match(/The called method/, error.message)
end
end
end