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 Ruby 2.0, 2.1, 2.2, 2.3, and 2.4 #549

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
34 changes: 3 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby:
[
"2.3",
"2.4",
"2.5",
"2.6",
"2.7",
"3.0",
"3.1",
"3.2",
"3.3",
"3.4",
"head",
]
ruby: ["2.5", "2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4", "head"]
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
Expand All @@ -34,24 +21,9 @@ jobs:
env:
RUBYOPT: ${{ startsWith(matrix.ruby, 'head') && '--enable=frozen-string-literal' || '' }}

test-legacy:
runs-on: ubuntu-20.04
strategy:
matrix:
ruby: ["2.0", "2.1", "2.2"]
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run tests
run: bundle exec rake test:units

test-all:
runs-on: ubuntu-latest
needs: [test, test-legacy]
needs: test
if: always()
steps:
- name: All tests ok
Expand All @@ -77,7 +49,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby: ["2.0", "ruby"]
ruby: ["2.5", "ruby"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗒️ Run slow functional tests on the oldest Ruby we support (2.5) and the latest Ruby.

steps:
- uses: actions/checkout@v4
- name: Set up Ruby
Expand Down
12 changes: 6 additions & 6 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ inherit_from: .rubocop_todo.yml
AllCops:
DisplayCopNames: true
DisplayStyleGuide: true
TargetRubyVersion: 2.0
TargetRubyVersion: 2.5

Lint/AmbiguousBlockAssociation:
Enabled: false
Expand All @@ -18,12 +18,12 @@ Style/ClassAndModuleChildren:
Enabled: false
Style/DoubleNegation:
Enabled: false
Style/FileName:
Naming/FileName:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗒️ I had to upgrade the rubocop gem to support TargetRubyVersion: 2.5. The new version migrated the names of some cops, hence the changes in these configs.

Exclude:
- "Dangerfile"
Style/IndentHeredoc:
Layout/IndentHeredoc:
Enabled: false
Style/SpaceAroundEqualsInParameterDefault:
Layout/SpaceAroundEqualsInParameterDefault:
EnforcedStyle: no_space
Style/StringLiterals:
EnforcedStyle: double_quotes
Expand All @@ -47,7 +47,7 @@ Metrics/CyclomaticComplexity:
Enabled: false
Metrics/MethodLength:
Enabled: false
Style/PredicateName:
Naming/PredicateName:
Enabled: false
Metrics/LineLength:
Enabled: false
Expand All @@ -59,5 +59,5 @@ Metrics/ClassLength:
Enabled: false
Metrics/ModuleLength:
Enabled: false
Style/AccessorMethodName:
Naming/AccessorMethodName:
Enabled: false
6 changes: 3 additions & 3 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ Style/MethodDefParentheses:
# Offense count: 3
# Configuration parameters: SupportedStyles.
# SupportedStyles: snake_case, camelCase
Style/MethodName:
Naming/MethodName:
EnforcedStyle: snake_case
Exclude:
- 'test/unit/test_color.rb'
Expand All @@ -460,7 +460,7 @@ Style/NumericPredicate:
- 'lib/sshkit/command.rb'

# Offense count: 1
Style/OpMethod:
Naming/BinaryOperatorParameterName:
Exclude:
- 'lib/sshkit/host.rb'

Expand Down Expand Up @@ -611,7 +611,7 @@ Style/UnneededPercentQ:
# Offense count: 1
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: snake_case, normalcase, non_integer
Style/VariableNumber:
Naming/VariableNumber:
Exclude:
- 'test/unit/backends/test_connection_pool.rb'

Expand Down
5 changes: 0 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
source 'https://rubygems.org'

gemspec

# public_suffix 3+ requires ruby 2.1+
if Gem::Requirement.new('< 2.1').satisfied_by?(Gem::Version.new(RUBY_VERSION))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗒️ No longer needed, since we no longer support Ruby < 2.1.

gem 'public_suffix', '< 3'
end
2 changes: 1 addition & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

* You must have commit rights to the SSHKit repository.
* You must have push rights for the sshkit gem on rubygems.org.
* You must be using Ruby >= 2.1.0.
* You must be using Ruby >= 2.5.0.

## How to release

Expand Down
3 changes: 1 addition & 2 deletions lib/sshkit/backends/abstract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ def configure
# Backends which extend the Abstract backend should implement the following methods:
def upload!(_local, _remote, _options = {}) raise MethodUnavailableError end
def download!(_remote, _local=nil, _options = {}) raise MethodUnavailableError end
def execute_command(_cmd) raise MethodUnavailableError end
private :execute_command # Can inline after Ruby 2.1
private def execute_command(_cmd) raise MethodUnavailableError end

private

Expand Down
1 change: 0 additions & 1 deletion lib/sshkit/backends/connection_pool.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require "monitor"
require "thread"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗒️ RuboCop flagged this as an unnecessary require (the Thread constant is always available without needing to require it.)


# Since we call to_s on new connection arguments and use that as a cache key, we
# need to make sure the memory address of the object is not used as part of the
Expand Down
2 changes: 0 additions & 2 deletions lib/sshkit/runners/parallel.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'thread'

module SSHKit

module Runner
Expand Down
7 changes: 4 additions & 3 deletions sshkit.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@ Gem::Specification.new do |gem|
gem.name = "sshkit"
gem.require_paths = ["lib"]
gem.version = SSHKit::VERSION
gem.required_ruby_version = ">= 2.5"

gem.add_runtime_dependency('base64') if RUBY_VERSION >= "2.4"
gem.add_runtime_dependency('base64')
gem.add_runtime_dependency('net-ssh', '>= 2.8.0')
gem.add_runtime_dependency('net-scp', '>= 1.1.2')
gem.add_runtime_dependency('net-sftp', '>= 2.1.2')
gem.add_runtime_dependency('ostruct') if RUBY_VERSION >= "2.5"
gem.add_runtime_dependency('ostruct')

gem.add_development_dependency('danger')
gem.add_development_dependency('minitest', '>= 5.0.0')
gem.add_development_dependency('minitest-reporters')
gem.add_development_dependency('rainbow', '~> 2.2.2')
gem.add_development_dependency('rake')
gem.add_development_dependency('rubocop', "~> 0.49.1")
gem.add_development_dependency('rubocop', "~> 0.52.0")
gem.add_development_dependency('mocha')

gem.add_development_dependency('bcrypt_pbkdf')
Expand Down
4 changes: 2 additions & 2 deletions test/functional/backends/test_netssh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def test_execute_raises_on_non_zero_exit_status_and_captures_stdout_and_stderr

def test_test_does_not_raise_on_non_zero_exit_status
Netssh.new(a_host) do |_host|
test :false
test :false # rubocop:disable Lint/BooleanSymbol
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗒️ RuboCop thinks this is a typo, and that we mean false and not :false. However in this case :false is the name of a command we are executing via SSH, not a boolean value.

end.run
end

Expand All @@ -151,7 +151,7 @@ def test_connection_pool_keepalive
# ensure we enable connection pool
SSHKit::Backend::Netssh.pool.idle_timeout = 10
Netssh.new(a_host) do |_host|
test :false
test :false # rubocop:disable Lint/BooleanSymbol
end.run
sleep 2.5
captured_command_result = nil
Expand Down
7 changes: 1 addition & 6 deletions test/unit/backends/test_abstract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,7 @@ def test_within_home
end

def test_background_logs_deprecation_warnings
deprecation_out =
if RUBY_VERSION < "2.3"
''
else
+''
end
deprecation_out = +''
SSHKit.config.deprecation_output = deprecation_out

ExampleBackend.new do
Expand Down
7 changes: 1 addition & 6 deletions test/unit/test_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,7 @@ def test_on_stderr
end

def test_deprecated_stdtream_accessors
deprecation_out =
if RUBY_VERSION < "2.3"
''
else
+''
end
deprecation_out = +''

SSHKit.config.deprecation_output = deprecation_out

Expand Down
7 changes: 1 addition & 6 deletions test/unit/test_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ def setup
end

def test_deprecation_output
output =
if RUBY_VERSION < "2.3"
''
else
+''
end
output = +''

SSHKit.config.deprecation_output = output
SSHKit.config.deprecation_logger.log('Test')
Expand Down
Loading