Skip to content

Commit 1ddf6d8

Browse files
authored
Replace Travis CI with GitHub Actions (sunspot#1029)
* Replace Travis CI with GitHub Actions There has been a price change in Travis CI. Therefore, we have replaced it with GitHub Actions, which is free for open-source software. refs: https://yoursunny.com/t/2020/TravisCI-credits/ * Avoiding the NoMethodError for force_encoding NoMethodError occurred when 'body' was not included in the fake_rsolr_response. * Fixed Incorrect Arguments The :boost argument for the boost method occasionally accepted two arguments. refs: An error occurred while loading ./spec/integration/unicode_spec.rb. Failure/Error: def boost(attr_name = nil, &block) @setup.add_document_boost(attr_name, &block) ArgumentError: wrong number of arguments (given 2, expected 0..1) # ./lib/sunspot/dsl/fields.rb:54:in `boost' # ./lib/sunspot/util.rb:301:in `__proxy_method__' # ./lib/sunspot/util.rb:293:in `method_missing' # ./spec/mocks/comment.rb:20:in `block in <top (required)>' # ./lib/sunspot/util.rb:257:in `instance_eval' # ./lib/sunspot/util.rb:257:in `instance_eval_with_context' # ./lib/sunspot/util.rb:102:in `instance_eval_or_call' # ./lib/sunspot/setup.rb:135:in `setup' # ./lib/sunspot/setup.rb:376:in `setup' # ./lib/sunspot.rb:172:in `setup' # ./spec/mocks/comment.rb:13:in `<top (required)>' # ./spec/spec_helper.rb:8:in `require' # ./spec/spec_helper.rb:8:in `block in <top (required)>' # ./spec/spec_helper.rb:7:in `each' # ./spec/spec_helper.rb:7:in `<top (required)>' # ./spec/integration/unicode_spec.rb:2:in `require' # ./spec/integration/unicode_spec.rb:2:in `<top (required)>' * Changing to Ruby 2.1 as Ruby 2.1.0 is not supported by ruby/setup-ruby@v1 * Specify Bundler version using ruby/setup-ruby@v1 options * Disable configurations that are failing tests * Revert "removes the ruby version condition" This reverts commit 665c874. * Revert "Allow using methods with keyword arguments in search DSL" This reverts commit e166c1d. * Update Ruby versions for CI to 2.5, 2.6, 2.7 * Replace removed method in Ruby 2.7 with BigDecimal() * Update actions/setup-java@v3 as Node v12 is now deprecated
1 parent 414a594 commit 1ddf6d8

File tree

11 files changed

+58
-79
lines changed

11 files changed

+58
-79
lines changed

.github/workflows/ci.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: CI
2+
on: [push, pull_request]
3+
jobs:
4+
build:
5+
runs-on: ubuntu-latest
6+
timeout-minutes: 60
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
ruby-version:
11+
- '2.5'
12+
- '2.6'
13+
- '2.7'
14+
# - 'head'
15+
gem: ['sunspot', 'sunspot_rails', 'sunspot_solr']
16+
update-format: ['xml', 'json']
17+
steps:
18+
- uses: actions/checkout@v3
19+
- name: Set up JDK 1.8
20+
uses: actions/setup-java@v3
21+
with:
22+
java-version: '8'
23+
distribution: 'adopt'
24+
- name: Set up Ruby
25+
uses: ruby/setup-ruby@v1
26+
with:
27+
ruby-version: ${{ matrix.ruby-version }}
28+
bundler: '1'
29+
bundler-cache: true # 'bundle install' and cache are handled automatically
30+
- name: Test
31+
run: ci/sunspot_test_script.sh
32+
env:
33+
GEM: ${{ matrix.gem }}
34+
UPDATE_FORMAT: ${{ matrix.update-format }}

.travis.yml

-41
This file was deleted.

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1667,9 +1667,9 @@ To run all the specs just call `rake` from the library root folder.
16671667
To run specs related to individual gems, consider using one of the following commands:
16681668

16691669
```bash
1670-
GEM=sunspot ci/travis.sh
1671-
GEM=sunspot_rails ci/travis.sh
1672-
GEM=sunspot_solr ci/travis.sh
1670+
GEM=sunspot ci/sunspot_test_script.sh
1671+
GEM=sunspot_rails ci/sunspot_test_script.sh
1672+
GEM=sunspot_solr ci/sunspot_test_script.sh
16731673
```
16741674

16751675
### Generating Documentation

Rakefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ end
5151

5252
desc 'Run all the tests'
5353
task :default do
54-
exit system([ "GEM=sunspot ci/travis.sh",
55-
"GEM=sunspot_rails ci/travis.sh",
56-
"GEM=sunspot_solr ci/travis.sh"].join(" && ")) ? 0 : 1
54+
exit system([ "GEM=sunspot ci/sunspot_test_script.sh",
55+
"GEM=sunspot_rails ci/sunspot_test_script.sh",
56+
"GEM=sunspot_solr ci/sunspot_test_script.sh"].join(" && ")) ? 0 : 1
5757
end
File renamed without changes.

sunspot/lib/sunspot/util.rb

+11-13
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def deep_merge_into(destination, left, right)
248248
Coordinates = Struct.new(:lat, :lng)
249249

250250
class ContextBoundDelegate
251-
class << self
251+
class <<self
252252
def instance_eval_with_context(receiver, &block)
253253
calling_context = eval('self', block.binding)
254254
if parent_calling_context = calling_context.instance_eval{@__calling_context__ if defined?(@__calling_context__)}
@@ -289,21 +289,19 @@ def sub(*args, &block)
289289
__proxy_method__(:sub, *args, &block)
290290
end
291291

292-
def method_missing(method, *args, **kwargs, &block)
293-
__proxy_method__(method, *args, **kwargs, &block)
292+
def method_missing(method, *args, &block)
293+
__proxy_method__(method, *args, &block)
294294
end
295295

296-
def respond_to_missing?(method, _)
297-
@__receiver__.respond_to?(method, true) || super
298-
end
299-
300-
def __proxy_method__(method, *args, **kwargs, &block)
301-
@__receiver__.__send__(method.to_sym, *args, **kwargs, &block)
302-
rescue ::NoMethodError => e
296+
def __proxy_method__(method, *args, &block)
303297
begin
304-
@__calling_context__.__send__(method.to_sym, *args, **kwargs, &block)
305-
rescue ::NoMethodError
306-
raise(e)
298+
@__receiver__.__send__(method.to_sym, *args, &block)
299+
rescue ::NoMethodError => e
300+
begin
301+
@__calling_context__.__send__(method.to_sym, *args, &block)
302+
rescue ::NoMethodError
303+
raise(e)
304+
end
307305
end
308306
end
309307
end

sunspot/spec/api/binding_spec.rb

-15
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,6 @@
3636
end
3737
end
3838
end
39-
expect(value).to eq('value')
40-
end
41-
42-
it 'should give access to calling context\'s methods with keyword arguments' do
43-
value = nil
44-
session.search(Post) do
45-
any_of do
46-
value = kwargs_method(a: 10, b: 20)
47-
end
48-
end
49-
expect(value).to eq({ a: 10, b: 20 })
5039
end
5140

5241
private
@@ -58,8 +47,4 @@ def test_method
5847
def id
5948
16
6049
end
61-
62-
def kwargs_method(a:, b:)
63-
{ a: a, b: b }
64-
end
6550
end

sunspot/spec/api/indexer/attributes_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898

9999
it 'should index latitude and longitude passed as non-Floats' do
100100
coordinates = Sunspot::Util::Coordinates.new(
101-
BigDecimal.new('40.7'), BigDecimal.new('-73.5'))
101+
BigDecimal('40.7'), BigDecimal('-73.5'))
102102
session.index(post(:coordinates => coordinates))
103103
expect(connection).to have_add_with(:coordinates_s => 'dr5xx3nytvgs')
104104
end

sunspot/spec/api/query/geo_examples.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
it 'searches for nearby points with non-Float arguments' do
1212
search do
13-
with(:coordinates).near(BigDecimal.new('40.7'), BigDecimal.new('-73.5'))
13+
with(:coordinates).near(BigDecimal('40.7'), BigDecimal('-73.5'))
1414
end
1515
expect(connection).to have_last_search_including(:q, build_geo_query)
1616
end

sunspot/spec/api/session_proxy/retry_5xx_session_proxy_spec.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ def backtrace
2525
end
2626

2727
def fake_rsolr_response(status)
28-
{:status => status.to_s}
28+
{
29+
:status => status.to_s,
30+
:body => ''
31+
}
2932
end
3033

3134
let :post do

sunspot/spec/mocks/comment.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ def custom_float
1717
long :hash
1818
double :average_rating
1919
dynamic_float :custom_float, :multiple => true
20-
boost :boost
20+
boost(:boost)
2121
end

0 commit comments

Comments
 (0)