From fc391c6c5c0d94e526aebda434c8ace1c2ffdbf8 Mon Sep 17 00:00:00 2001 From: Tate Thurston Date: Wed, 1 May 2024 12:36:49 -0700 Subject: [PATCH] Add Ruby 3.x to CI testing --- .travis.yml | 31 ++++++++++++++++++--------- Gemfile.lock | 20 +++++++++++------ cassandra-driver.gemspec | 3 ++- spec/cassandra/protocol/coder_spec.rb | 10 +++++++-- 4 files changed, 44 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4fce134a7..b8d71807a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,12 +2,15 @@ language: ruby script: bundle exec rake rspec bundler_args: --without development docs rvm: - - 2.2.4 - - 2.3.0 - - 2.4 - - 2.5 - - 2.6 - - 2.7 + # - 2.3.0 + # - 2.4 + # - 2.5 + # - 2.6 + # - 2.7 + # - 3.0 + # - 3.1 + - 3.2 + - 3.3 - jruby-9.0.5.0 jdk: - openjdk8 @@ -21,10 +24,18 @@ branches: only: - master before_install: | - # Install bundler < 2.0, see https://docs.travis-ci.com/user/languages/ruby/ - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true - gem install bundler -v '< 2' - if [[ k$TRAVIS_RUBY_VERSION = kjruby* ]] ; then + RUBY_MAJOR=$(echo "$TRAVIS_RUBY_VERSION" | cut -d. -f1) + RUBY_MINOR=$(echo "$TRAVIS_RUBY_VERSION" | cut -d. -f2) + + if (( $RUBY_MAJOR >= 3 && $RUBY_MINOR >= 2)); then + # Hack the Gemfile.lock, bundler 1.x does not work with Ruby 3.2+ + sed -e 's/ 1\.17\.3/ 2.5.9/g' -i '' Gemfile.lock + sed -e 's/bundler (~> 1\.6)/bundler (~> 2.5)/g' -i '' Gemfile.lock + elif [[ k$TRAVIS_RUBY_VERSION = kjruby* ]]; then # Hack the Gemfile.lock file to indicate we're a JRuby gem, to make bundler happy. sed -e 's/\(cassandra-driver [^)]*\)/\1-java/' -i"" Gemfile.lock + else + # Install bundler < 2.0, see https://docs.travis-ci.com/user/languages/ruby/ + gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true + gem install bundler -v '< 2' fi diff --git a/Gemfile.lock b/Gemfile.lock index 62622f396..c81bf2f10 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -36,13 +36,13 @@ GEM delorean (2.1.0) chronic diff-lcs (1.2.5) - docile (1.1.5) + docile (1.3.5) ffi (1.9.25) ffi (1.9.25-java) gherkin (3.2.0) ione (1.2.4) - json (1.8.6) - json (1.8.6-java) + json (2.7.2) + json (2.7.2-java) lz4-ruby (0.3.3) lz4-ruby (0.3.3-java) minitest (4.7.5) @@ -59,6 +59,7 @@ GEM rake (13.0.1) rake-compiler (0.9.5) rake + rbtree (0.4.6) rspec (3.9.0) rspec-core (~> 3.9.0) rspec-expectations (~> 3.9.0) @@ -84,16 +85,21 @@ GEM ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) ruby-progressbar (1.9.0) - simplecov (0.11.2) - docile (~> 1.1.0) - json (~> 1.8) + set (1.1.0) + simplecov (0.17.1) + docile (~> 1.1) + json (>= 1.8, < 3) simplecov-html (~> 0.10.0) - simplecov-html (0.10.0) + simplecov-html (0.10.2) snappy (0.0.14) snappy (0.0.14-java) snappy-jars (~> 1.1.0) snappy-jars (1.1.0.1.2-java) thor (0.19.1) + sorted_set (1.0.3) + rbtree + set (~> 1.0) + sorted_set (1.0.3-java) unicode-display_width (1.3.0) yard (0.9.20) diff --git a/cassandra-driver.gemspec b/cassandra-driver.gemspec index bd2624b50..0bc0cd41f 100644 --- a/cassandra-driver.gemspec +++ b/cassandra-driver.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |s| s.extra_rdoc_files = ['README.md'] s.rdoc_options << '--title' << 'Datastax Ruby Driver' << '--main' << 'README.md' << '--line-numbers' - s.required_ruby_version = '>= 2.2.0' + s.required_ruby_version = '>= 2.3.0' if defined?(JRUBY_VERSION) s.platform = 'java' @@ -31,6 +31,7 @@ Gem::Specification.new do |s| end s.add_runtime_dependency 'ione', '~> 1.2' + s.add_runtime_dependency 'sorted_set', '~> 1.0' s.add_development_dependency 'bundler', '~> 1.6' s.add_development_dependency 'rake', '~> 13.0' diff --git a/spec/cassandra/protocol/coder_spec.rb b/spec/cassandra/protocol/coder_spec.rb index c6c7e17f2..d23393043 100644 --- a/spec/cassandra/protocol/coder_spec.rb +++ b/spec/cassandra/protocol/coder_spec.rb @@ -38,8 +38,14 @@ module Protocol describe('RUBY-128') do it 'reads very large short strings and string' do - column_specs = ::YAML::load(::File.open(::File.dirname(__FILE__) + "/cols.yml")) - buffer = ::YAML::load(::File.open(::File.dirname(__FILE__) + "/buffer.yml")) + # https://bugs.ruby-lang.org/issues/17866 + if RUBY_VERSION >= "3.1" + column_specs = ::YAML::unsafe_load(::File.open(::File.dirname(__FILE__) + "/cols.yml")) + buffer = ::YAML::unsafe_load(::File.open(::File.dirname(__FILE__) + "/buffer.yml")) + else + column_specs = ::YAML::load(::File.open(::File.dirname(__FILE__) + "/cols.yml")) + buffer = ::YAML::load(::File.open(::File.dirname(__FILE__) + "/buffer.yml")) + end Coder.read_values_v1(buffer, column_specs) end