Skip to content

Commit

Permalink
Merge branch 'release/v5.4.0' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
pat committed Dec 21, 2021
2 parents b8560be + 11b2972 commit a55f678
Show file tree
Hide file tree
Showing 13 changed files with 201 additions and 73 deletions.
168 changes: 117 additions & 51 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,77 +7,128 @@ workflows:
test:
jobs:
- test:
name: "Sphinx 2.2.11 with MySQL"
database: mysql2
name: "Sphinx 2.2"
sphinx_version: 2.2.11
sphinx_engine: sphinx
debian: jessie
ruby: '2.4.6'
- test:
name: "Sphinx 2.2.11 with PostgreSQL"
database: postgresql
sphinx_version: 2.2.11
sphinx_engine: sphinx
debian: jessie
ruby: '2.4.6'
- test:
name: "Sphinx 3.3.1 with MySQL"
database: mysql2
sphinx_version: 3.3.1
sphinx_engine: sphinx
debian: buster
matrix:
parameters:
ruby: [ '2.4.9', '2.5.8', '2.6.6', '2.7.2', '3.0.0' ]
# - test:
# database: postgresql
# sphinx_version: 3.3.1
# sphinx_engine: sphinx
# matrix:
# parameters:
# ruby: [ '2.4', '2.5', '2.6', '2.7' ]
- test:
name: "Manticore 2.8.2 with MySQL"
database: mysql2
sphinx_version: 2.8.2
sphinx_engine: manticore
debian: stretch
matrix:
parameters:
ruby: [ '2.4.9', '2.5.8', '2.6.6' ]
database: [ 'mysql2', 'postgresql' ]
rails: [ '4_2', '5_0', '5_1', '5_2' ]
- test:
name: "Manticore 2.8.2 with PostgreSQL"
database: postgresql
sphinx_version: 2.8.2
sphinx_engine: manticore
debian: stretch
name: "Sphinx 3.4"
sphinx_version: 3.4.1
sphinx_engine: sphinx
debian: buster
matrix:
parameters:
ruby: [ '2.4.9', '2.5.8', '2.6.6' ]
database: [ 'mysql2' ]
ruby: [ '2.4.10', '2.5.9', '2.6.9', '2.7.5', '3.0.3' ]
rails: [ '4_2', '5_0', '5_1', '5_2' ]
exclude:
- rails: '4_2'
ruby: '2.5.9'
- rails: '4_2'
ruby: '2.6.9'
- rails: '4_2'
ruby: '2.7.5'
- rails: '4_2'
ruby: '3.0.3'
- rails: '5_0'
ruby: '3.0.3'
- rails: '5_1'
ruby: '3.0.3'
- rails: '5_2'
ruby: '3.0.3'
- rails: '6_0'
ruby: '2.4.10'
- rails: '6_1'
ruby: '2.4.10'
- rails: '7_0'
ruby: '2.4.10'
- rails: '7_0'
ruby: '2.5.9'
- rails: '7_0'
ruby: '2.6.9'
- test:
name: "Manticore 3.5.4 with MySQL"
database: mysql2
name: "Manticore 3.5"
sphinx_version: 3.5.4
sphinx_engine: manticore
debian: buster
matrix:
parameters:
ruby: [ '2.4.9', '2.5.8', '2.6.6', '2.7.2', '3.0.0' ]
database: [ 'mysql2', 'postgresql' ]
ruby: [ '2.4.10', '2.5.9', '2.6.9', '2.7.5', '3.0.3' ]
rails: [ '4_2', '5_0', '5_1', '5_2' ]
exclude:
- rails: '4_2'
ruby: '2.5.9'
- rails: '4_2'
ruby: '2.6.9'
- rails: '4_2'
ruby: '2.7.5'
- rails: '4_2'
ruby: '3.0.3'
- rails: '5_0'
ruby: '3.0.3'
- rails: '5_1'
ruby: '3.0.3'
- rails: '5_2'
ruby: '3.0.3'
- rails: '6_0'
ruby: '2.4.10'
- rails: '6_1'
ruby: '2.4.10'
- rails: '7_0'
ruby: '2.4.10'
- rails: '7_0'
ruby: '2.5.9'
- rails: '7_0'
ruby: '2.6.9'
- test:
name: "Manticore 3.5.4 with PostgreSQL"
database: postgresql
sphinx_version: 3.5.4
name: "Manticore 4.0"
sphinx_version: 4.0.2
sphinx_engine: manticore
debian: buster
matrix:
parameters:
ruby: [ '2.4.9', '2.5.8', '2.6.6', '2.7.2', '3.0.0' ]
database: [ 'mysql2', 'postgresql' ]
ruby: [ '2.4.10', '2.5.9', '2.6.9', '2.7.5', '3.0.3' ]
rails: [ '4_2', '5_0', '5_1', '5_2' ]
exclude:
- rails: '4_2'
ruby: '2.5.9'
- rails: '4_2'
ruby: '2.6.9'
- rails: '4_2'
ruby: '2.7.5'
- rails: '4_2'
ruby: '3.0.3'
- rails: '5_0'
ruby: '3.0.3'
- rails: '5_1'
ruby: '3.0.3'
- rails: '5_2'
ruby: '3.0.3'
- rails: '6_0'
ruby: '2.4.10'
- rails: '6_1'
ruby: '2.4.10'
- rails: '7_0'
ruby: '2.4.10'
- rails: '7_0'
ruby: '2.5.9'
- rails: '7_0'
ruby: '2.6.9'

jobs:
test:
parameters:
ruby:
type: string
rails:
type: string
database:
type: string
sphinx_version:
Expand Down Expand Up @@ -108,14 +159,14 @@ jobs:

- restore_cache:
keys:
- v1-dependencies-<< parameters.ruby >>
- v1-dependencies-<< parameters.ruby >>-<< parameters.rails >>

- run:
name: install bundler
command: |
if [ "<< parameters.ruby >>" == "2.7.2" ]; then
if [ "<< parameters.ruby >>" == "2.7.5" ]; then
export BUNDLER_VERSION=2.1.4
elif [ "<< parameters.ruby >>" == "3.0.0" ]; then
elif [ "<< parameters.ruby >>" == "3.0.3" ]; then
export BUNDLER_VERSION=2.1.4
else
export BUNDLER_VERSION=1.17.3
Expand All @@ -131,12 +182,22 @@ jobs:
- run:
name: set up appraisal
command: bundle exec appraisal update
command: bundle exec appraisal generate

- run:
name: update gems
environment:
BUNDLE_GEMFILE: "./gemfiles/rails_<< parameters.rails >>.gemfile"
command: |
if [[ -f $BUNDLE_GEMFILE ]]
then
bundle update
fi
- save_cache:
paths:
- ./vendor/bundle
key: v1-dependencies-<< parameters.ruby >>
key: v1-dependencies-<< parameters.ruby >>-<< parameters.rails >>

- run:
name: set up sphinx
Expand All @@ -149,4 +210,9 @@ jobs:
DATABASE: << parameters.database >>
SPHINX_VERSION: << parameters.sphinx_version >>
SPHINX_ENGINE: << parameters.sphinx_engine >>
command: bundle exec appraisal rspec
BUNDLE_GEMFILE: "./gemfiles/rails_<< parameters.rails >>.gemfile"
command: |
if [[ -f $BUNDLE_GEMFILE ]]
then
bundle exec rspec
fi
6 changes: 6 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@ appraise 'rails_6_1' do
gem 'mysql2', '~> 0.5.0', :platform => :ruby
gem 'pg', '~> 1.0', :platform => :ruby
end if RUBY_PLATFORM != 'java' && RUBY_VERSION.to_f >= 2.5

appraise 'rails_7_0' do
gem 'rails', '~> 7.0.0'
gem 'mysql2', '~> 0.5.0', :platform => :ruby
gem 'pg', '~> 1.0', :platform => :ruby
end if RUBY_PLATFORM != 'java' && RUBY_VERSION.to_f >= 2.7
17 changes: 17 additions & 0 deletions CHANGELOG.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

All notable changes to this project (at least, from v3.0.0 onwards) are documented in this file.

## 5.4.0 - 2021-12-21

[Release Notes](https://github.com/pat/thinking-sphinx/releases/tag/v5.4.0)

### Added

* Rails 7 support, including contributions from @anthonyshull in [#1205](https://github.com/pat/thinking-sphinx/pull/1205).

### Changed

* Confirmed support by testing against Manticore 4.0 and Sphinx 3.4.

### Fixed

* Include instance_exec in ThinkingSphinx::Search::CORE_METHODS by @jdelStrother in [#1210](https://github.com/pat/thinking-sphinx/pull/1210).
* Use File.exist? instead of the deprecated File.exists? ([#1211](https://github.com/pat/thinking-sphinx/issues/1211)).

## 5.3.0 - 2021-08-19

[Release Notes](https://github.com/pat/thinking-sphinx/releases/tag/v5.3.0)
Expand Down
14 changes: 8 additions & 6 deletions README.textile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
h1. Thinking Sphinx

Thinking Sphinx is a library for connecting ActiveRecord to the Sphinx full-text search tool, and integrates closely with Rails (but also works with other Ruby web frameworks). The current release is v5.3.0.
Thinking Sphinx is a library for connecting ActiveRecord to the Sphinx full-text search tool, and integrates closely with Rails (but also works with other Ruby web frameworks). The current release is v5.4.0.

h2. Upgrading

Expand All @@ -14,7 +14,7 @@ It's a gem, so install it like you would any other gem. You will also need to sp

<pre><code>gem 'mysql2', '~> 0.4', :platform => :ruby
gem 'jdbc-mysql', '~> 5.1.35', :platform => :jruby
gem 'thinking-sphinx', '~> 5.3'</code></pre>
gem 'thinking-sphinx', '~> 5.4'</code></pre>

The MySQL gems mentioned are required for connecting to Sphinx, so please include it even when you're using PostgreSQL for your database.

Expand All @@ -31,16 +31,18 @@ The current release of Thinking Sphinx works with the following versions of its
|_. Library |_. Minimum |_. Tested Against |
| Ruby | v2.4 | v2.4, v2.5, v2.6, v2.7, v3.0 |
| Sphinx | v2.2.11 | v2.2.11, v3.3.1 |
| Manticore | v2.8 | v2.8, v3.5 |
| ActiveRecord | v4.2 | v4.2..v6.1 |
| Manticore | v2.8 | v3.5, v4.0 |
| ActiveRecord | v4.2 | v4.2..v7.0 |

It _might_ work with older versions of Ruby, but it's highly recommended to update to a supported release.

It should also work with JRuby, but the test environment for that in CI has been unreliable, hence that's not actively tested against at the moment.

h3. Sphinx or Manticore

Thinking Sphinx is currently built for Sphinx 2.2.11 or newer, or Manticore v2.8+.
If you're using Sphinx, v2.2.11 is recommended even though it's quite old, as it works well with PostgreSQL databases (but if you're using MySQL - or real-time indices - then v3.3.1 should also be fine).

If you're opting for Manticore instead, v2.8 or newer works, but v3 or newer is recommended as that's what is actively tested against.

h3. Rails and ActiveRecord

Expand Down Expand Up @@ -79,4 +81,4 @@ You can then run the unit tests with @rake spec:unit@, the acceptance tests with

h2. Licence

Copyright (c) 2007-2020, Thinking Sphinx is developed and maintained by Pat Allan, and is released under the open MIT Licence. Many thanks to "all who have contributed patches":https://github.com/pat/thinking-sphinx/contributors.
Copyright (c) 2007-2021, Thinking Sphinx is developed and maintained by Pat Allan, and is released under the open MIT Licence. Many thanks to "all who have contributed patches":https://github.com/pat/thinking-sphinx/contributors.
5 changes: 5 additions & 0 deletions bin/loadsphinx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ load_sphinx () {
3.3.1)
url="http://sphinxsearch.com/files/sphinx-3.3.1-b72d67b-linux-amd64.tar.gz"
format="gz";;
3.4.1)
url="http://sphinxsearch.com/files/sphinx-3.4.1-efbcc65-linux-amd64.tar.gz"
format="gz";;
*)
echo "No Sphinx version $version available"
exit 1;;
Expand Down Expand Up @@ -64,6 +67,8 @@ load_manticore () {
url="https://github.com/manticoresoftware/manticoresearch/releases/download/3.4.2/manticore_3.4.2-200410-6903305-release.xenial_amd64-bin.deb";;
3.5.4)
url="https://repo.manticoresearch.com/repository/manticoresearch_buster/pool/m/manticore/manticore_3.5.4-201211-13f8d08d_amd64.deb";;
4.0.2)
url="https://repo.manticoresearch.com/repository/manticoresearch_buster/pool/m/manticore/manticore_4.0.2-210921-af497f245_amd64.deb";;
*)
echo "No Manticore version $version available"
exit 1;;
Expand Down
10 changes: 8 additions & 2 deletions lib/thinking_sphinx/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ class ThinkingSphinx::Railtie < Rails::Railtie
require 'thinking_sphinx/active_record'
end

if ActiveSupport::VERSION::MAJOR > 5 &&
Rails.application.config.autoloader == :zeitwerk
if zeitwerk?
ActiveSupport::Dependencies.autoload_paths.delete(
Rails.root.join("app", "indices").to_s
)
Expand All @@ -29,4 +28,11 @@ class ThinkingSphinx::Railtie < Rails::Railtie
rake_tasks do
load File.expand_path('../tasks.rb', __FILE__)
end

def zeitwerk?
return true if ActiveSupport::VERSION::MAJOR >= 7
return false if ActiveSupport::VERSION::MAJOR <= 5

Rails.application.config.autoloader == :zeitwerk
end
end
2 changes: 1 addition & 1 deletion lib/thinking_sphinx/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class ThinkingSphinx::Search < Array
CORE_METHODS = %w( == class class_eval extend frozen? id instance_eval
instance_of? instance_values instance_variable_defined?
instance_exec instance_of? instance_values instance_variable_defined?
instance_variable_get instance_variable_set instance_variables is_a?
kind_of? member? method methods nil? object_id respond_to?
respond_to_missing? send should should_not type )
Expand Down
2 changes: 1 addition & 1 deletion lib/thinking_sphinx/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def self.clear
config.indices_location,
config.searchd.binlog_path
].each do |path|
FileUtils.rm_r(path) if File.exists?(path)
FileUtils.rm_r(path) if File.exist?(path)
end
end

Expand Down
12 changes: 10 additions & 2 deletions spec/acceptance/attribute_access_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
search = Book.search 'gods', :select => "*, weight()"
search.context[:panes] << ThinkingSphinx::Panes::WeightPane

expect(search.first.weight).to eq(2500)
if ENV["SPHINX_ENGINE"] == "sphinx" && ENV["SPHINX_VERSION"].to_f > 3.3
expect(search.first.weight).to eq(20_000.0)
else
expect(search.first.weight).to eq(2500)
end
end

it "provides direct access to the weight with alternative primary keys" do
Expand All @@ -39,7 +43,11 @@
search = Book.search 'gods', :select => "*, weight()"
search.masks << ThinkingSphinx::Masks::WeightEnumeratorMask

expectations = [[gods, 2500]]
if ENV["SPHINX_ENGINE"] == "sphinx" && ENV["SPHINX_VERSION"].to_f > 3.3
expectations = [[gods, 20_000.0]]
else
expectations = [[gods, 2500]]
end
search.each_with_weight do |result, weight|
expectation = expectations.shift

Expand Down
Loading

0 comments on commit a55f678

Please sign in to comment.