From 59444331f4a197a8dd9e4f5c9abaf0bba46757d7 Mon Sep 17 00:00:00 2001 From: Michael Mior Date: Mon, 11 Mar 2024 09:46:31 -0400 Subject: [PATCH] Test with Ruby 3.x --- .github/workflows/ci.yml | 7 ++++++- .rspec | 1 - lib/nose/backend/cassandra.rb | 1 + lib/nose/backend/file.rb | 4 +++- nose.gemspec | 9 +++++---- spec/backend/cassandra_backend_spec.rb | 4 ++-- spec/spec_helper.rb | 4 ++-- 7 files changed, 19 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 07cb4e70..f43fb81e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: ['2.5.3', '2.6.1'] + ruby-version: ['3.1.4', '3.2.3', '3.3.0'] services: mysql: image: mysql:5.6 @@ -61,3 +61,8 @@ jobs: run: | sed -i '/^--tag/d' .rspec bundle exec rspec + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.rspec b/.rspec index be88af17..eea5e8e6 100644 --- a/.rspec +++ b/.rspec @@ -1,6 +1,5 @@ --color --format documentation --require spec_helper ---tag ~cassandra --tag ~mongo --tag ~mysql diff --git a/lib/nose/backend/cassandra.rb b/lib/nose/backend/cassandra.rb index a67a1d8e..780f96b9 100644 --- a/lib/nose/backend/cassandra.rb +++ b/lib/nose/backend/cassandra.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require 'sorted_set' require 'cassandra' require 'zlib' diff --git a/lib/nose/backend/file.rb b/lib/nose/backend/file.rb index 4caf24d2..eaa6de07 100644 --- a/lib/nose/backend/file.rb +++ b/lib/nose/backend/file.rb @@ -24,7 +24,9 @@ def initialize(model, indexes, plans, update_plans, config) # Save data when the object is destroyed def self.finalize(index_data, file) proc do - Marshal.dump(index_data, File.open(file, 'w')) + if !file.nil? + Marshal.dump(index_data, File.open(file, 'w')) + end end end diff --git a/nose.gemspec b/nose.gemspec index 5c7b5d5c..b944aecc 100644 --- a/nose.gemspec +++ b/nose.gemspec @@ -29,15 +29,15 @@ Gem::Specification.new do |s| s.add_dependency 'ruby-mysql', '~> 2.9.14', '>= 2.9.0' # for the proxy because it's pure Ruby s.add_dependency 'sequel', '~> 5.41.0', '>= 4.46.0' s.add_dependency 'smarter_csv', '1.10.2' + s.add_dependency 'sorted_set', '~> 1.0', '>= 1.0.3' # Required for Cassandra backend - s.add_dependency 'cassandra-driver', '~> 3.2.3', '>= 3.1.0' + s.add_dependency 'cassandra-driver', '~> 3.2.5', '>= 3.1.0' # Required for MongoDB backend s.add_dependency 'mongo', '>= 2.14', '< 2.20' - s.add_development_dependency 'codecov', '~> 0.4.3' - s.add_development_dependency 'fakefs', '~> 1.3.2' + s.add_development_dependency 'fakefs', '~> 2.5.0' s.add_development_dependency 'memory_profiler', '~> 1.0.0' s.add_development_dependency 'pry-byebug', '~> 3.9.0' s.add_development_dependency 'pry-doc', '~> 1.1.0' @@ -47,7 +47,8 @@ Gem::Specification.new do |s| s.add_development_dependency 'rspec-core', '~> 3.10.0' s.add_development_dependency 'rspec-collection_matchers', '~> 1.2.0', '>= 1.1.0' s.add_development_dependency 'ruby-prof', '~> 1.4.2' - s.add_development_dependency 'simplecov', '~> 0.21.2' + s.add_development_dependency 'simplecov', '~> 0.22.0' + s.add_development_dependency 'simplecov-cobertura', '~> 2.1' s.add_development_dependency 'yard', '~> 0.9.4' # Below for MRI only (TODO JRuby gemspec) diff --git a/spec/backend/cassandra_backend_spec.rb b/spec/backend/cassandra_backend_spec.rb index 1786ccad..529c0cf9 100644 --- a/spec/backend/cassandra_backend_spec.rb +++ b/spec/backend/cassandra_backend_spec.rb @@ -83,8 +83,8 @@ module Backend # Validate the expected CQL query client = double('client') - backend_query = 'SELECT "User_Username", "Tweet_Timestamp", ' \ - '"Tweet_Body" ' + "FROM \"#{index.key}\" " \ + backend_query = 'SELECT "Tweet_Body", "User_Username", ' \ + '"Tweet_Timestamp" ' + "FROM \"#{index.key}\" " \ 'WHERE "User_Username" = ? ' \ 'ORDER BY "Tweet_Timestamp" LIMIT 10' expect(client).to receive(:prepare).with(backend_query) \ diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b6b89d3e..490a2385 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,8 +8,8 @@ require 'simplecov' SimpleCov.start -require 'codecov' -SimpleCov.formatter = SimpleCov::Formatter::Codecov +require 'simplecov-cobertura' +SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter require 'rspec/collection_matchers' require 'fakefs/safe'