Skip to content

Commit

Permalink
Merge pull request #22 from ncbo/ruby-v3
Browse files Browse the repository at this point in the history
Ruby v3
  • Loading branch information
alexskr authored Oct 3, 2024
2 parents f92a42f + 0f10578 commit 31dafa0
Show file tree
Hide file tree
Showing 9 changed files with 242 additions and 91 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/ruby-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,25 @@ on:

jobs:
test:
strategy:
fail-fast: false
matrix:
backend: ['ruby', 'ruby-agraph'] # ruby runs tests with 4store backend and ruby-agraph runs with AllegroGraph backend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: copy config file
run: cp config/config.test.rb config/config.rb
- uses: actions/checkout@v4
- name: copy config.rb file from template
run: cp config/config.test.rb config/config.rb
- name: Build docker compose
run: docker compose build
- name: Run unit tests
# unit tests are run inside a container
# http://docs.codecov.io/docs/testing-with-docker
run: |
ci_env=`bash <(curl -s https://codecov.io/env)`
docker compose run $ci_env -e CI --rm ruby bundle exec rake test TESTOPTS='-v'
docker compose run $ci_env -e CI --rm ${{ matrix.backend }} bundle exec rake test TESTOPTS='-v'
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
verbose: true
fail_ci_if_error: false # optional (default = false)
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0.6
20 changes: 11 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG RUBY_VERSION
ARG RUBY_VERSION=3.0
ARG DISTRO_NAME=bullseye

FROM ruby:$RUBY_VERSION-$DISTRO_NAME
Expand All @@ -8,14 +8,16 @@ RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \
raptor2-utils \
&& rm -rf /var/lib/apt/lists/*

# The Gemfile Caching Trick
RUN mkdir -p /srv/ontoportal/ncbo_ontology_recommender
COPY *.gemspec Gemfile* /srv/ontoportal/ncbo_ontology_recommender/
ENV BUNDLE_PATH=/usr/local/bundle \
BUNDLE_BIN=/usr/local/bundle/bin \
BUNDLE_APP_CONFIG=/usr/local/bundle/config

WORKDIR /srv/ontoportal/ncbo_ontology_recommender
WORKDIR /usr/src/app

RUN gem install bundler
ENV BUNDLE_PATH /bundle
COPY Gemfile* *.gemspec ./

RUN gem update --system
RUN bundle install
COPY . /srv/ontoportal/ncbo_ontology_recommender
CMD ["/bin/bash"]

COPY . .
CMD ["irb"]
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source 'https://rubygems.org'

gem 'cube-ruby'
gem 'faraday', '~> 2.0'
gem 'faraday'
gem 'ffi'
gem 'oj', '~> 3.0'
gem 'rake', '~> 10.0'
Expand Down
74 changes: 37 additions & 37 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/ncbo/goo.git
revision: 33583fd1c1d72b449cd6bb91815e3422b8448983
revision: 74a012eebb9433d031eb00df5abbe488cb8b4512
branch: develop
specs:
goo (0.0.2)
Expand All @@ -16,7 +16,7 @@ GIT

GIT
remote: https://github.com/ncbo/ncbo_annotator.git
revision: f9a1be204e81d72f408927b8f60c0be208611929
revision: b2731c98bfef0958fecb440c8648b7755a670895
branch: develop
specs:
ncbo_annotator (0.0.1)
Expand All @@ -27,7 +27,7 @@ GIT

GIT
remote: https://github.com/ncbo/ontologies_linked_data.git
revision: da1642ed8f9f04db2e427e35d88f235a55138d03
revision: 812dd78f02b77c9c6d579b0febf1c2a42d513022
branch: develop
specs:
ontologies_linked_data (0.0.1)
Expand Down Expand Up @@ -64,34 +64,34 @@ GEM
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
base64 (0.2.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
bcrypt (3.1.20)
bigdecimal (3.1.7)
builder (3.2.4)
bigdecimal (3.1.8)
builder (3.3.0)
coderay (1.1.3)
concurrent-ruby (1.2.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
cube-ruby (0.0.3)
date (3.3.4)
docile (1.4.0)
docile (1.4.1)
domain_name (0.6.20240107)
faraday (2.8.1)
base64
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2)
ffi (1.16.3)
faraday (2.12.0)
faraday-net_http (>= 2.0, < 3.4)
json
logger
faraday-net_http (3.3.0)
net-http
ffi (1.17.0-aarch64-linux-gnu)
http-accept (1.7.0)
http-cookie (1.0.5)
http-cookie (1.0.7)
domain_name (~> 0.5)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
json (2.7.2)
json_pure (2.7.2)
libxml-ruby (5.0.3)
logger (1.6.0)
logger (1.6.1)
macaddr (1.7.2)
systemu (~> 2.6.5)
mail (2.8.1)
Expand All @@ -100,14 +100,17 @@ GEM
net-pop
net-smtp
method_source (1.1.0)
mime-types (3.5.2)
mime-types (3.6.0)
logger
mime-types-data (~> 3.2015)
mime-types-data (3.2024.0305)
mime-types-data (3.2024.1001)
mini_mime (1.1.5)
minitest (4.7.5)
multi_json (1.15.0)
net-http (0.4.1)
uri
net-http-persistent (2.9.4)
net-imap (0.4.10)
net-imap (0.4.16)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -117,39 +120,40 @@ GEM
net-smtp (0.5.0)
net-protocol
netrc (0.11.0)
oj (3.16.3)
oj (3.16.6)
bigdecimal (>= 3.0)
ostruct (>= 0.2)
omni_logger (0.1.4)
logger
ostruct (0.6.0)
pony (1.13.1)
mail (>= 2.0)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (5.0.5)
rack (3.0.10)
public_suffix (6.0.1)
rack (3.1.7)
rack-test (2.1.0)
rack (>= 1.3)
rake (10.5.0)
rdf (1.0.8)
addressable (>= 2.2)
redis (5.2.0)
redis (5.3.0)
redis-client (>= 0.22.0)
redis-client (0.22.1)
redis-client (0.22.2)
connection_pool
request_store (1.6.0)
request_store (1.7.0)
rack (>= 1.4)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.2.6)
rexml (3.3.8)
rsolr (2.6.0)
builder (>= 2.1.2)
faraday (>= 0.9, < 3, != 2.0.0)
ruby-xxHash (0.4.0.2)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
simplecov (0.22.0)
docile (~> 1.1)
Expand All @@ -158,26 +162,22 @@ GEM
simplecov-cobertura (2.1.0)
rexml
simplecov (~> 0.19)
simplecov-html (0.12.3)
simplecov-html (0.13.1)
simplecov_json_formatter (0.1.4)
systemu (2.6.5)
thread_safe (0.3.6)
timeout (0.4.1)
tzinfo (0.3.62)
uri (0.13.1)
uuid (2.3.9)
macaddr (~> 1.0)

PLATFORMS
aarch64-linux
arm64-darwin-22
ruby
x86_64-darwin-18
x86_64-darwin-21
x86_64-linux

DEPENDENCIES
cube-ruby
faraday (~> 2.0)
faraday
ffi
goo!
minitest (~> 4.0)
Expand All @@ -192,4 +192,4 @@ DEPENDENCIES
sparql-client!

BUNDLED WITH
2.4.22
2.5.21
37 changes: 25 additions & 12 deletions config/config.test.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
# frozen_string_literal: true

#
# This file is designed for used for unit testing
#
# All the defaults are set in
# https://github.com/ncbo/ontologies_linked_data/blob/master/lib/ontologies_linked_data/config/config.rb
###
GOO_HOST = ENV.include?('GOO_HOST') ? ENV['GOO_HOST'] : 'localhost'
GOO_PORT = ENV.include?('GOO_PORT') ? ENV['GOO_PORT'] : 9000
REDIS_HOST = ENV.include?('REDIS_HOST') ? ENV['REDIS_HOST'] : 'localhost'
REDIS_PORT = ENV.include?('REDIS_PORT') ? ENV['REDIS_PORT'] : 6379
SOLR_HOST = ENV.include?('SOLR_HOST') ? ENV['SOLR_HOST'] : 'localhost'
MGREP_HOST = ENV.include?('MGREP_HOST') ? ENV['MGREP_HOST'] : 'localhost'
MGREP_PORT = ENV.include?('MGREP_PORT') ? ENV['MGREP_PORT'] : 55555
GOO_BACKEND_NAME = ENV.include?("GOO_BACKEND_NAME") ? ENV["GOO_BACKEND_NAME"] : "4store"
GOO_PATH_QUERY = ENV.include?("GOO_PATH_QUERY") ? ENV["GOO_PATH_QUERY"] : "/sparql/"
GOO_PATH_DATA = ENV.include?("GOO_PATH_DATA") ? ENV["GOO_PATH_DATA"] : "/data/"
GOO_PATH_UPDATE = ENV.include?("GOO_PATH_UPDATE") ? ENV["GOO_PATH_UPDATE"] : "/update/"
GOO_PORT = ENV.include?("GOO_PORT") ? ENV["GOO_PORT"] : 9000
GOO_HOST = ENV.include?("GOO_HOST") ? ENV["GOO_HOST"] : "localhost"
REDIS_HOST = ENV.include?("REDIS_HOST") ? ENV["REDIS_HOST"] : "localhost"
REDIS_PORT = ENV.include?("REDIS_PORT") ? ENV["REDIS_PORT"] : 6379
MGREP_HOST = ENV.include?('MGREP_HOST') ? ENV['MGREP_HOST'] : 'localhost'
MGREP_PORT = ENV.include?('MGREP_PORT') ? ENV['MGREP_PORT'] : 55556
SOLR_TERM_SEARCH_URL = ENV.include?("SOLR_TERM_SEARCH_URL") ? ENV["SOLR_TERM_SEARCH_URL"] : "http://localhost:8983/solr/term_search_core1"
SOLR_PROP_SEARCH_URL = ENV.include?("SOLR_PROP_SEARCH_URL") ? ENV["SOLR_PROP_SEARCH_URL"] : "http://localhost:8983/solr/prop_search_core1"

LinkedData.config do |config|
config.goo_host = GOO_HOST.to_s
config.goo_port = GOO_PORT.to_i
config.goo_backend_name = GOO_BACKEND_NAME.to_s
config.goo_host = GOO_HOST.to_s
config.goo_port = GOO_PORT.to_i
config.goo_path_query = GOO_PATH_QUERY.to_s
config.goo_path_data = GOO_PATH_DATA.to_s
config.goo_path_update = GOO_PATH_UPDATE.to_s
config.goo_redis_host = REDIS_HOST.to_s
config.goo_redis_port = REDIS_PORT.to_i
config.http_redis_host = REDIS_HOST.to_s
config.http_redis_port = REDIS_PORT.to_i
config.ontology_analytics_redis_host = REDIS_HOST.to_s
config.ontology_analytics_redis_port = REDIS_PORT.to_i
config.search_server_url = "http://#{SOLR_HOST}:8983/solr/term_search_core1".to_s
config.property_search_server_url = "http://#{SOLR_HOST}:8983/solr/prop_search_core1".to_s
config.search_server_url = SOLR_TERM_SEARCH_URL.to_s
config.property_search_server_url = SOLR_PROP_SEARCH_URL.to_s
end

Annotator.config do |config|
config.mgrep_host = MGREP_HOST.to_s
config.mgrep_port = MGREP_PORT.to_i
Expand Down
55 changes: 55 additions & 0 deletions dip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
version: '7.1'

# Define default environment variables to pass
# to Docker Compose
#environment:
# RAILS_ENV: development

compose:
files:
- docker-compose.yml

interaction:
# This command spins up a ontologies_api container with the required dependencies (solr, 4store, etc),
# and opens a terminal within it.
runner:
description: Open a Bash shell within a ontologies_api container (with dependencies up)
service: ruby
command: /bin/bash

# Run a Rails container without any dependent services (useful for non-Rails scripts)
bash:
description: Run an arbitrary script within a container (or open a shell without deps)
service: ruby
command: /bin/bash
compose_run_options: [ no-deps ]

# A shortcut to run Bundler commands
bundle:
description: Run Bundler commands
service: ruby
command: bundle
compose_run_options: [ no-deps ]

# A shortcut to run unit tests
test:
description: Run minitest unit tests
service: ruby
command: bundle exec rake test

test-ag:
description: Run minitest unit tests
service: ruby-ag
command: bundle exec rake test


'redis-cli':
description: Run Redis console
service: redis-ut
command: redis-cli -h redis-ut

#provision:
#- dip compose down --volumes
#- dip compose up -d solr 4store
#- dip bundle install
#- dip bash -c bin/setup
Loading

0 comments on commit 31dafa0

Please sign in to comment.