Skip to content

Commit

Permalink
Update the opensearch-rails gem (RM-2427)
Browse files Browse the repository at this point in the history
- Ruby 3.2 support
- Remove CI / CD support for unsupported Ruby & Rails versions
- Ensure compatibility with opensearch-ruby 3
  • Loading branch information
martijnbolhuis authored Feb 9, 2024
1 parent e128c9e commit b0493f2
Show file tree
Hide file tree
Showing 27 changed files with 75 additions and 226 deletions.
47 changes: 0 additions & 47 deletions .github/workflows/2.5.yml

This file was deleted.

46 changes: 0 additions & 46 deletions .github/workflows/2.6.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/2.7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
tests:
env:
TEST_ES_SERVER: http://localhost:9200
RAILS_VERSIONS: '5.0,6.0'
RAILS_VERSIONS: '6.1,7.1'
strategy:
fail-fast: false
runs-on: ubuntu-latest
Expand All @@ -34,7 +34,7 @@ jobs:
- name: Bundle
run: |
sudo apt-get install libsqlite3-dev
gem install bundler
gem install bundler -v 2.4.22
bundle install
bundle exec rake bundle:clean
bundle exec rake bundle:install
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/2.4.yml → .github/workflows/3.2.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Ruby 2.4
name: Ruby 3.2
on:
push:
branches:
Expand All @@ -13,7 +13,7 @@ jobs:
tests:
env:
TEST_ES_SERVER: http://localhost:9200
RAILS_VERSIONS: '5.0'
RAILS_VERSIONS: '7.1'
strategy:
fail-fast: false
runs-on: ubuntu-latest
Expand All @@ -30,7 +30,7 @@ jobs:
cluster-version: 2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.4
ruby-version: 3.2
- name: Bundle
run: |
sudo apt-get install libsqlite3-dev
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 1.1.0

No functional changes.

- Ruby 3.2 support
- Remove CI / CD support for unsupported Ruby & Rails versions
- Ensure compatibility with opensearch-ruby 3

## 1.0.0

* Support OpenSearch 2 by removing deprecated type and include_type_name parameters
Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# OpenSearch

[![Ruby 3.2](https://github.com/compliance-innovations/opensearch-rails/actions/workflows/3.2.yml/badge.svg)](https://github.com/compliance-innovations/opensearch-rails/actions/workflows/3.2.yml)
[![Ruby 2.7](https://github.com/compliance-innovations/opensearch-rails/workflows/Ruby%202.7/badge.svg)](https://github.com/compliance-innovations/opensearch-rails/actions)
[![Ruby 2.6](https://github.com/compliance-innovations/opensearch-rails/workflows/Ruby%202.6/badge.svg)](https://github.com/compliance-innovations/opensearch-rails/actions)
[![Ruby 2.5](https://github.com/compliance-innovations/opensearch-rails/workflows/Ruby%202.5/badge.svg)](https://github.com/compliance-innovations/opensearch-rails/actions)
[![Ruby 2.4](https://github.com/compliance-innovations/opensearch-rails/workflows/Ruby%202.4/badge.svg)](https://github.com/compliance-innovations/opensearch-rails/actions)
[![JRuby](https://github.com/compliance-innovations/opensearch-rails/workflows/JRuby/badge.svg)](https://github.com/compliance-innovations/opensearch-rails/actions)

This repository contains various Ruby and Rails integrations for [OpenSearch](https://opensearch.org/). This is a fork
Expand Down Expand Up @@ -92,7 +90,7 @@ You can generate a simple Ruby on Rails application with a single command
--env "cluster.name=opensearch-rails" \
--env "cluster.routing.allocation.disk.threshold_enabled=false" \
--rm \
opensearchproject/opensearch:1.3.0
opensearchproject/opensearch:latest
```

Once OpenSearch is running, you can generate the simple app with this command:
Expand Down Expand Up @@ -168,9 +166,9 @@ This software is licensed under the Apache 2 license, quoted below.
the Apache License, Version 2.0 (the "License"); you may
not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand Down
4 changes: 2 additions & 2 deletions opensearch-model/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ desc 'Run unit tests'
task default: 'test:all'
task test: 'test:all'

gemfiles = ['5.0.gemfile', '6.0.gemfile']
gemfiles << '4.0.gemfile' if RUBY_VERSION < '2.7'
gemfiles = ['7.1.gemfile']
gemfiles << '6.1.gemfile' if RUBY_VERSION <= '3.0'
GEMFILES = gemfiles.freeze

namespace :bundle do
Expand Down
35 changes: 0 additions & 35 deletions opensearch-model/gemfiles/3.0.gemfile

This file was deleted.

36 changes: 0 additions & 36 deletions opensearch-model/gemfiles/4.0.gemfile

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ source 'https://rubygems.org'

gemspec path: '../'

gem 'activemodel', '6.0.0'
gem 'activerecord', '6.0.0'
gem 'activemodel', '~> 6.1'
gem 'activerecord', '~> 6.1'
gem 'sqlite3' unless defined?(JRUBY_VERSION)
#gem 'mongoid', '~> 6'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@

# Usage:
#
# $ BUNDLE_GEMFILE=./gemfiles/5.0.gemfile bundle install
# $ BUNDLE_GEMFILE=./gemfiles/5.0.gemfile bundle exec rake test:integration
# $ BUNDLE_GEMFILE=./gemfiles/6.0.gemfile bundle install
# $ BUNDLE_GEMFILE=./gemfiles/6.0.gemfile bundle exec rake test:integration


source 'https://rubygems.org'

gemspec path: '../'

gem 'activemodel', '~> 5'
gem 'activerecord', '~> 5'
gem 'activemodel', '~> 7.1'
gem 'activerecord', '~> 7.1'
gem 'sqlite3' unless defined?(JRUBY_VERSION)
gem 'mongoid', '~> 6'
#gem 'mongoid', '~> 6'

group :development, :testing do
gem 'rspec'
Expand Down
2 changes: 1 addition & 1 deletion opensearch-model/lib/opensearch/model/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@

module OpenSearch
module Model
VERSION = "1.0.0"
VERSION = "1.1.0"
end
end
4 changes: 2 additions & 2 deletions opensearch-model/opensearch-model.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require 'opensearch/model/version'
Gem::Specification.new do |s|
s.name = 'opensearch-model'
s.version = OpenSearch::Model::VERSION
s.authors = ['Compliance Innovations B.V.']
s.authors = ['CDD Solutions B.V.']
s.email = ['[email protected]']
s.description = 'ActiveModel/Record integrations for OpenSearch.'
s.summary = 'ActiveModel/Record integrations for OpenSearch.'
Expand All @@ -42,7 +42,7 @@ Gem::Specification.new do |s|
s.required_ruby_version = '>= 2.4'

s.add_dependency 'activesupport', '> 3'
s.add_dependency "opensearch-ruby", '~> 2.0'
s.add_dependency "opensearch-ruby", '>= 2'
s.add_dependency 'hashie'

s.add_development_dependency 'activemodel', '> 3'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
MyNamespace::Book.__opensearch__.refresh_index!
end

after do
after(:all) do
clear_indices(MyNamespace::Book)
clear_tables(MyNamespace::Book)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
context 'when a document is updated' do

before do
article.update_attributes(title: 'UPDATED', status: 'yellow')
article.update(title: 'UPDATED', status: 'yellow')
ArticleWithCustomSerialization.__opensearch__.refresh_index!
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class DummyClassForMongoid; end
context 'query criteria specified as a hash' do

before do
expect(relation).to receive(:where).with(color: 'red').and_return(relation)
expect(relation).to receive(:where).with({ color: 'red' }).and_return(relation)
end

let(:query) do
Expand Down
12 changes: 6 additions & 6 deletions opensearch-model/spec/opensearch/model/importing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ def importing_mixin
context 'when the method is called with the force option' do

before do
expect(DummyImportingModel).to receive(:create_index!).with(force: true, index: 'foo').and_return(true)
expect(DummyImportingModel).to receive(:__find_in_batches).with(foo: 'bar').and_return(true)
expect(DummyImportingModel).to receive(:create_index!).with({ force: true, index: 'foo' }).and_return(true)
expect(DummyImportingModel).to receive(:__find_in_batches).with({ foo: 'bar' }).and_return(true)
end

it 'deletes and creates the index' do
Expand All @@ -145,8 +145,8 @@ def importing_mixin
context 'when the method is called with the refresh option' do

before do
expect(DummyImportingModel).to receive(:refresh_index!).with(index: 'foo').and_return(true)
expect(DummyImportingModel).to receive(:__find_in_batches).with(foo: 'bar').and_return(true)
expect(DummyImportingModel).to receive(:refresh_index!).with({ index: 'foo' }).and_return(true)
expect(DummyImportingModel).to receive(:__find_in_batches).with({ foo: 'bar' }).and_return(true)
end

it 'refreshes the index' do
Expand All @@ -158,7 +158,7 @@ def importing_mixin

before do
expect(DummyImportingModel).to receive(:client).and_return(client)
expect(client).to receive(:bulk).with(body: nil, index: 'my-new-index').and_return(response)
expect(client).to receive(:bulk).with({ body: nil, index: 'my-new-index' }).and_return(response)
end

it 'uses the alternate index name' do
Expand Down Expand Up @@ -219,7 +219,7 @@ def importing_mixin

before do
expect(DummyImportingModel).to receive(:client).and_return(client)
expect(client).to receive(:bulk).with(body: nil, index: 'foo', pipeline: 'my-pipeline').and_return(response)
expect(client).to receive(:bulk).with({ body: nil, index: 'foo', pipeline: 'my-pipeline' }).and_return(response)
end

it 'uses the pipeline option' do
Expand Down
Loading

0 comments on commit b0493f2

Please sign in to comment.