Skip to content

Commit de1030a

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 adding GSL testing to CI 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 and installing the required `libgsl-dev` package in the Ubuntu test environment. 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 de1030a

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,42 @@ 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
4038
uses: actions/checkout@v3
39+
- name: Install GSL
40+
run: |
41+
sudo apt-get update
42+
sudo apt-get install -y libgsl-dev
4143
- name: "Set up ${{ matrix.label }}"
4244
uses: ruby/setup-ruby@v1
4345
with:
4446
ruby-version: ${{ matrix.ruby_version }}
4547
bundler-cache: true
4648
- name: Run Minitest based tests
4749
run: script/test
50+
env:
51+
NAVIVE_VECTOR: ${{ matrix.native_vector }}
52+
4853
services:
4954
redis:
5055
image: redis

test/lsi/lsi_test.rb

Lines changed: 2 additions & 2 deletions
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)