Skip to content

Commit a7f3a9d

Browse files
authored
Merge pull request #204 from ncbo/infra/ontoportal-testkit-integration
Infra/ontoportal testkit integration
2 parents 2a04c02 + 12cdeec commit a7f3a9d

9 files changed

Lines changed: 141 additions & 262 deletions

File tree

.github/workflows/ruby-unit-tests.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Docker Unit Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
tags-ignore:
8+
- '**'
9+
pull_request:
10+
11+
env:
12+
# CI execution mode for backend tests:
13+
# - container: run `test:docker:<backend>:container` (default)
14+
# - native: run `test:docker:<backend>` on host Ruby
15+
OPTK_CI_RUN_MODE: ${{ vars.OPTK_CI_RUN_MODE || 'container' }}
16+
# Example override to force native mode in this workflow file:
17+
# OPTK_CI_RUN_MODE: native
18+
19+
jobs:
20+
prepare:
21+
runs-on: ubuntu-latest
22+
outputs:
23+
backends: ${{ steps.cfg.outputs.backends }}
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- id: cfg
28+
name: Read backend matrix from .ontoportal-testkit.yml
29+
run: |
30+
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)')
31+
echo "backends=$BACKENDS" >> "$GITHUB_OUTPUT"
32+
33+
test:
34+
needs: prepare
35+
runs-on: ubuntu-latest
36+
timeout-minutes: 45
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
backend: ${{ fromJson(needs.prepare.outputs.backends) }}
41+
42+
steps:
43+
- uses: actions/checkout@v4
44+
45+
- name: Set up Ruby from .ruby-version
46+
uses: ruby/setup-ruby@v1
47+
with:
48+
ruby-version: .ruby-version
49+
bundler-cache: true
50+
51+
- name: Set up Java 11 (native mode)
52+
if: env.OPTK_CI_RUN_MODE == 'native'
53+
uses: actions/setup-java@v4
54+
with:
55+
distribution: temurin
56+
java-version: '11'
57+
58+
- name: Install native system dependencies
59+
if: env.OPTK_CI_RUN_MODE == 'native'
60+
run: |
61+
sudo apt-get update
62+
sudo apt-get install -y raptor2-utils
63+
64+
- name: Run unit tests
65+
env:
66+
CI: "true"
67+
TESTOPTS: "--verbose"
68+
BACKEND: ${{ matrix.backend }}
69+
run: |
70+
MODE="${OPTK_CI_RUN_MODE:-container}"
71+
TASK="test:docker:${BACKEND}"
72+
if [ "$MODE" = "container" ]; then
73+
TASK="${TASK}:container"
74+
elif [ "$MODE" != "native" ]; then
75+
echo "Invalid OPTK_CI_RUN_MODE=$MODE (expected container or native)"
76+
exit 1
77+
fi
78+
79+
bundle exec rake "$TASK"
80+
81+
- name: Upload coverage reports to Codecov
82+
uses: codecov/codecov-action@v5
83+
with:
84+
token: ${{ secrets.CODECOV_TOKEN }}
85+
flags: unittests,${{ matrix.backend }}
86+
verbose: true
87+
fail_ci_if_error: false

.ontoportal-testkit.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
component_name: ontologies_api
2+
app_service: test-container
3+
backends:
4+
- fs
5+
- ag
6+
- vo
7+
- gd
8+
dependency_services:
9+
- mgrep

Dockerfile

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
1-
ARG RUBY_VERSION=3.1
2-
ARG DISTRO_NAME=bullseye
1+
ARG RUBY_VERSION=3.2
2+
ARG DISTRO=bullseye
3+
ARG TESTKIT_BASE_IMAGE=ontoportal/testkit-base:ruby${RUBY_VERSION}-${DISTRO}
4+
FROM ${TESTKIT_BASE_IMAGE}
35

4-
FROM ruby:$RUBY_VERSION-$DISTRO_NAME
6+
WORKDIR /app
57

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

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

15-
WORKDIR /srv/ontoportal/ontologies_api
16+
RUN bundle install --jobs 4 --retry 3
1617

17-
ENV BUNDLE_PATH=/srv/ontoportal/bundle
18-
RUN bundle install
18+
COPY . ./
1919

20-
COPY . /srv/ontoportal/ontologies_api
21-
RUN cp /srv/ontoportal/ontologies_api/config/environments/config.rb.sample /srv/ontoportal/ontologies_api/config/environments/development.rb
22-
23-
EXPOSE 9393
2420
CMD ["bundle", "exec", "rackup", "-p", "9393", "--host", "0.0.0.0"]

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ group :test do
7878
gem 'crack', '0.4.5'
7979
gem 'minitest'
8080
gem 'minitest-hooks'
81-
gem 'minitest-stub_any_instance'
8281
gem 'minitest-reporters'
82+
gem 'minitest-stub_any_instance'
83+
gem 'ontoportal_testkit', github: 'alexskr/ontoportal_testkit', branch: 'main'
8384
gem 'rack-test'
8485
gem 'simplecov', require: false
8586
gem 'simplecov-cobertura' # for codecov.io

Gemfile.lock

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
GIT
2+
remote: https://github.com/alexskr/ontoportal_testkit.git
3+
revision: 9944d1d5f57b11e8ae9ccda11a83c7c5b2348870
4+
branch: main
5+
specs:
6+
ontoportal_testkit (0.1.0)
7+
rake (>= 13.0)
8+
19
GIT
210
remote: https://github.com/ncbo/goo.git
311
revision: 93c8ade0f7ef56fa4ad4fbdee0f9c6c4553be287
@@ -183,15 +191,9 @@ GEM
183191
faraday (~> 2.0)
184192
ffi (1.17.3)
185193
ffi (1.17.3-aarch64-linux-gnu)
186-
ffi (1.17.3-aarch64-linux-musl)
187-
ffi (1.17.3-arm-linux-gnu)
188-
ffi (1.17.3-arm-linux-musl)
189194
ffi (1.17.3-arm64-darwin)
190-
ffi (1.17.3-x86-linux-gnu)
191-
ffi (1.17.3-x86-linux-musl)
192195
ffi (1.17.3-x86_64-darwin)
193196
ffi (1.17.3-x86_64-linux-gnu)
194-
ffi (1.17.3-x86_64-linux-musl)
195197
fugit (1.12.1)
196198
et-orbi (~> 1.4)
197199
raabro (~> 1.4)
@@ -224,7 +226,6 @@ GEM
224226
google-protobuf (3.25.3)
225227
google-protobuf (3.25.3-aarch64-linux)
226228
google-protobuf (3.25.3-arm64-darwin)
227-
google-protobuf (3.25.3-x86-linux)
228229
google-protobuf (3.25.3-x86_64-darwin)
229230
google-protobuf (3.25.3-x86_64-linux)
230231
googleapis-common-protos (1.8.0)
@@ -250,9 +251,6 @@ GEM
250251
grpc (1.70.1-arm64-darwin)
251252
google-protobuf (>= 3.25, < 5.0)
252253
googleapis-common-protos-types (~> 1.0)
253-
grpc (1.70.1-x86-linux)
254-
google-protobuf (>= 3.25, < 5.0)
255-
googleapis-common-protos-types (~> 1.0)
256254
grpc (1.70.1-x86_64-darwin)
257255
google-protobuf (>= 3.25, < 5.0)
258256
googleapis-common-protos-types (~> 1.0)
@@ -515,20 +513,11 @@ GEM
515513
webrick (1.9.2)
516514

517515
PLATFORMS
518-
aarch64-linux
519516
aarch64-linux-gnu
520-
aarch64-linux-musl
521-
arm-linux-gnu
522-
arm-linux-musl
523517
arm64-darwin
524518
ruby
525-
x86-linux
526-
x86-linux-gnu
527-
x86-linux-musl
528519
x86_64-darwin
529-
x86_64-linux
530520
x86_64-linux-gnu
531-
x86_64-linux-musl
532521

533522
DEPENDENCIES
534523
activesupport
@@ -559,6 +548,7 @@ DEPENDENCIES
559548
net-ftp
560549
oj
561550
ontologies_linked_data!
551+
ontoportal_testkit!
562552
pandoc-ruby
563553
parallel
564554
parseconfig
@@ -629,15 +619,9 @@ CHECKSUMS
629619
faraday-retry (2.4.0) sha256=7b79c48fb7e56526faf247b12d94a680071ff40c9fda7cf1ec1549439ad11ebe
630620
ffi (1.17.3) sha256=0e9f39f7bb3934f77ad6feab49662be77e87eedcdeb2a3f5c0234c2938563d4c
631621
ffi (1.17.3-aarch64-linux-gnu) sha256=28ad573df26560f0aedd8a90c3371279a0b2bd0b4e834b16a2baa10bd7a97068
632-
ffi (1.17.3-aarch64-linux-musl) sha256=020b33b76775b1abacc3b7d86b287cef3251f66d747092deec592c7f5df764b2
633-
ffi (1.17.3-arm-linux-gnu) sha256=5bd4cea83b68b5ec0037f99c57d5ce2dd5aa438f35decc5ef68a7d085c785668
634-
ffi (1.17.3-arm-linux-musl) sha256=0d7626bb96265f9af78afa33e267d71cfef9d9a8eb8f5525344f8da6c7d76053
635622
ffi (1.17.3-arm64-darwin) sha256=0c690555d4cee17a7f07c04d59df39b2fba74ec440b19da1f685c6579bb0717f
636-
ffi (1.17.3-x86-linux-gnu) sha256=868a88fcaf5186c3a46b7c7c2b2c34550e1e61a405670ab23f5b6c9971529089
637-
ffi (1.17.3-x86-linux-musl) sha256=f0286aa6ef40605cf586e61406c446de34397b85dbb08cc99fdaddaef8343945
638623
ffi (1.17.3-x86_64-darwin) sha256=1f211811eb5cfaa25998322cdd92ab104bfbd26d1c4c08471599c511f2c00bb5
639624
ffi (1.17.3-x86_64-linux-gnu) sha256=3746b01f677aae7b16dc1acb7cb3cc17b3e35bdae7676a3f568153fb0e2c887f
640-
ffi (1.17.3-x86_64-linux-musl) sha256=086b221c3a68320b7564066f46fed23449a44f7a1935f1fe5a245bd89d9aea56
641625
fugit (1.12.1) sha256=5898f478ede9b415f0804e42b8f3fd53f814bd85eebffceebdbc34e1107aaf68
642626
gapic-common (1.1.0) sha256=3270ab3c5135012a4ab4d8848f945cf35014192f24504cdb40c66fc67f1beaa3
643627
get_process_mem (0.2.7) sha256=4afd3c3641dd6a817c09806c7d6d509d8a9984512ac38dea8b917426bbf77eba
@@ -651,7 +635,6 @@ CHECKSUMS
651635
google-protobuf (3.25.3) sha256=39bd97cbc7631905e76cdf8f1bf3dda1c3d05200d7e23f575aced78930fbddd6
652636
google-protobuf (3.25.3-aarch64-linux) sha256=5ea9d20d60e5d3bef8d881b426946345e5ac6cf4779ac81cd900e45f40567243
653637
google-protobuf (3.25.3-arm64-darwin) sha256=c42cddd21c4f09fd756fe0efd70ab6c8006dd67ffbb04e99fe7310f49923d18c
654-
google-protobuf (3.25.3-x86-linux) sha256=7a0e74f14affbce6024595cdb55e7e8c5a51716f0bb11b103c63cbe3a3a0e348
655638
google-protobuf (3.25.3-x86_64-darwin) sha256=13d27e96e89835f642c444e32414fd50fabc29a125d78760ad067d6536214f02
656639
google-protobuf (3.25.3-x86_64-linux) sha256=ceeba879d9313a2bd0600a97d6fe3cf529a9b37d12ca026f891996c118b7ffb2
657640
googleapis-common-protos (1.8.0) sha256=bfe89cb75d1a8f13e4591d262a20333e145481d803adb74dd13ac0517decdffe
@@ -660,7 +643,6 @@ CHECKSUMS
660643
grpc (1.70.1) sha256=174594605c96df3caed44a83221665aa6e11f554e56028f89bef82c07ffb83cb
661644
grpc (1.70.1-aarch64-linux) sha256=48e0b22b8b96e61ca7054a7fea894a4845498e6bf366b50eff03e588f714ed96
662645
grpc (1.70.1-arm64-darwin) sha256=eeb6758dd58135e4e5fcd78726b9a18d34d7313e41bc81528ff4b3dce65cf525
663-
grpc (1.70.1-x86-linux) sha256=cb7921614fec4f90f888637736b7ede85305ad94a869f736176f9ebede98c4f1
664646
grpc (1.70.1-x86_64-darwin) sha256=628cb929542c277b6e5f638b6b8575b3bdcde250a2a70bddf8c0be1bf77e6781
665647
grpc (1.70.1-x86_64-linux) sha256=ed12eea749127119c9761a58ba17ce92aadbc35b0b4fa27e4bd8ec84047d63be
666648
haml (5.2.2) sha256=6e759246556145642ef832d670fc06f9bd8539159a0e600847a00291dd7aae0c
@@ -712,6 +694,7 @@ CHECKSUMS
712694
oj (3.16.15) sha256=4d3324cac3e8fef54c0fa250b2af26a16dadd9f9788a1d6b1b2098b793a1b2cd
713695
omni_logger (0.1.4) sha256=b61596f7d96aa8426929e46c3500558d33e838e1afd7f4735244feb4d082bb3e
714696
ontologies_linked_data (0.0.1)
697+
ontoportal_testkit (0.1.0)
715698
os (1.1.4) sha256=57816d6a334e7bd6aed048f4b0308226c5fb027433b67d90a9ab435f35108d3f
716699
ostruct (0.6.3) sha256=95a2ed4a4bd1d190784e666b47b2d3f078e4a9efda2fccf18f84ddc6538ed912
717700
pandoc-ruby (2.1.10) sha256=37653d6b5e71657fb25b3cb230e6eebbfb8c925c7f1fcf69dfb6b929d12b74b2

config/environments/test.rb

Lines changed: 19 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,16 @@
11
# conig file for unit tests
22

3-
# GOO_BACKEND_NAME = ENV.include?("GOO_BACKEND_NAME") ? ENV["GOO_BACKEND_NAME"] : "AG"
4-
# GOO_HOST = ENV.include?("GOO_HOST") ? ENV["GOO_HOST"] : "localhost"
5-
# GOO_PATH_QUERY = ENV.include?("GOO_PATH_QUERY") ? ENV["GOO_PATH_QUERY"] : "/repositories/bioportal"
6-
# GOO_PATH_DATA = ENV.include?("GOO_PATH_DATA") ? ENV["GOO_PATH_DATA"] : "/repositories/bioportal/statements"
7-
# GOO_PATH_UPDATE = ENV.include?("GOO_PATH_UPDATE") ? ENV["GOO_PATH_UPDATE"] : "/repositories/bioportal/statements"
8-
# GOO_PORT = ENV.include?("GOO_PORT") ? ENV["GOO_PORT"] : 10035
9-
10-
GOO_BACKEND_NAME = ENV.include?("GOO_BACKEND_NAME") ? ENV["GOO_BACKEND_NAME"] : "4store"
11-
GOO_HOST = ENV.include?("GOO_HOST") ? ENV["GOO_HOST"] : "localhost"
12-
GOO_PATH_DATA = ENV.include?("GOO_PATH_DATA") ? ENV["GOO_PATH_DATA"] : "/data/"
13-
GOO_PATH_QUERY = ENV.include?("GOO_PATH_QUERY") ? ENV["GOO_PATH_QUERY"] : "/sparql/"
14-
GOO_PATH_UPDATE = ENV.include?("GOO_PATH_UPDATE") ? ENV["GOO_PATH_UPDATE"] : "/update/"
15-
GOO_PORT = ENV.include?("GOO_PORT") ? ENV["GOO_PORT"] : 9000
16-
17-
MGREP_DICTIONARY_FILE = ENV.include?("MGREP_DICTIONARY_FILE") ? ENV["MGREP_DICTIONARY_FILE"] : "./test/data/dictionary.txt"
18-
MGREP_HOST = ENV.include?("MGREP_HOST") ? ENV["MGREP_HOST"] : "localhost"
19-
MGREP_PORT = ENV.include?("MGREP_PORT") ? ENV["MGREP_PORT"] : 55555
20-
21-
REDIS_GOO_CACHE_HOST = ENV.include?("REDIS_GOO_CACHE_HOST") ? ENV["REDIS_GOO_CACHE_HOST"] : "localhost"
22-
REDIS_HTTP_CACHE_HOST = ENV.include?("REDIS_HTTP_CACHE_HOST") ? ENV["REDIS_HTTP_CACHE_HOST"] : "localhost"
23-
REDIS_PERSISTENT_HOST = ENV.include?("REDIS_PERSISTENT_HOST") ? ENV["REDIS_PERSISTENT_HOST"] : "localhost"
24-
REDIS_PORT = ENV.include?("REDIS_PORT") ? ENV["REDIS_PORT"] : 6379
25-
REPORT_PATH = ENV.include?("REPORT_PATH") ? ENV["REPORT_PATH"] : "./test/ontologies_report.json"
26-
REPOSITORY_FOLDER = ENV.include?("REPOSITORY_FOLDER") ? ENV["REPOSITORY_FOLDER"] : "./test/data/ontology_files/repo"
27-
SOLR_PROP_SEARCH_URL = ENV.include?("SOLR_PROP_SEARCH_URL") ? ENV["SOLR_PROP_SEARCH_URL"] : "http://localhost:8983/solr"
28-
SOLR_TERM_SEARCH_URL = ENV.include?("SOLR_TERM_SEARCH_URL") ? ENV["SOLR_TERM_SEARCH_URL"] : "http://localhost:8983/solr"
3+
GOO_BACKEND_NAME = ENV.include?("GOO_BACKEND_NAME") ? ENV["GOO_BACKEND_NAME"] : "4store"
4+
GOO_HOST = ENV.include?("GOO_HOST") ? ENV["GOO_HOST"] : "localhost"
5+
GOO_PATH_DATA = ENV.include?("GOO_PATH_DATA") ? ENV["GOO_PATH_DATA"] : "/data/"
6+
GOO_PATH_QUERY = ENV.include?("GOO_PATH_QUERY") ? ENV["GOO_PATH_QUERY"] : "/sparql/"
7+
GOO_PATH_UPDATE = ENV.include?("GOO_PATH_UPDATE") ? ENV["GOO_PATH_UPDATE"] : "/update/"
8+
GOO_PORT = ENV.include?("GOO_PORT") ? ENV["GOO_PORT"] : 9000
9+
MGREP_HOST = ENV.include?("MGREP_HOST") ? ENV["MGREP_HOST"] : "localhost"
10+
MGREP_PORT = ENV.include?("MGREP_PORT") ? ENV["MGREP_PORT"] : 55556
11+
REDIS_HOST = ENV.include?("REDIS_HOST") ? ENV["REDIS_HOST"] : "localhost"
12+
REDIS_PORT = ENV.include?("REDIS_PORT") ? ENV["REDIS_PORT"] : 6379
13+
SEARCH_SERVER_URL = ENV.include?('SEARCH_SERVER_URL') ? ENV['SEARCH_SERVER_URL'] : 'http://localhost:8983/solr'
2914

3015
LinkedData.config do |config|
3116
config.goo_backend_name = GOO_BACKEND_NAME.to_s
@@ -34,16 +19,15 @@
3419
config.goo_path_query = GOO_PATH_QUERY.to_s
3520
config.goo_path_data = GOO_PATH_DATA.to_s
3621
config.goo_path_update = GOO_PATH_UPDATE.to_s
37-
config.goo_redis_host = REDIS_GOO_CACHE_HOST.to_s
22+
config.goo_redis_host = REDIS_HOST.to_s
3823
config.goo_redis_port = REDIS_PORT.to_i
39-
config.http_redis_host = REDIS_HTTP_CACHE_HOST.to_s
24+
config.http_redis_host = REDIS_HOST.to_s
4025
config.http_redis_port = REDIS_PORT.to_i
41-
config.search_server_url = SOLR_TERM_SEARCH_URL.to_s
42-
config.property_search_server_url = SOLR_PROP_SEARCH_URL.to_s
43-
#config.enable_notifications = false
26+
config.search_server_url = SEARCH_SERVER_URL.to_s
27+
config.property_search_server_url = SEARCH_SERVER_URL.to_s
4428

4529
# Ontology analytics
46-
config.ontology_analytics_redis_host = REDIS_PERSISTENT_HOST.to_s
30+
config.ontology_analytics_redis_host = REDIS_HOST.to_s
4731
config.ontology_analytics_redis_port = REDIS_PORT.to_i
4832
config.ontology_analytics_redis_field = 'test_analytics'
4933
config.oauth_providers = {
@@ -67,20 +51,18 @@
6751
end
6852

6953
Annotator.config do |config|
70-
config.annotator_redis_host = REDIS_PERSISTENT_HOST.to_s
54+
config.annotator_redis_host = REDIS_HOST.to_s
7155
config.annotator_redis_port = REDIS_PORT.to_i
7256
config.mgrep_host = MGREP_HOST.to_s
7357
config.mgrep_port = MGREP_PORT.to_i
74-
config.mgrep_dictionary_file = MGREP_DICTIONARY_FILE.to_s
7558
end
7659

7760
LinkedData::OntologiesAPI.config do |config|
78-
config.http_redis_host = REDIS_HTTP_CACHE_HOST.to_s
61+
config.http_redis_host = REDIS_HOST.to_s
7962
config.http_redis_port = REDIS_PORT.to_i
8063
end
8164

8265
NcboCron.config do |config|
83-
config.redis_host = REDIS_PERSISTENT_HOST.to_s
66+
config.redis_host = REDIS_HOST.to_s
8467
config.redis_port = REDIS_PORT.to_i
85-
# config.ontology_report_path = REPORT_PATH
8668
end

0 commit comments

Comments
 (0)