Skip to content

Commit

Permalink
Merge pull request #15 from ontoportal-lirmm/development
Browse files Browse the repository at this point in the history
Merge development & upstream  (2022-12)
  • Loading branch information
syphax-bouazzouni authored Dec 17, 2022
2 parents 738e7d7 + 41b6e62 commit 8083f4d
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 60 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/ruby-unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Ruby Unit Test

on: [push, pull_request]

permissions:
contents: read

jobs:
test:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby-version: ['2.7']

steps:
- uses: actions/checkout@v3
- name: Install Dependencies
run: sudo apt-get -y install raptor2-utils
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Start backend services via docker-compose
run: docker compose up -d
- name: Run tests
run: bundle exec rake test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3

26 changes: 15 additions & 11 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@ source 'https://rubygems.org'

gemspec

gem 'rake'
gem 'pry'
gem 'simplecov'
gem 'minitest', '< 5.0'
gem 'activesupport'
gem "activesupport"
gem "cube-ruby", require: "cube"
gem "faraday", '~> 1.9'
gem "rake"
gem "uuid"
gem 'cube-ruby', require: "cube"
gem 'faraday', '~> 1.9'

group :test do
gem "minitest", '< 5.0'
gem "pry"
gem 'simplecov'
gem 'simplecov-cobertura' # for submitting code coverage results to codecov.io
end

group :profiling do
gem 'sinatra'
gem 'rack-accept'
gem 'rack-post-body-to-params'
gem 'thin'
gem "rack-accept"
gem "rack-post-body-to-params"
gem "sinatra"
gem "thin"
end

gem 'sparql-client', github: 'ontoportal-lirmm/sparql-client', branch: 'master'
58 changes: 35 additions & 23 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ PATH
remote: .
specs:
goo (0.0.2)
addressable (= 2.3.5)
addressable (~> 2.8)
pry
rdf (= 1.0.8)
redis
rest-client
rsolr
sparql-client
systemu
uuid

GEM
Expand All @@ -31,17 +30,19 @@ GEM
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
addressable (2.3.5)
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
builder (3.2.4)
coderay (1.1.3)
concurrent-ruby (1.1.9)
concurrent-ruby (1.1.10)
connection_pool (2.3.0)
cube-ruby (0.0.3)
daemons (1.4.1)
docile (1.4.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
eventmachine (1.2.7)
faraday (1.10.0)
faraday (1.10.2)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
Expand All @@ -57,19 +58,19 @@ GEM
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-multipart (1.0.3)
multipart-post (>= 1.2, < 3)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
http-accept (1.7.0)
http-cookie (1.0.4)
http-cookie (1.0.5)
domain_name (~> 0.5)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
json_pure (2.6.1)
json_pure (2.6.2)
macaddr (1.7.2)
systemu (~> 2.6.5)
method_source (1.0.0)
Expand All @@ -78,30 +79,35 @@ GEM
mime-types-data (3.2022.0105)
minitest (4.7.5)
multi_json (1.15.0)
multipart-post (2.1.1)
mustermann (1.1.1)
multipart-post (2.2.3)
mustermann (3.0.0)
ruby2_keywords (~> 0.0.1)
net-http-persistent (2.9.4)
netrc (0.11.0)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
rack (2.2.3)
public_suffix (5.0.0)
rack (2.2.4)
rack-accept (0.4.5)
rack (>= 0.4)
rack-post-body-to-params (0.1.8)
activesupport (>= 2.3)
rack-protection (2.2.0)
rack-protection (3.0.3)
rack
rake (13.0.6)
rdf (1.0.8)
addressable (>= 2.2)
redis (4.6.0)
redis (5.0.5)
redis-client (>= 0.9.0)
redis-client (0.11.1)
connection_pool
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.5)
rsolr (2.5.0)
builder (>= 2.1.2)
faraday (>= 0.9, < 3, != 2.0.0)
Expand All @@ -110,29 +116,34 @@ GEM
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-cobertura (2.1.0)
rexml
simplecov (~> 0.19)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
sinatra (2.2.0)
mustermann (~> 1.0)
rack (~> 2.2)
rack-protection (= 2.2.0)
sinatra (3.0.3)
mustermann (~> 3.0)
rack (~> 2.2, >= 2.2.4)
rack-protection (= 3.0.3)
tilt (~> 2.0)
systemu (2.6.5)
thin (1.8.1)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
thread_safe (0.3.6)
tilt (2.0.10)
tzinfo (0.3.60)
tilt (2.0.11)
tzinfo (0.3.61)
unf (0.1.4)
unf_ext
unf_ext (0.0.8.1)
unf_ext (0.0.8.2)
uuid (2.3.9)
macaddr (~> 1.0)

PLATFORMS
x86_64-darwin-21
ruby
x86_64-darwin-16
x86_64-linux

DEPENDENCIES
activesupport
Expand All @@ -145,10 +156,11 @@ DEPENDENCIES
rack-post-body-to-params
rake
simplecov
simplecov-cobertura
sinatra
sparql-client!
thin
uuid

BUNDLED WITH
2.3.5
2.3.22
26 changes: 26 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: '3'

services:
4store:
image: bde2020/4store
ports:
- 9000:9000
command: >
bash -c "4s-backend-setup --segments 4 ontoportal_kb
&& 4s-backend ontoportal_kb
&& 4s-httpd -D -s-1 -p 9000 ontoportal_kb"
redis:
image: redis
ports:
- 6379:6379
healthcheck:
test: redis-cli ping
interval: 1s
timeout: 3s
retries: 30

solr:
image: ontoportal/solr-ut:0.1
ports:
- 8983:8983
26 changes: 12 additions & 14 deletions goo.gemspec
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
Gem::Specification.new do |s|
s.name = 'goo'
s.version = '0.0.2'
s.date = '2012-11-21'
s.summary = ""
s.name = "goo"
s.version = "0.0.2"
s.summary = "Graph Oriented Objects (GOO) for Ruby. A RDF/SPARQL based ORM."
s.authors = ["Manuel Salvadores", "Paul Alexander"]
s.email = 'manuelso@stanford.edu'
s.files = Dir['lib/**/*.rb']
s.homepage = 'http://github.com/ncbo/goo'
s.add_dependency("uuid")
s.add_dependency("systemu") # remove when https://github.com/ahoward/macaddr/pull/20 is resolved
s.add_dependency("rsolr")
s.email = "manuelso@stanford.edu"
s.files = Dir["lib/**/*.rb"]
s.homepage = "http://github.com/ncbo/goo"
s.add_dependency("addressable", "~> 2.8")
s.add_dependency("pry")
s.add_dependency("rdf", "= 1.0.8")
s.add_dependency("sparql-client")
s.add_dependency("addressable", "= 2.3.5")
s.add_dependency("rest-client")
s.add_dependency("redis")
s.add_dependency("pry")
s.add_dependency("rest-client")
s.add_dependency("rsolr")
s.add_dependency("sparql-client")
s.add_dependency("uuid")
end
2 changes: 1 addition & 1 deletion lib/goo/sparql/query_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def ids_filter(ids)
filter_id = []

ids.each do |id|
filter_id << "?id = #{id.to_ntriples.to_s}"
filter_id << "?id = #{id.to_ntriples.to_s.gsub(' ', '%20')}"
end
filter_id_str = filter_id.join ' || '
@query.filter filter_id_str
Expand Down
4 changes: 3 additions & 1 deletion lib/goo/sparql/solutions_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,9 @@ def include_embed_attributes(incl_embed, objects_new)
}.values
unless range_objs.empty?
range_objs.uniq!
attr_range.where().models(range_objs).in(@collection).include(*next_attrs).all
query = attr_range.where().models(range_objs).in(@collection).include(*next_attrs)
query = query.read_only if @read_only
query.all
end
end
end
Expand Down
20 changes: 15 additions & 5 deletions test/test_case.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Start simplecov if this is a coverage task
if ENV["COVERAGE"].eql?("true")
require 'simplecov'
# Start simplecov if this is a coverage task or if it is run in the CI pipeline
if ENV["COVERAGE"] == "true" || ENV["CI"] == "true"
require "simplecov"
require "simplecov-cobertura"
# https://github.com/codecov/ruby-standard-2
# Generate HTML and Cobertura reports which can be consumed by codecov uploader
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::CoberturaFormatter
])
SimpleCov.start do
add_filter "/test/"
add_filter "app.rb"
Expand Down Expand Up @@ -34,16 +41,19 @@ def _run_suites(suites, type)
end

def _run_suite(suite, type)
[1,5,10,200].each do |slice_size|
%[1,5,10,20]
ret = []
[1,5,10,20].each do |slice_size|
puts "\nrunning test with slice_loading_size=#{slice_size}"
Goo.slice_loading_size=slice_size
begin
suite.before_suite if suite.respond_to?(:before_suite)
super(suite, type)
ret += super(suite, type)
ensure
suite.after_suite if suite.respond_to?(:after_suite)
end
end
return ret
end
end

Expand Down
11 changes: 6 additions & 5 deletions test/test_model_complex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Submission < Goo::Base::Resource
end

class Term < Goo::Base::Resource
model :class,
model :term,
namespace: :owl,
collection: :submission,
name_with: :id,
Expand All @@ -25,22 +25,22 @@ class Term < Goo::Base::Resource
attribute :parents,
namespace: :rdfs,
property: lambda { |x| tree_property(x) },
enforce: [:list, :class]
enforce: [:list, :term]

attribute :ancestors,
namespace: :rdfs,
property: lambda { |x| tree_property(x) },
enforce: [:list, :class], transitive: true
enforce: [:list, :term], transitive: true

attribute :children,
namespace: :rdfs,
property: lambda { |x| tree_property(x) },
inverse: { on: :class , attribute: :parents }
inverse: { on: :term , attribute: :parents }

attribute :descendants,
namespace: :rdfs,
property: lambda { |x| tree_property(x) },
inverse: { on: :class , attribute: :parents },
inverse: { on: :term , attribute: :parents },
transitive: true

def self.tree_property(*args)
Expand Down Expand Up @@ -482,6 +482,7 @@ def test_empty_attributes
end

def test_aggregate
skip "Transitive closure doesn't work yet. AllegroGraph?"
submission = Submission.new(name: "submission1")
unless submission.exist?
submission.save
Expand Down

0 comments on commit 8083f4d

Please sign in to comment.