Skip to content

Commit fd20ebf

Browse files
committed
Test Native and GSL Implementations
classifier-reborn is designed to work with or without [GSL](https://www.gnu.org/software/gsl/) support. https://github.com/jekyll/classifier-reborn/blob/99d13af5adf040ba40a6fe77dbe0b28756562fcc/docs/index.md?plain=1#L68 If GSL is installed, classifier-reborn will detect it and use it. If GSL is not installed, classifier-reborn will fall back to a pure-ruby implementation. The mechanism for doing so is in `lsi.rb`: https://github.com/jekyll/classifier-reborn/blob/99d13af5adf040ba40a6fe77dbe0b28756562fcc/lib/classifier-reborn/lsi.rb#L7-L17 Notably, there's a comment there about how to test with/without GSL enabled. > to test the native vector class, try `rake test NATIVE_VECTOR=true` As far as I can tell, this was only ever used for local development/testing, and was never tested in CI (though it was previously discussed [here](jekyll#46 (comment))). I did not include this in my last PR (jekyll#195) because I was focused on porting existing testing functionality from TravisCI to GitHub Actions. Now that GitHub Actions is working, I think it's important to expand our CI coverage to test with and without GSL in CI. So, in this PR, I'm doing so by setting `NATIVE_VECTOR` to true or false in our test matrix. Lucky for us, GitHub already [includes libgsl as pre-installed software](https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md#installed-apt-packages), so we don't need to do anything special there. While working on this, I noticed some tests in the LSI spec that return early when `$GSL` is not enabled. It would be better for those tests to report as skipped when GSL is not enabled (and this matches the pattern of the redis tests, that report as skipped if redis isn't available).
1 parent 99d13af commit fd20ebf

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

.github/workflows/ci.yml

+13-9
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,24 @@ on:
1414

1515
jobs:
1616
ci:
17-
name: "Run Tests (${{ matrix.label }})"
17+
name: "Run Tests (Ruby ${{ matrix.ruby_version }}, native_vector: ${{ matrix.native_vector }})"
1818
runs-on: "ubuntu-latest"
1919
env:
2020
# See https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby#matrix-of-gemfiles
2121
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
2222
strategy:
2323
fail-fast: false
2424
matrix:
25+
ruby_version: ["2.7", "3.0", "3.1", "jruby-9.3.4.0"]
26+
native_vector: [true, false]
2527
include:
26-
- label: Ruby 2.7
27-
ruby_version: "2.7"
28+
- ruby_version: "2.7"
2829
gemfile: Gemfile
29-
- label: Ruby 3.0
30-
ruby_version: "3.0"
30+
- ruby_version: "3.0"
3131
gemfile: Gemfile
32-
- label: Ruby 3.1
33-
ruby_version: "3.1"
32+
- ruby_version: "3.1"
3433
gemfile: Gemfile
35-
- label: JRuby 9.3.4.0
36-
ruby_version: "jruby-9.3.4.0"
34+
- ruby_version: "jruby-9.3.4.0"
3735
gemfile: Gemfile-jruby
3836
steps:
3937
- name: Checkout Repository
@@ -43,8 +41,14 @@ jobs:
4341
with:
4442
ruby-version: ${{ matrix.ruby_version }}
4543
bundler-cache: true
44+
- name: Install GSL Gem
45+
if: ${{ !matrix.native_vector }}
46+
run: gem install rb-gsl
4647
- name: Run Minitest based tests
4748
run: script/test
49+
env:
50+
NAVIVE_VECTOR: ${{ matrix.native_vector }}
51+
4852
services:
4953
redis:
5054
image: redis

test/lsi/lsi_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def test_cached_content_node_option
163163
end
164164

165165
def test_clears_cached_content_node_cache
166-
return unless $GSL
166+
skip "transposed_search_vector is only used by GSL implementation" unless $GSL
167167

168168
lsi = ClassifierReborn::LSI.new(cache_node_vectors: true)
169169
lsi.add_item @str1, 'Dog'
@@ -192,7 +192,7 @@ def test_keyword_search
192192
end
193193

194194
def test_invalid_searching_when_using_gsl
195-
return unless $GSL
195+
skip "Only GSL currently raises invalid search error" unless $GSL
196196

197197
lsi = ClassifierReborn::LSI.new
198198
lsi.add_item @str1, 'Dog'

0 commit comments

Comments
 (0)