Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actually Use GSL in CI Tests #197

Merged
merged 1 commit into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Actually Use GSL in CI Tests
In #196, I attempted to make the CI tests execute both with and without
GSL support because classifier-reborn is supposed to work in both cases
(though GSL increases performance). However, while doing so, I missed
the fact that `script/test` (which our CI job runs) uses `bundle exec`
to run the tests. And when the tests are run with `bundle exec`, Bundler
will not load gems that aren't specified in the Gemfile. So our GSL
tests weren't actually using the GSL gem.

To fix this, we add `gem 'gsl' if ENV["LOAD_GSL"]` to our Gemfile. (This
solution was proposed by ashmaroli.) This won't do anything in most
cases (when `LOAD_GSL` isn't set). But when we set it (in our CI env),
it will include GSL in our bundled gems so that we can actually test
with GSL support in CI.

See here for more info:
#196 (comment)
  • Loading branch information
mkasberg committed May 23, 2022
commit cef0e638d6257adef1650c0a29bfd6b560cc08ec
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
env:
# See https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby#matrix-of-gemfiles
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
LOAD_GSL: ${{ matrix.gsl }}
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -54,9 +55,6 @@ jobs:
with:
ruby-version: ${{ matrix.ruby_version }}
bundler-cache: true
- name: Install GSL Gem
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer necessary - bundle install will install this gem now.

if: ${{ matrix.gsl }}
run: gem install gsl
- name: Run Minitest based tests
run: script/test

Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

source 'https://rubygems.org'
gemspec name: 'classifier-reborn'

# For testing with GSL support & bundle exec
gem 'gsl' if ENV['LOAD_GSL'] == 'true'
2 changes: 2 additions & 0 deletions test/extensions/matrix_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

class MatrixTest < Minitest::Test
def test_zero_division
skip "extensions/vector is only used by non-GSL implementation" if $GSL

matrix = Matrix[[1, 0], [0, 1]]
matrix.SV_decomp
end
Expand Down
2 changes: 2 additions & 0 deletions test/extensions/zero_vector_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

class ZeroVectorTest < Minitest::Test
def test_zero?
skip "extensions/zero_vector is only used by non-GSL implementation" if $GSL

vec0 = Vector[]
vec1 = Vector[0]
vec10 = Vector.elements [0] * 10
Expand Down