From 6e541d196d5d1f96632b54fd02241ff8854e37f9 Mon Sep 17 00:00:00 2001 From: Jeremy Corbett Date: Wed, 10 Jul 2024 10:30:25 -0700 Subject: [PATCH] Revert "Revert "Updates for ruby 3.0 (#1)"" This reverts commit 1b3f6ea7ff26ac8fe4c47d0e565c113c3412bc2f. --- .github/ISSUE_TEMPLATE.md | 16 ++++ .github/PULL_REQUEST_TEMPLATE.md | 17 ++++ .github/workflows/ci.yml | 33 +++++++ .gitignore | 1 + .travis.yml | 30 ------ Gemfile | 1 + Gemfile.lock | 127 -------------------------- Rakefile | 10 ++ cassandra-driver.gemspec | 3 +- lib/cassandra/version.rb | 8 +- spec/cassandra/protocol/coder_spec.rb | 15 ++- spec/cassandra/session_spec.rb | 2 +- 12 files changed, 100 insertions(+), 163 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml delete mode 100644 Gemfile.lock diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 000000000..17e2a6bcf --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,16 @@ +## Expected Behavior + + +## Actual Behavior + + +## Steps to Reproduce the Problem + + 1. + 2. + 3. + +## Specifications + + - Version: + - Ruby version: diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..5a4396151 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,17 @@ +## What is the current behavior? + + + +## What is the new behavior? + + + +## Checklist + +Please make sure the following requirements are complete: + +- [ ] Tests for the changes have been added (for bug fixes / features) +- [ ] Docs have been reviewed and added / updated if needed (for bug fixes / + features) +- [ ] All automated checks pass (CI/CD) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..d9aff3b94 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,33 @@ +name: CI + +on: + push: + branches: + - main + - master + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + ruby: ['2.7', '3.0', '3.1'] + + steps: + - uses: actions/checkout@v4 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + + - name: Runs code QA and tests + env: + COVERAGE: no + run: | + sudo apt-get update + sudo apt-get install openjdk-8-jdk + bundle + bundle exec rake rspec diff --git a/.gitignore b/.gitignore index a89900b1b..4e48799e8 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ /*.gem /.bundle/* /.idea/ +Gemfile.lock diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4fce134a7..000000000 --- a/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ -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 - - jruby-9.0.5.0 -jdk: - - openjdk8 -env: - global: - - FAIL_FAST=no - - COVERAGE=no -matrix: - fast_finish: true -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 - # 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 - fi diff --git a/Gemfile b/Gemfile index 8af924584..780526090 100644 --- a/Gemfile +++ b/Gemfile @@ -25,6 +25,7 @@ group :test do gem 'rspec-collection_matchers' gem 'rspec-wait' gem 'simplecov' + gem 'byebug' end group :docs do diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 62622f396..000000000 --- a/Gemfile.lock +++ /dev/null @@ -1,127 +0,0 @@ -PATH - remote: . - specs: - cassandra-driver (3.2.5) - ione (~> 1.2) - -GEM - remote: https://rubygems.org/ - specs: - ansi (1.5.0) - aruba (0.13.0) - childprocess (~> 0.5.6) - contracts (~> 0.9) - cucumber (>= 1.3.19) - ffi (~> 1.9.10) - rspec-expectations (>= 2.99) - thor (~> 0.19) - ast (2.3.0) - builder (3.2.2) - childprocess (0.5.9) - ffi (~> 1.0, >= 1.0.11) - chronic (0.10.2) - cliver (0.3.2) - contracts (0.13.0) - cucumber (2.3.2) - builder (>= 2.1.2) - cucumber-core (~> 1.4.0) - cucumber-wire (~> 0.0.1) - diff-lcs (>= 1.1.3) - gherkin (~> 3.2.0) - multi_json (>= 1.7.5, < 2.0) - multi_test (>= 0.1.2) - cucumber-core (1.4.0) - gherkin (~> 3.2.0) - cucumber-wire (0.0.1) - delorean (2.1.0) - chronic - diff-lcs (1.2.5) - docile (1.1.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) - lz4-ruby (0.3.3) - lz4-ruby (0.3.3-java) - minitest (4.7.5) - multi_json (1.11.2) - multi_test (0.1.2) - os (0.9.6) - parallel (1.12.0) - parser (2.4.0.2) - ast (~> 2.3) - perftools.rb (2.0.4) - powerpack (0.1.1) - rainbow (2.2.2) - rake - rake (13.0.1) - rake-compiler (0.9.5) - rake - rspec (3.9.0) - rspec-core (~> 3.9.0) - rspec-expectations (~> 3.9.0) - rspec-mocks (~> 3.9.0) - rspec-collection_matchers (1.2.0) - rspec-expectations (>= 2.99.0.beta1) - rspec-core (3.9.1) - rspec-support (~> 3.9.1) - rspec-expectations (3.9.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-mocks (3.9.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-support (3.9.2) - rspec-wait (0.0.9) - rspec (>= 3, < 4) - rubocop (0.51.0) - parallel (~> 1.10) - parser (>= 2.3.3.1, < 3.0) - powerpack (~> 0.1) - rainbow (>= 2.2.2, < 3.0) - 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) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.0) - 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) - unicode-display_width (1.3.0) - yard (0.9.20) - -PLATFORMS - java - ruby - -DEPENDENCIES - ansi - aruba - bundler (~> 1.6) - cassandra-driver! - cliver - cucumber - delorean - lz4-ruby - minitest (< 5.0.0) - os - perftools.rb - rake (~> 13.0) - rake-compiler - rspec - rspec-collection_matchers - rspec-wait - rubocop (~> 0.51) - simplecov - snappy - yard - -BUNDLED WITH - 1.17.3 diff --git a/Rakefile b/Rakefile index 43a06e844..86b2b29ad 100644 --- a/Rakefile +++ b/Rakefile @@ -59,3 +59,13 @@ Rake::TestTask.new(stress: :compile) do |t| t.test_files = FileList['integration/stress_tests/*_test.rb'] t.verbose = true end + +desc 'Build the package and publish it to rubygems.pkg.github.com' +task publish: :build do + # Requires local setup of personal access token, see: + # 1. https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-rubygems-registry#authenticating-with-a-personal-access-token + system("gem push --key github --host https://rubygems.pkg.github.com/art19 " \ + "pkg/cassandra-driver-#{Cassandra::VERSION}.gem") +end + + diff --git a/cassandra-driver.gemspec b/cassandra-driver.gemspec index bd2624b50..c210e8b49 100644 --- a/cassandra-driver.gemspec +++ b/cassandra-driver.gemspec @@ -31,7 +31,8 @@ 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 'bundler' s.add_development_dependency 'rake', '~> 13.0' end diff --git a/lib/cassandra/version.rb b/lib/cassandra/version.rb index ed8d2183c..9fd98328c 100644 --- a/lib/cassandra/version.rb +++ b/lib/cassandra/version.rb @@ -17,5 +17,11 @@ #++ module Cassandra - VERSION = '3.2.5'.freeze + ## + # ART19 maintains a fork with patches applied on top of the upstream gem. + # We publish our fork with a revision number appended to the upstream version. + # + # @return [String] the ART19 revision number + ART19_REVISION = '1'.freeze + VERSION = "3.2.5.#{ART19_REVISION}".freeze end diff --git a/spec/cassandra/protocol/coder_spec.rb b/spec/cassandra/protocol/coder_spec.rb index c6c7e17f2..98e79b145 100644 --- a/spec/cassandra/protocol/coder_spec.rb +++ b/spec/cassandra/protocol/coder_spec.rb @@ -37,11 +37,20 @@ module Protocol end describe('RUBY-128') do + let(:permitted_classes) { [Cassandra::Protocol::CqlByteBuffer, Cassandra::Types::Map, Cassandra::Types::Simple, Symbol] } + 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")) + if Psych::VERSION.to_i >= 4 + column_specs = ::YAML::load(::File.open(::File.dirname(__FILE__) + "/cols.yml"), aliases: true, permitted_classes: permitted_classes) + buffer = ::YAML::load(::File.open(::File.dirname(__FILE__) + "/buffer.yml"), permitted_classes: permitted_classes) + + Coder.read_values_v1(buffer, column_specs) + else + column_specs = ::YAML::load(::File.open(::File.dirname(__FILE__) + "/cols.yml")) + buffer = ::YAML::load(::File.open(::File.dirname(__FILE__) + "/buffer.yml")) - Coder.read_values_v1(buffer, column_specs) + Coder.read_values_v1(buffer, column_specs) + end end end end diff --git a/spec/cassandra/session_spec.rb b/spec/cassandra/session_spec.rb index 321979bb9..aaf45528f 100644 --- a/spec/cassandra/session_spec.rb +++ b/spec/cassandra/session_spec.rb @@ -143,7 +143,7 @@ module Cassandra bound_statement = double('bound statement') options = double('options') - expect(session_options).to receive(:override).once.with(nil, arguments: [1, 2, 3, 4, 5]).and_return(options) + expect(session_options).to receive(:override).once.with(nil, { arguments: [1, 2, 3, 4, 5] }).and_return(options) allow(options).to receive(:arguments).and_return([1, 2, 3, 4, 5]) expect(statement).to receive(:bind).with([1, 2, 3, 4, 5]).and_return(bound_statement) expect(client).to receive(:execute).once.with(bound_statement, options).and_return(promise)