Skip to content
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
30 changes: 0 additions & 30 deletions .github/workflows/ruby-unit-tests.yml

This file was deleted.

87 changes: 87 additions & 0 deletions .github/workflows/testkit-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Docker Unit Tests

on:
push:
branches:
- '**'
tags-ignore:
- '**'
pull_request:

env:
# CI execution mode for backend tests:
# - container: run `test:docker:<backend>:container` (default)
# - native: run `test:docker:<backend>` on host Ruby
OPTK_CI_RUN_MODE: ${{ vars.OPTK_CI_RUN_MODE || 'container' }}
# Example override to force native mode in this workflow file:
# OPTK_CI_RUN_MODE: native

jobs:
prepare:
runs-on: ubuntu-latest
outputs:
backends: ${{ steps.cfg.outputs.backends }}
steps:
- uses: actions/checkout@v4

- id: cfg
name: Read backend matrix from .ontoportal-testkit.yml
run: |
BACKENDS=$(ruby -ryaml -rjson -e 'c=YAML.safe_load_file(".ontoportal-testkit.yml") || {}; b=c["backends"] || %w[fs ag vo gd]; puts JSON.generate(b)')
echo "backends=$BACKENDS" >> "$GITHUB_OUTPUT"

test:
needs: prepare
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
backend: ${{ fromJson(needs.prepare.outputs.backends) }}

steps:
- uses: actions/checkout@v4

- name: Set up Ruby from .ruby-version
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true

- name: Set up Java 11 (native mode)
if: env.OPTK_CI_RUN_MODE == 'native'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '11'

- name: Install native system dependencies
if: env.OPTK_CI_RUN_MODE == 'native'
run: |
sudo apt-get update
sudo apt-get install -y raptor2-utils

- name: Run unit tests
env:
CI: "true"
TESTOPTS: "--verbose"
BACKEND: ${{ matrix.backend }}
run: |
MODE="${OPTK_CI_RUN_MODE:-container}"
TASK="test:docker:${BACKEND}"
if [ "$MODE" = "container" ]; then
TASK="${TASK}:container"
elif [ "$MODE" != "native" ]; then
echo "Invalid OPTK_CI_RUN_MODE=$MODE (expected container or native)"
exit 1
fi

bundle exec rake "$TASK"

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests,${{ matrix.backend }}
verbose: true
fail_ci_if_error: false
9 changes: 9 additions & 0 deletions .ontoportal-testkit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
component_name: ontologies_api
app_service: test-container
backends:
- fs
- ag
- vo
- gd
dependency_services:
- mgrep
30 changes: 13 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
ARG RUBY_VERSION=3.1
ARG DISTRO_NAME=bullseye
ARG RUBY_VERSION=3.2
ARG DISTRO=bullseye
ARG TESTKIT_BASE_IMAGE=ontoportal/testkit-base:ruby${RUBY_VERSION}-${DISTRO}
FROM ${TESTKIT_BASE_IMAGE}

FROM ruby:$RUBY_VERSION-$DISTRO_NAME
WORKDIR /app

RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \
openjdk-11-jre-headless \
raptor2-utils \
&& rm -rf /var/lib/apt/lists/*
COPY Gemfile* *.gemspec ./

RUN mkdir -p /srv/ontoportal/ontologies_api
RUN mkdir -p /srv/ontoportal/bundle
COPY Gemfile* /srv/ontoportal/ontologies_api/
# Respect the project's Bundler lock when present.
RUN if [ -f Gemfile.lock ]; then \
BUNDLER_VERSION=$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1 | tr -d ' '); \
gem install bundler -v "$BUNDLER_VERSION"; \
fi

WORKDIR /srv/ontoportal/ontologies_api
RUN bundle install --jobs 4 --retry 3

ENV BUNDLE_PATH=/srv/ontoportal/bundle
RUN bundle install
COPY . ./

COPY . /srv/ontoportal/ontologies_api
RUN cp /srv/ontoportal/ontologies_api/config/environments/config.rb.sample /srv/ontoportal/ontologies_api/config/environments/development.rb

EXPOSE 9393
CMD ["bundle", "exec", "rackup", "-p", "9393", "--host", "0.0.0.0"]
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ group :test do
gem 'crack', '0.4.5'
gem 'minitest'
gem 'minitest-hooks'
gem 'minitest-stub_any_instance'
gem 'minitest-reporters'
gem 'minitest-stub_any_instance'
gem 'ontoportal_testkit', github: 'alexskr/ontoportal_testkit', branch: 'main'
gem 'rack-test'
gem 'simplecov', require: false
gem 'simplecov-cobertura' # for codecov.io
Expand Down
37 changes: 10 additions & 27 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
GIT
remote: https://github.com/alexskr/ontoportal_testkit.git
revision: 9944d1d5f57b11e8ae9ccda11a83c7c5b2348870
branch: main
specs:
ontoportal_testkit (0.1.0)
rake (>= 13.0)

GIT
remote: https://github.com/ncbo/goo.git
revision: 93c8ade0f7ef56fa4ad4fbdee0f9c6c4553be287
Expand Down Expand Up @@ -183,15 +191,9 @@ GEM
faraday (~> 2.0)
ffi (1.17.3)
ffi (1.17.3-aarch64-linux-gnu)
ffi (1.17.3-aarch64-linux-musl)
ffi (1.17.3-arm-linux-gnu)
ffi (1.17.3-arm-linux-musl)
ffi (1.17.3-arm64-darwin)
ffi (1.17.3-x86-linux-gnu)
ffi (1.17.3-x86-linux-musl)
ffi (1.17.3-x86_64-darwin)
ffi (1.17.3-x86_64-linux-gnu)
ffi (1.17.3-x86_64-linux-musl)
fugit (1.12.1)
et-orbi (~> 1.4)
raabro (~> 1.4)
Expand Down Expand Up @@ -224,7 +226,6 @@ GEM
google-protobuf (3.25.3)
google-protobuf (3.25.3-aarch64-linux)
google-protobuf (3.25.3-arm64-darwin)
google-protobuf (3.25.3-x86-linux)
google-protobuf (3.25.3-x86_64-darwin)
google-protobuf (3.25.3-x86_64-linux)
googleapis-common-protos (1.8.0)
Expand All @@ -250,9 +251,6 @@ GEM
grpc (1.70.1-arm64-darwin)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
grpc (1.70.1-x86-linux)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
grpc (1.70.1-x86_64-darwin)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
Expand Down Expand Up @@ -515,20 +513,11 @@ GEM
webrick (1.9.2)

PLATFORMS
aarch64-linux
aarch64-linux-gnu
aarch64-linux-musl
arm-linux-gnu
arm-linux-musl
arm64-darwin
ruby
x86-linux
x86-linux-gnu
x86-linux-musl
x86_64-darwin
x86_64-linux
x86_64-linux-gnu
x86_64-linux-musl

DEPENDENCIES
activesupport
Expand Down Expand Up @@ -559,6 +548,7 @@ DEPENDENCIES
net-ftp
oj
ontologies_linked_data!
ontoportal_testkit!
pandoc-ruby
parallel
parseconfig
Expand Down Expand Up @@ -629,15 +619,9 @@ CHECKSUMS
faraday-retry (2.4.0) sha256=7b79c48fb7e56526faf247b12d94a680071ff40c9fda7cf1ec1549439ad11ebe
ffi (1.17.3) sha256=0e9f39f7bb3934f77ad6feab49662be77e87eedcdeb2a3f5c0234c2938563d4c
ffi (1.17.3-aarch64-linux-gnu) sha256=28ad573df26560f0aedd8a90c3371279a0b2bd0b4e834b16a2baa10bd7a97068
ffi (1.17.3-aarch64-linux-musl) sha256=020b33b76775b1abacc3b7d86b287cef3251f66d747092deec592c7f5df764b2
ffi (1.17.3-arm-linux-gnu) sha256=5bd4cea83b68b5ec0037f99c57d5ce2dd5aa438f35decc5ef68a7d085c785668
ffi (1.17.3-arm-linux-musl) sha256=0d7626bb96265f9af78afa33e267d71cfef9d9a8eb8f5525344f8da6c7d76053
ffi (1.17.3-arm64-darwin) sha256=0c690555d4cee17a7f07c04d59df39b2fba74ec440b19da1f685c6579bb0717f
ffi (1.17.3-x86-linux-gnu) sha256=868a88fcaf5186c3a46b7c7c2b2c34550e1e61a405670ab23f5b6c9971529089
ffi (1.17.3-x86-linux-musl) sha256=f0286aa6ef40605cf586e61406c446de34397b85dbb08cc99fdaddaef8343945
ffi (1.17.3-x86_64-darwin) sha256=1f211811eb5cfaa25998322cdd92ab104bfbd26d1c4c08471599c511f2c00bb5
ffi (1.17.3-x86_64-linux-gnu) sha256=3746b01f677aae7b16dc1acb7cb3cc17b3e35bdae7676a3f568153fb0e2c887f
ffi (1.17.3-x86_64-linux-musl) sha256=086b221c3a68320b7564066f46fed23449a44f7a1935f1fe5a245bd89d9aea56
fugit (1.12.1) sha256=5898f478ede9b415f0804e42b8f3fd53f814bd85eebffceebdbc34e1107aaf68
gapic-common (1.1.0) sha256=3270ab3c5135012a4ab4d8848f945cf35014192f24504cdb40c66fc67f1beaa3
get_process_mem (0.2.7) sha256=4afd3c3641dd6a817c09806c7d6d509d8a9984512ac38dea8b917426bbf77eba
Expand All @@ -651,7 +635,6 @@ CHECKSUMS
google-protobuf (3.25.3) sha256=39bd97cbc7631905e76cdf8f1bf3dda1c3d05200d7e23f575aced78930fbddd6
google-protobuf (3.25.3-aarch64-linux) sha256=5ea9d20d60e5d3bef8d881b426946345e5ac6cf4779ac81cd900e45f40567243
google-protobuf (3.25.3-arm64-darwin) sha256=c42cddd21c4f09fd756fe0efd70ab6c8006dd67ffbb04e99fe7310f49923d18c
google-protobuf (3.25.3-x86-linux) sha256=7a0e74f14affbce6024595cdb55e7e8c5a51716f0bb11b103c63cbe3a3a0e348
google-protobuf (3.25.3-x86_64-darwin) sha256=13d27e96e89835f642c444e32414fd50fabc29a125d78760ad067d6536214f02
google-protobuf (3.25.3-x86_64-linux) sha256=ceeba879d9313a2bd0600a97d6fe3cf529a9b37d12ca026f891996c118b7ffb2
googleapis-common-protos (1.8.0) sha256=bfe89cb75d1a8f13e4591d262a20333e145481d803adb74dd13ac0517decdffe
Expand All @@ -660,7 +643,6 @@ CHECKSUMS
grpc (1.70.1) sha256=174594605c96df3caed44a83221665aa6e11f554e56028f89bef82c07ffb83cb
grpc (1.70.1-aarch64-linux) sha256=48e0b22b8b96e61ca7054a7fea894a4845498e6bf366b50eff03e588f714ed96
grpc (1.70.1-arm64-darwin) sha256=eeb6758dd58135e4e5fcd78726b9a18d34d7313e41bc81528ff4b3dce65cf525
grpc (1.70.1-x86-linux) sha256=cb7921614fec4f90f888637736b7ede85305ad94a869f736176f9ebede98c4f1
grpc (1.70.1-x86_64-darwin) sha256=628cb929542c277b6e5f638b6b8575b3bdcde250a2a70bddf8c0be1bf77e6781
grpc (1.70.1-x86_64-linux) sha256=ed12eea749127119c9761a58ba17ce92aadbc35b0b4fa27e4bd8ec84047d63be
haml (5.2.2) sha256=6e759246556145642ef832d670fc06f9bd8539159a0e600847a00291dd7aae0c
Expand Down Expand Up @@ -712,6 +694,7 @@ CHECKSUMS
oj (3.16.15) sha256=4d3324cac3e8fef54c0fa250b2af26a16dadd9f9788a1d6b1b2098b793a1b2cd
omni_logger (0.1.4) sha256=b61596f7d96aa8426929e46c3500558d33e838e1afd7f4735244feb4d082bb3e
ontologies_linked_data (0.0.1)
ontoportal_testkit (0.1.0)
os (1.1.4) sha256=57816d6a334e7bd6aed048f4b0308226c5fb027433b67d90a9ab435f35108d3f
ostruct (0.6.3) sha256=95a2ed4a4bd1d190784e666b47b2d3f078e4a9efda2fccf18f84ddc6538ed912
pandoc-ruby (2.1.10) sha256=37653d6b5e71657fb25b3cb230e6eebbfb8c925c7f1fcf69dfb6b929d12b74b2
Expand Down
56 changes: 19 additions & 37 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
# conig file for unit tests

# GOO_BACKEND_NAME = ENV.include?("GOO_BACKEND_NAME") ? ENV["GOO_BACKEND_NAME"] : "AG"
# GOO_HOST = ENV.include?("GOO_HOST") ? ENV["GOO_HOST"] : "localhost"
# GOO_PATH_QUERY = ENV.include?("GOO_PATH_QUERY") ? ENV["GOO_PATH_QUERY"] : "/repositories/bioportal"
# GOO_PATH_DATA = ENV.include?("GOO_PATH_DATA") ? ENV["GOO_PATH_DATA"] : "/repositories/bioportal/statements"
# GOO_PATH_UPDATE = ENV.include?("GOO_PATH_UPDATE") ? ENV["GOO_PATH_UPDATE"] : "/repositories/bioportal/statements"
# GOO_PORT = ENV.include?("GOO_PORT") ? ENV["GOO_PORT"] : 10035

GOO_BACKEND_NAME = ENV.include?("GOO_BACKEND_NAME") ? ENV["GOO_BACKEND_NAME"] : "4store"
GOO_HOST = ENV.include?("GOO_HOST") ? ENV["GOO_HOST"] : "localhost"
GOO_PATH_DATA = ENV.include?("GOO_PATH_DATA") ? ENV["GOO_PATH_DATA"] : "/data/"
GOO_PATH_QUERY = ENV.include?("GOO_PATH_QUERY") ? ENV["GOO_PATH_QUERY"] : "/sparql/"
GOO_PATH_UPDATE = ENV.include?("GOO_PATH_UPDATE") ? ENV["GOO_PATH_UPDATE"] : "/update/"
GOO_PORT = ENV.include?("GOO_PORT") ? ENV["GOO_PORT"] : 9000

MGREP_DICTIONARY_FILE = ENV.include?("MGREP_DICTIONARY_FILE") ? ENV["MGREP_DICTIONARY_FILE"] : "./test/data/dictionary.txt"
MGREP_HOST = ENV.include?("MGREP_HOST") ? ENV["MGREP_HOST"] : "localhost"
MGREP_PORT = ENV.include?("MGREP_PORT") ? ENV["MGREP_PORT"] : 55555

REDIS_GOO_CACHE_HOST = ENV.include?("REDIS_GOO_CACHE_HOST") ? ENV["REDIS_GOO_CACHE_HOST"] : "localhost"
REDIS_HTTP_CACHE_HOST = ENV.include?("REDIS_HTTP_CACHE_HOST") ? ENV["REDIS_HTTP_CACHE_HOST"] : "localhost"
REDIS_PERSISTENT_HOST = ENV.include?("REDIS_PERSISTENT_HOST") ? ENV["REDIS_PERSISTENT_HOST"] : "localhost"
REDIS_PORT = ENV.include?("REDIS_PORT") ? ENV["REDIS_PORT"] : 6379
REPORT_PATH = ENV.include?("REPORT_PATH") ? ENV["REPORT_PATH"] : "./test/ontologies_report.json"
REPOSITORY_FOLDER = ENV.include?("REPOSITORY_FOLDER") ? ENV["REPOSITORY_FOLDER"] : "./test/data/ontology_files/repo"
SOLR_PROP_SEARCH_URL = ENV.include?("SOLR_PROP_SEARCH_URL") ? ENV["SOLR_PROP_SEARCH_URL"] : "http://localhost:8983/solr"
SOLR_TERM_SEARCH_URL = ENV.include?("SOLR_TERM_SEARCH_URL") ? ENV["SOLR_TERM_SEARCH_URL"] : "http://localhost:8983/solr"
GOO_BACKEND_NAME = ENV.include?("GOO_BACKEND_NAME") ? ENV["GOO_BACKEND_NAME"] : "4store"
GOO_HOST = ENV.include?("GOO_HOST") ? ENV["GOO_HOST"] : "localhost"
GOO_PATH_DATA = ENV.include?("GOO_PATH_DATA") ? ENV["GOO_PATH_DATA"] : "/data/"
GOO_PATH_QUERY = ENV.include?("GOO_PATH_QUERY") ? ENV["GOO_PATH_QUERY"] : "/sparql/"
GOO_PATH_UPDATE = ENV.include?("GOO_PATH_UPDATE") ? ENV["GOO_PATH_UPDATE"] : "/update/"
GOO_PORT = ENV.include?("GOO_PORT") ? ENV["GOO_PORT"] : 9000
MGREP_HOST = ENV.include?("MGREP_HOST") ? ENV["MGREP_HOST"] : "localhost"
MGREP_PORT = ENV.include?("MGREP_PORT") ? ENV["MGREP_PORT"] : 55556
REDIS_HOST = ENV.include?("REDIS_HOST") ? ENV["REDIS_HOST"] : "localhost"
REDIS_PORT = ENV.include?("REDIS_PORT") ? ENV["REDIS_PORT"] : 6379
SEARCH_SERVER_URL = ENV.include?('SEARCH_SERVER_URL') ? ENV['SEARCH_SERVER_URL'] : 'http://localhost:8983/solr'

LinkedData.config do |config|
config.goo_backend_name = GOO_BACKEND_NAME.to_s
Expand All @@ -34,16 +19,15 @@
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_GOO_CACHE_HOST.to_s
config.goo_redis_host = REDIS_HOST.to_s
config.goo_redis_port = REDIS_PORT.to_i
config.http_redis_host = REDIS_HTTP_CACHE_HOST.to_s
config.http_redis_host = REDIS_HOST.to_s
config.http_redis_port = REDIS_PORT.to_i
config.search_server_url = SOLR_TERM_SEARCH_URL.to_s
config.property_search_server_url = SOLR_PROP_SEARCH_URL.to_s
#config.enable_notifications = false
config.search_server_url = SEARCH_SERVER_URL.to_s
config.property_search_server_url = SEARCH_SERVER_URL.to_s

# Ontology analytics
config.ontology_analytics_redis_host = REDIS_PERSISTENT_HOST.to_s
config.ontology_analytics_redis_host = REDIS_HOST.to_s
config.ontology_analytics_redis_port = REDIS_PORT.to_i
config.ontology_analytics_redis_field = 'test_analytics'
config.oauth_providers = {
Expand All @@ -67,20 +51,18 @@
end

Annotator.config do |config|
config.annotator_redis_host = REDIS_PERSISTENT_HOST.to_s
config.annotator_redis_host = REDIS_HOST.to_s
config.annotator_redis_port = REDIS_PORT.to_i
config.mgrep_host = MGREP_HOST.to_s
config.mgrep_port = MGREP_PORT.to_i
config.mgrep_dictionary_file = MGREP_DICTIONARY_FILE.to_s
end

LinkedData::OntologiesAPI.config do |config|
config.http_redis_host = REDIS_HTTP_CACHE_HOST.to_s
config.http_redis_host = REDIS_HOST.to_s
config.http_redis_port = REDIS_PORT.to_i
end

NcboCron.config do |config|
config.redis_host = REDIS_PERSISTENT_HOST.to_s
config.redis_host = REDIS_HOST.to_s
config.redis_port = REDIS_PORT.to_i
# config.ontology_report_path = REPORT_PATH
end
Loading