From fccf48290bae105287c31878dd2241d26b594875 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 11 Feb 2026 13:54:09 -0800 Subject: [PATCH 01/18] chore: refactor docker-based test runner and add linux container tests see https://github.com/ncbo/goo/pull/173 --- Dockerfile | 3 +- dev/compose/linux/ag.yml | 16 ++ dev/compose/linux/fs.yml | 13 ++ dev/compose/linux/gd.yml | 16 ++ dev/compose/linux/no-ports.yml | 13 ++ dev/compose/linux/vo.yml | 16 ++ docker-compose.yml | 172 ++++++++---------- .../backends/graphdb/graphdb-repo-config.ttl | 33 ++++ .../backends/graphdb/graphdb-test-load.nt | 0 .../virtuoso-grant-write-sparql-access.sql | 3 + 10 files changed, 191 insertions(+), 94 deletions(-) create mode 100644 dev/compose/linux/ag.yml create mode 100644 dev/compose/linux/fs.yml create mode 100644 dev/compose/linux/gd.yml create mode 100644 dev/compose/linux/no-ports.yml create mode 100644 dev/compose/linux/vo.yml create mode 100644 test/fixtures/backends/graphdb/graphdb-repo-config.ttl create mode 100644 test/fixtures/backends/graphdb/graphdb-test-load.nt create mode 100644 test/fixtures/backends/virtuoso_initdb_d/virtuoso-grant-write-sparql-access.sql diff --git a/Dockerfile b/Dockerfile index b9529fd14..b252ba3d2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG RUBY_VERSION=3.1 +ARG RUBY_VERSION=3.2 ARG DISTRO=bullseye FROM ruby:$RUBY_VERSION-$DISTRO @@ -8,6 +8,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ git \ libxml2 \ libxslt-dev \ + libxslt1-dev zlib1g-dev \ openjdk-11-jre-headless \ raptor2-utils \ && rm -rf /var/lib/apt/lists/* diff --git a/dev/compose/linux/ag.yml b/dev/compose/linux/ag.yml new file mode 100644 index 000000000..b56d9c8e5 --- /dev/null +++ b/dev/compose/linux/ag.yml @@ -0,0 +1,16 @@ +services: + test-linux: + environment: + GOO_BACKEND_NAME: allegrograph + GOO_PORT: 10035 + GOO_HOST: agraph-ut + GOO_PATH_QUERY: /repositories/ontoportal_test + GOO_PATH_DATA: /repositories/ontoportal_test/statements + GOO_PATH_UPDATE: /repositories/ontoportal_test/statements + depends_on: + solr-ut: + condition: service_healthy + redis-ut: + condition: service_healthy + agraph-ut: + condition: service_healthy diff --git a/dev/compose/linux/fs.yml b/dev/compose/linux/fs.yml new file mode 100644 index 000000000..27acf4b33 --- /dev/null +++ b/dev/compose/linux/fs.yml @@ -0,0 +1,13 @@ +services: + test-linux: + environment: + GOO_BACKEND_NAME: '4store' + GOO_HOST: 4store-ut + GOO_PORT: 9000 + depends_on: + solr-ut: + condition: service_healthy + redis-ut: + condition: service_healthy + 4store-ut: + condition: service_healthy diff --git a/dev/compose/linux/gd.yml b/dev/compose/linux/gd.yml new file mode 100644 index 000000000..87576c734 --- /dev/null +++ b/dev/compose/linux/gd.yml @@ -0,0 +1,16 @@ +services: + test-linux: + environment: + GOO_BACKEND_NAME: graphdb + GOO_PORT: 7200 + GOO_HOST: graphdb-ut + GOO_PATH_QUERY: /repositories/ontoportal_test + GOO_PATH_DATA: /repositories/ontoportal_test/statements + GOO_PATH_UPDATE: /repositories/ontoportal_test/statements + depends_on: + solr-ut: + condition: service_healthy + redis-ut: + condition: service_healthy + graphdb-ut: + condition: service_healthy diff --git a/dev/compose/linux/no-ports.yml b/dev/compose/linux/no-ports.yml new file mode 100644 index 000000000..f42191b93 --- /dev/null +++ b/dev/compose/linux/no-ports.yml @@ -0,0 +1,13 @@ +services: + redis-ut: + ports: [] + solr-ut: + ports: [] + agraph-ut: + ports: [] + 4store-ut: + ports: [] + virtuoso-ut: + ports: [] + graphdb-ut: + ports: [] diff --git a/dev/compose/linux/vo.yml b/dev/compose/linux/vo.yml new file mode 100644 index 000000000..c47dd6543 --- /dev/null +++ b/dev/compose/linux/vo.yml @@ -0,0 +1,16 @@ +services: + test-linux: + environment: + GOO_BACKEND_NAME: 'virtuoso' + GOO_HOST: virtuoso-ut + GOO_PORT: 8890 + GOO_PATH_QUERY: /sparql + GOO_PATH_DATA: /sparql + GOO_PATH_UPDATE: /sparql + depends_on: + solr-ut: + condition: service_healthy + redis-ut: + condition: service_healthy + virtuoso-ut: + condition: service_healthy diff --git a/docker-compose.yml b/docker-compose.yml index df84ea47f..2aec73dcf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,72 +1,28 @@ -x-app: &app +# unit tests in containerased env +services: + test-linux: build: context: . args: RUBY_VERSION: '3.2' - # Increase the version number in the image tag every time Dockerfile or its arguments is changed - image: ontologies_ld-dev:0.0.4 - environment: &env + command: ["bash", "-lc", "bundle exec rake test"] + environment: COVERAGE: 'true' # enable simplecov code coverage REDIS_HOST: redis-ut - REDIS_PORT: 6379 - SOLR_TERM_SEARCH_URL: http://solr-term-ut:8983/solr - SOLR_PROP_SEARCH_URL: http://solr-prop-ut:8983/solr - stdin_open: true - tty: true - command: /bin/bash - volumes: - # bundle volume for hosting gems installed by bundle; it speeds up gem install in local development - - bundle:/usr/local/bundle - - .:/app - # mount directory containing development version of the gems if you need to use 'bundle config local' - #- /Users/alexskr/ontoportal:/Users/alexskr/ontoportal - depends_on: &depends_on - solr-prop-ut: - condition: service_healthy - solr-term-ut: + SOLR_TERM_SEARCH_URL: http://solr-ut:8983/solr + SOLR_PROP_SEARCH_URL: http://solr-ut:8983/solr + depends_on: + solr-ut: condition: service_healthy redis-ut: condition: service_healthy - -services: - # environment wtih 4store backend - ruby: - <<: *app - environment: - <<: *env - GOO_BACKEND_NAME: 4store - GOO_PORT: 9000 - GOO_HOST: 4store-ut - GOO_PATH_QUERY: /sparql/ - GOO_PATH_DATA: /data/ - GOO_PATH_UPDATE: /update/ profiles: - - 4store - depends_on: - <<: *depends_on - 4store-ut: - condition: service_started - - # environment with AllegroGraph backend - ruby-agraph: - <<: *app - environment: - <<: *env - GOO_BACKEND_NAME: ag - GOO_PORT: 10035 - GOO_HOST: agraph-ut - GOO_PATH_QUERY: /repositories/ontoportal_test - GOO_PATH_DATA: /repositories/ontoportal_test/statements - GOO_PATH_UPDATE: /repositories/ontoportal_test/statements - profiles: - - agraph - depends_on: - <<: *depends_on - agraph-ut: - condition: service_healthy + - linux redis-ut: image: redis + ports: + - 6379:6379 command: ["redis-server", "--save", "", "--appendonly", "no"] healthcheck: test: redis-cli ping @@ -74,53 +30,45 @@ services: timeout: 3s retries: 10 + solr-ut: + image: solr:9 + command: bin/solr start -cloud -f + ports: + - 8983:8983 + healthcheck: + test: ["CMD", "curl", "-sf", "http://localhost:8983/solr/admin/info/system?wt=json"] + start_period: 5s + interval: 10s + timeout: 5s + retries: 5 + 4store-ut: image: bde2020/4store platform: linux/amd64 + 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" - profiles: - - 4store - - solr-term-ut: - image: solr:8 - volumes: - - ./test/solr/configsets:/configsets:ro - # ports: - # - "8983:8983" - command: ["solr-precreate", "term_search_core1", "/configsets/term_search"] - healthcheck: - test: ["CMD-SHELL", "curl -sf http://localhost:8983/solr/term_search_core1/admin/ping?wt=json | grep -iq '\"status\":\"OK\"}' || exit 1"] - start_period: 5s - interval: 10s - timeout: 5s - retries: 5 - - solr-prop-ut: - image: solr:8 - volumes: - - ./test/solr/configsets:/configsets:ro - # ports: - # - "8984:8983" - command: ["solr-precreate", "prop_search_core1", "/configsets/property_search"] + bash -c "4s-backend-setup --segments 4 ontoportal_test + && 4s-backend ontoportal_test + && 4s-httpd -D -s-1 -p 9000 ontoportal_test" healthcheck: - test: ["CMD-SHELL", "curl -sf http://localhost:8983/solr/prop_search_core1/admin/ping?wt=json | grep -iq '\"status\":\"OK\"}' || exit 1"] + test: ["CMD", "4s-backend-info", "ontoportal_test"] start_period: 5s interval: 10s - timeout: 5s + timeout: 10s retries: 5 + profiles: + - fs agraph-ut: - image: franzinc/agraph:v8.3.1 - platform: linux/amd64 + image: franzinc/agraph:v8.4.3 + platform: linux/amd64 #agraph doesn't provide arm platform environment: - AGRAPH_SUPER_USER=test - AGRAPH_SUPER_PASSWORD=xyzzy shm_size: 1g - # ports: - # - 10035:10035 + ports: + - 10035:10035 command: > bash -c "/agraph/bin/agraph-control --config /agraph/etc/agraph.cfg start ; agtool repos create --supersede ontoportal_test @@ -128,13 +76,51 @@ services: ; agtool users grant anonymous root:ontoportal_test:rw ; tail -f /agraph/data/agraph.log" healthcheck: - test: ["CMD-SHELL", "agtool storage-report ontoportal_test || exit 1"] + test: ["CMD", "agtool", "storage-report", "ontoportal_test"] start_period: 30s #AllegroGraph can take a loooooong time to start interval: 20s timeout: 10s retries: 20 profiles: - - agraph + - ag -volumes: - bundle: + virtuoso-ut: + image: openlink/virtuoso-opensource-7:7.2.16 + environment: + - SPARQL_UPDATE=true + - DBA_PASSWORD=dba + - DAV_PASSWORD=dba + ports: + - 1111:1111 + - 8890:8890 + volumes: + - ./test/fixtures/backends/virtuoso_initdb_d:/initdb.d + healthcheck: + test: [ "CMD-SHELL", "echo 'status();' | isql localhost:1111 dba dba || exit 1" ] + start_period: 10s + interval: 10s + timeout: 5s + retries: 3 + profiles: + - vo + + graphdb-ut: + image: ontotext/graphdb:10.8.12 + environment: + GDB_HEAP_SIZE: 5G + GDB_JAVA_OPTS: >- + -Xms5g -Xmx5g + ports: + - 7200:7200 + - 7300:7300 + healthcheck: + test: [ "CMD", "curl", "-sf", "http://localhost:7200/repositories/ontoportal_test/health" ] + start_period: 10s + interval: 10s + volumes: + - ./test/fixtures/backends/graphdb:/opt/graphdb/dist/configs/templates/data + entrypoint: > + bash -c " importrdf load -f -c /opt/graphdb/dist/configs/templates/data/graphdb-repo-config.ttl -m parallel /opt/graphdb/dist/configs/templates/data/graphdb-test-load.nt + ; graphdb -Ddefault.min.distinct.threshold=3000 " + profiles: + - gd diff --git a/test/fixtures/backends/graphdb/graphdb-repo-config.ttl b/test/fixtures/backends/graphdb/graphdb-repo-config.ttl new file mode 100644 index 000000000..84032a0b1 --- /dev/null +++ b/test/fixtures/backends/graphdb/graphdb-repo-config.ttl @@ -0,0 +1,33 @@ +@prefix rdfs: . +@prefix rep: . +@prefix sail: . +@prefix xsd: . + +<#ontoportal_test> a rep:Repository; + rep:repositoryID "ontoportal_test"; + rep:repositoryImpl [ + rep:repositoryType "graphdb:SailRepository"; + [ + "http://example.org/owlim#"; + "false"; + ""; + "true"; + "false"; + "true"; + "true"; + "32"; + "10000000"; + ""; + "true"; + ""; + "0"; + "0"; + "false"; + "file-repository"; + "rdfsplus-optimized"; + "storage"; + "false"; + sail:sailType "owlim:Sail" + ] + ]; + rdfs:label "" . diff --git a/test/fixtures/backends/graphdb/graphdb-test-load.nt b/test/fixtures/backends/graphdb/graphdb-test-load.nt new file mode 100644 index 000000000..e69de29bb diff --git a/test/fixtures/backends/virtuoso_initdb_d/virtuoso-grant-write-sparql-access.sql b/test/fixtures/backends/virtuoso_initdb_d/virtuoso-grant-write-sparql-access.sql new file mode 100644 index 000000000..d509c6fb8 --- /dev/null +++ b/test/fixtures/backends/virtuoso_initdb_d/virtuoso-grant-write-sparql-access.sql @@ -0,0 +1,3 @@ +GRANT EXECUTE ON DB.DBA.SPARQL_INSERT_DICT_CONTENT TO "SPARQL"; +GRANT SPARQL_UPDATE TO "SPARQL"; +DB.DBA.RDF_DEFAULT_USER_PERMS_SET ('nobody', 7); From 537197aaba17a7870953f996e4e7a146ff8ed7a2 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 11 Feb 2026 14:01:45 -0800 Subject: [PATCH 02/18] Tests no longer execute inside the Docker container --- .github/workflows/ruby-unit-tests.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ruby-unit-tests.yml b/.github/workflows/ruby-unit-tests.yml index d8eadf4f0..1922d939b 100644 --- a/.github/workflows/ruby-unit-tests.yml +++ b/.github/workflows/ruby-unit-tests.yml @@ -13,22 +13,17 @@ jobs: strategy: fail-fast: false matrix: - backend: ['ruby', 'ruby-agraph'] # ruby runs tests with 4store backend and ruby-agraph runs with AllegroGraph backend + goo-slice: [ '100'] + #triplestore: [ 'fs', 'ag', 'vo', 'gd' ] + triplestore: [ 'fs', 'ag' ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up solr configsets - run: ./test/solr/generate_ncbo_configsets.sh - name: create config.rb file run: cp config/config.test.rb config/config.rb - - name: Build docker compose - run: docker compose --profile 4store build # profile flag is set in order to build all containers in this step - 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 ${{ matrix.backend }} bundle exec rake test TESTOPTS='-v' + GOO_SLICES=${{ matrix.goo-slice }} bundle exec rake test:docker:${{ matrix.triplestore }} TESTOPTS="-v" - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v5 with: From 08cbe96a59a1902f4284e72e2aedba28ae23ee28 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 11 Feb 2026 14:47:47 -0800 Subject: [PATCH 03/18] install dependencies --- .github/workflows/ruby-unit-tests.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/ruby-unit-tests.yml b/.github/workflows/ruby-unit-tests.yml index 1922d939b..cc52570eb 100644 --- a/.github/workflows/ruby-unit-tests.yml +++ b/.github/workflows/ruby-unit-tests.yml @@ -19,6 +19,15 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y raptor2-utils + - name: Set up Java 11 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '11' - name: create config.rb file run: cp config/config.test.rb config/config.rb - name: Run unit tests From 835db5cf11d2c7ce558b7daff976361cfa972899 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 11 Feb 2026 14:58:11 -0800 Subject: [PATCH 04/18] add ruby setup --- .github/workflows/ruby-unit-tests.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ruby-unit-tests.yml b/.github/workflows/ruby-unit-tests.yml index cc52570eb..7c0a65852 100644 --- a/.github/workflows/ruby-unit-tests.yml +++ b/.github/workflows/ruby-unit-tests.yml @@ -13,7 +13,6 @@ jobs: strategy: fail-fast: false matrix: - goo-slice: [ '100'] #triplestore: [ 'fs', 'ag', 'vo', 'gd' ] triplestore: [ 'fs', 'ag' ] runs-on: ubuntu-latest @@ -24,15 +23,19 @@ jobs: sudo apt-get update sudo apt-get install -y raptor2-utils - name: Set up Java 11 - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: temurin java-version: '11' + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true - name: create config.rb file run: cp config/config.test.rb config/config.rb - name: Run unit tests run: | - GOO_SLICES=${{ matrix.goo-slice }} bundle exec rake test:docker:${{ matrix.triplestore }} TESTOPTS="-v" + bundle exec rake test:docker:${{ matrix.triplestore }} TESTOPTS="-v" - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v5 with: From 87733c455e7d0e77ea6afd91ffe0533899e98ce4 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 11 Feb 2026 15:22:40 -0800 Subject: [PATCH 05/18] add rakelib --- rakelib/docker_based_test.rake | 240 +++++++++++++++++++++++++++++++++ 1 file changed, 240 insertions(+) create mode 100644 rakelib/docker_based_test.rake diff --git a/rakelib/docker_based_test.rake b/rakelib/docker_based_test.rake new file mode 100644 index 000000000..c3cd32aa8 --- /dev/null +++ b/rakelib/docker_based_test.rake @@ -0,0 +1,240 @@ +# Docker compose driven unit test orchestration +# +# Notes: +# - Backend names match compose profile names (ag, fs, vo, gd). +# - Hostnames are NOT set here. The app defaults them (localhost for host runs). +# - Linux container env is provided via compose override files: +# dev/compose/linux/ag.yml +# dev/compose/linux/fs.yml +# dev/compose/linux/vo.yml +# dev/compose/linux/gd.yml +namespace :test do + namespace :docker do + BASE_COMPOSE = 'docker-compose.yml' + LINUX_OVERRIDE_DIR = 'dev/compose/linux' + LINUX_NO_PORTS_OVERRIDE = "#{LINUX_OVERRIDE_DIR}/no-ports.yml" + TIMEOUT = (ENV['OP_TEST_DOCKER_TIMEOUT'] || '600').to_i + DEFAULT_BACKEND = (ENV['OP_TEST_DOCKER_BACKEND'] || 'fs').to_sym + + # Minimal per-backend config for host runs only. + # Do not set hostnames here. The app defaults them. + BACKENDS = { + ag: { + host_env: { + 'GOO_BACKEND_NAME' => 'allegrograph', + 'GOO_PORT' => '10035', + 'GOO_PATH_QUERY' => '/repositories/ontoportal_test', + 'GOO_PATH_DATA' => '/repositories/ontoportal_test/statements', + 'GOO_PATH_UPDATE' => '/repositories/ontoportal_test/statements' + } + }, + fs: { + host_env: { + 'GOO_BACKEND_NAME' => '4store', + 'GOO_PORT' => '9000', + 'GOO_PATH_QUERY' => '/sparql/', + 'GOO_PATH_DATA' => '/data/', + 'GOO_PATH_UPDATE' => '/update/' + } + }, + vo: { + host_env: { + 'GOO_BACKEND_NAME' => 'virtuoso', + 'GOO_PORT' => '8890', + 'GOO_PATH_QUERY' => '/sparql', + 'GOO_PATH_DATA' => '/sparql', + 'GOO_PATH_UPDATE' => '/sparql' + } + }, + gd: { + host_env: { + 'GOO_BACKEND_NAME' => 'graphdb', + 'GOO_PORT' => '7200', + 'GOO_PATH_QUERY' => '/repositories/ontoportal_test', + 'GOO_PATH_DATA' => '/repositories/ontoportal_test/statements', + 'GOO_PATH_UPDATE' => '/repositories/ontoportal_test/statements' + } + } + }.freeze + + def abort_with(msg) + warn(msg) + exit(1) + end + + def shell!(cmd) + system(cmd) || abort_with("Command failed: #{cmd}") + end + + def cfg!(key) + cfg = BACKENDS[key] + abort_with("Unknown backend key: #{key}. Supported: #{BACKENDS.keys.join(', ')}") unless cfg + cfg + end + + def compose_files(*files) + files.flatten.map { |f| "-f #{f}" }.join(' ') + end + + def linux_override_for(key) + "#{LINUX_OVERRIDE_DIR}/#{key}.yml" + end + + def compose_up(key, files:) + # Host tests use only the backend profile. Linux tests add the linux profile. + # `docker compose up --wait` only applies to services started by `up`, + # so linux runs still call `run` separately after this wait completes. + shell!("docker compose #{compose_files(files)} --profile #{key} up -d --wait --wait-timeout #{TIMEOUT}") + end + + def compose_down(files:) + return puts('OP_KEEP_CONTAINERS=1 set, skipping docker compose down') if ENV['OP_KEEP_CONTAINERS'] == '1' + + shell!( + "docker compose #{compose_files(files)} " \ + '--profile ag --profile fs --profile vo --profile gd --profile linux down' + ) + end + + def apply_host_env(key) + cfg!(key)[:host_env].each { |k, v| ENV[k] = v } + end + + def run_host_tests(key) + apply_host_env(key) + files = [BASE_COMPOSE] + + compose_up(key, files: files) + Rake::Task['test'].invoke + end + + def run_linux_tests(key) + override = linux_override_for(key) + abort_with("Missing compose override file: #{override}") unless File.exist?(override) + abort_with("Missing compose override file: #{LINUX_NO_PORTS_OVERRIDE}") unless File.exist?(LINUX_NO_PORTS_OVERRIDE) + + files = [BASE_COMPOSE, override, LINUX_NO_PORTS_OVERRIDE] + # docker compose is handleling wait_for_healthy + compose_up(key, files: files) + + shell!( + "docker compose #{compose_files(files)} --profile linux --profile #{key} " \ + 'run --rm --build test-linux bundle exec rake test TESTOPTS="-v"' + ) + end + + def run_linux_shell(key) + override = linux_override_for(key) + abort_with("Missing compose override file: #{override}") unless File.exist?(override) + abort_with("Missing compose override file: #{LINUX_NO_PORTS_OVERRIDE}") unless File.exist?(LINUX_NO_PORTS_OVERRIDE) + + files = [BASE_COMPOSE, override, LINUX_NO_PORTS_OVERRIDE] + compose_up(key, files: files) + + shell!( + "docker compose #{compose_files(files)} --profile linux --profile #{key} " \ + 'run --rm --build test-linux bash' + ) + end + + # + # Public tasks + # + + desc 'Run unit tests with AllegroGraph backend (docker deps, host Ruby)' + task :ag do + run_host_tests(:ag) + ensure + Rake::Task['test'].reenable + compose_down(files: [BASE_COMPOSE]) + end + + desc 'Run unit tests with AllegroGraph backend (docker deps, Linux container)' + task 'ag:linux' do + files = [BASE_COMPOSE, linux_override_for(:ag)] + begin + run_linux_tests(:ag) + ensure + compose_down(files: files) + end + end + + desc 'Run unit tests with 4store backend (docker deps, host Ruby)' + task :fs do + run_host_tests(:fs) + ensure + Rake::Task['test'].reenable + compose_down(files: [BASE_COMPOSE]) + end + + desc 'Run unit tests with 4store backend (docker deps, Linux container)' + task 'fs:linux' do + files = [BASE_COMPOSE, linux_override_for(:fs)] + begin + run_linux_tests(:fs) + ensure + compose_down(files: files) + end + end + + desc 'Run unit tests with Virtuoso backend (docker deps, host Ruby)' + task :vo do + run_host_tests(:vo) + ensure + Rake::Task['test'].reenable + compose_down(files: [BASE_COMPOSE]) + end + + desc 'Run unit tests with Virtuoso backend (docker deps, Linux container)' + task 'vo:linux' do + files = [BASE_COMPOSE, linux_override_for(:vo)] + begin + run_linux_tests(:vo) + ensure + compose_down(files: files) + end + end + + desc 'Run unit tests with GraphDB backend (docker deps, host Ruby)' + task :gd do + run_host_tests(:gd) + ensure + Rake::Task['test'].reenable + compose_down(files: [BASE_COMPOSE]) + end + + desc 'Run unit tests with GraphDB backend (docker deps, Linux container)' + task 'gd:linux' do + files = [BASE_COMPOSE, linux_override_for(:gd)] + begin + run_linux_tests(:gd) + ensure + compose_down(files: files) + end + end + + desc 'Start a shell in the Linux test container (default backend: fs)' + task :shell, [:backend] do |_t, args| + key = (args[:backend] || DEFAULT_BACKEND).to_sym + cfg!(key) + files = [BASE_COMPOSE, linux_override_for(key), LINUX_NO_PORTS_OVERRIDE] + begin + run_linux_shell(key) + ensure + compose_down(files: files) + end + end + + desc 'Start backend services for development (default backend: fs)' + task :up, [:backend] do |_t, args| + key = (args[:backend] || DEFAULT_BACKEND).to_sym + cfg!(key) + compose_up(key, files: [BASE_COMPOSE]) + end + + desc 'Stop backend services for development (default backend: fs)' + task :down, [:backend] do |_t, args| + compose_down(files: [BASE_COMPOSE]) + end + end +end From 6f3b70bc0510a4ffd675b171da90169dd7d5db42 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 11 Feb 2026 15:49:21 -0800 Subject: [PATCH 06/18] run unit tests inside a container --- .github/workflows/ruby-unit-tests.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ruby-unit-tests.yml b/.github/workflows/ruby-unit-tests.yml index 7c0a65852..1dedb721f 100644 --- a/.github/workflows/ruby-unit-tests.yml +++ b/.github/workflows/ruby-unit-tests.yml @@ -18,15 +18,15 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Install system dependencies - run: | - sudo apt-get update - sudo apt-get install -y raptor2-utils - - name: Set up Java 11 - uses: actions/setup-java@v5 - with: - distribution: temurin - java-version: '11' + # - name: Install system dependencies + # run: | + # sudo apt-get update + # sudo apt-get install -y raptor2-utils + # - name: Set up Java 11 + # uses: actions/setup-java@v5 + # with: + # distribution: temurin + # java-version: '11' - name: Set up Ruby uses: ruby/setup-ruby@v1 with: @@ -35,7 +35,7 @@ jobs: run: cp config/config.test.rb config/config.rb - name: Run unit tests run: | - bundle exec rake test:docker:${{ matrix.triplestore }} TESTOPTS="-v" + test:docker:${{ matrix.triplestore }}:linux TESTOPTS="-v" - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v5 with: From 07aaf40462d2b612a6803292b1009d033b7df2e0 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 11 Feb 2026 15:50:16 -0800 Subject: [PATCH 07/18] add rake command --- .github/workflows/ruby-unit-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruby-unit-tests.yml b/.github/workflows/ruby-unit-tests.yml index 1dedb721f..89e289824 100644 --- a/.github/workflows/ruby-unit-tests.yml +++ b/.github/workflows/ruby-unit-tests.yml @@ -35,7 +35,7 @@ jobs: run: cp config/config.test.rb config/config.rb - name: Run unit tests run: | - test:docker:${{ matrix.triplestore }}:linux TESTOPTS="-v" + rake test:docker:${{ matrix.triplestore }}:linux TESTOPTS="-v" - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v5 with: From df4a75d6885384dbca692f4a9438940f8b053a88 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 11 Feb 2026 16:17:06 -0800 Subject: [PATCH 08/18] add step to build docker containter --- .github/workflows/ruby-unit-tests.yml | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ruby-unit-tests.yml b/.github/workflows/ruby-unit-tests.yml index 89e289824..beb3fc59b 100644 --- a/.github/workflows/ruby-unit-tests.yml +++ b/.github/workflows/ruby-unit-tests.yml @@ -18,24 +18,20 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - # - name: Install system dependencies - # run: | - # sudo apt-get update - # sudo apt-get install -y raptor2-utils - # - name: Set up Java 11 - # uses: actions/setup-java@v5 - # with: - # distribution: temurin - # java-version: '11' - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - name: create config.rb file run: cp config/config.test.rb config/config.rb + - name: Run unit tests + - name: Build docker container + run: docker compose -f dev/compose/linux/${{ matrix.triplestore }}.yml --profile linux build - name: Run unit tests run: | - rake test:docker:${{ matrix.triplestore }}:linux TESTOPTS="-v" + ci_env=`bash <(curl -s https://codecov.io/env)` + docker compose -f docker-compose.yml \ + -f dev/compose/linux/${{ matrix.triplestore }}.yml \ + --profile linux \ + --profile ${{ matrix.triplestore }} \ + run $ci_env -e CI=true --build test-linux bundle exec rake test TESTOPTS="-v" + # docker compose rake test:docker:${{ matrix.triplestore }}:linux TESTOPTS="-v" - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v5 with: From 05a15bfff4aab2f8f087aca058742a9ae3aa3744 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 11 Feb 2026 16:18:31 -0800 Subject: [PATCH 09/18] fix fat finger copy&paste --- .github/workflows/ruby-unit-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ruby-unit-tests.yml b/.github/workflows/ruby-unit-tests.yml index beb3fc59b..d13345e2e 100644 --- a/.github/workflows/ruby-unit-tests.yml +++ b/.github/workflows/ruby-unit-tests.yml @@ -20,7 +20,6 @@ jobs: - uses: actions/checkout@v4 - name: create config.rb file run: cp config/config.test.rb config/config.rb - - name: Run unit tests - name: Build docker container run: docker compose -f dev/compose/linux/${{ matrix.triplestore }}.yml --profile linux build - name: Run unit tests From 1f317eefa780857ee942751ab36879b2971c383f Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 11 Feb 2026 16:46:31 -0800 Subject: [PATCH 10/18] Remove the ci_env Codecov env script line. --- .github/workflows/ruby-unit-tests.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ruby-unit-tests.yml b/.github/workflows/ruby-unit-tests.yml index d13345e2e..b49656e68 100644 --- a/.github/workflows/ruby-unit-tests.yml +++ b/.github/workflows/ruby-unit-tests.yml @@ -21,15 +21,17 @@ jobs: - name: create config.rb file run: cp config/config.test.rb config/config.rb - name: Build docker container - run: docker compose -f dev/compose/linux/${{ matrix.triplestore }}.yml --profile linux build + run: docker compose -f docker-compose.yml \ + -f dev/compose/linux/${{ matrix.triplestore }}.yml --profile linux \ + build - name: Run unit tests run: | - ci_env=`bash <(curl -s https://codecov.io/env)` docker compose -f docker-compose.yml \ -f dev/compose/linux/${{ matrix.triplestore }}.yml \ --profile linux \ --profile ${{ matrix.triplestore }} \ - run $ci_env -e CI=true --build test-linux bundle exec rake test TESTOPTS="-v" + run -v "$PWD/coverage:/app/coverage" -e CI=true \ + test-linux bundle exec rake test TESTOPTS="-v" # docker compose rake test:docker:${{ matrix.triplestore }}:linux TESTOPTS="-v" - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v5 From bcfc9209bac1b14cdf4accbf242a2a0af0b0b81d Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 11 Feb 2026 16:51:13 -0800 Subject: [PATCH 11/18] Update the run block to YAML folded style > --- .github/workflows/ruby-unit-tests.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ruby-unit-tests.yml b/.github/workflows/ruby-unit-tests.yml index b49656e68..2e62e5094 100644 --- a/.github/workflows/ruby-unit-tests.yml +++ b/.github/workflows/ruby-unit-tests.yml @@ -21,16 +21,18 @@ jobs: - name: create config.rb file run: cp config/config.test.rb config/config.rb - name: Build docker container - run: docker compose -f docker-compose.yml \ - -f dev/compose/linux/${{ matrix.triplestore }}.yml --profile linux \ - build + run: > + docker compose -f docker-compose.yml + -f dev/compose/linux/${{ matrix.triplestore }}.yml + --profile linux + build - name: Run unit tests - run: | - docker compose -f docker-compose.yml \ - -f dev/compose/linux/${{ matrix.triplestore }}.yml \ - --profile linux \ - --profile ${{ matrix.triplestore }} \ - run -v "$PWD/coverage:/app/coverage" -e CI=true \ + run: > + docker compose -f docker-compose.yml + -f dev/compose/linux/${{ matrix.triplestore }}.yml + --profile linux + --profile ${{ matrix.triplestore }} + run -v "$PWD/coverage:/app/coverage" -e CI=true test-linux bundle exec rake test TESTOPTS="-v" # docker compose rake test:docker:${{ matrix.triplestore }}:linux TESTOPTS="-v" - name: Upload coverage reports to Codecov From 5089da5e012cbd8ae53936b6495a36d7ad048002 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 11 Feb 2026 16:57:38 -0800 Subject: [PATCH 12/18] add missing profile --- .github/workflows/ruby-unit-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ruby-unit-tests.yml b/.github/workflows/ruby-unit-tests.yml index 2e62e5094..99e43e410 100644 --- a/.github/workflows/ruby-unit-tests.yml +++ b/.github/workflows/ruby-unit-tests.yml @@ -25,6 +25,7 @@ jobs: docker compose -f docker-compose.yml -f dev/compose/linux/${{ matrix.triplestore }}.yml --profile linux + --profile ${{ matrix.triplestore }} build - name: Run unit tests run: > From ae46bf626bafbb03fb76173d74aefc4848c7b5ee Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 11 Feb 2026 17:10:44 -0800 Subject: [PATCH 13/18] optimize --- .github/workflows/ruby-unit-tests.yml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ruby-unit-tests.yml b/.github/workflows/ruby-unit-tests.yml index 99e43e410..018acbbdc 100644 --- a/.github/workflows/ruby-unit-tests.yml +++ b/.github/workflows/ruby-unit-tests.yml @@ -10,6 +10,12 @@ on: jobs: test: + env: + COMPOSE_CMD: > + docker compose -f docker-compose.yml + -f dev/compose/linux/${{ matrix.triplestore }}.yml + --profile linux + --profile ${{ matrix.triplestore }} strategy: fail-fast: false matrix: @@ -22,20 +28,11 @@ jobs: run: cp config/config.test.rb config/config.rb - name: Build docker container run: > - docker compose -f docker-compose.yml - -f dev/compose/linux/${{ matrix.triplestore }}.yml - --profile linux - --profile ${{ matrix.triplestore }} - build + $COMPOSE_CMD build - name: Run unit tests run: > - docker compose -f docker-compose.yml - -f dev/compose/linux/${{ matrix.triplestore }}.yml - --profile linux - --profile ${{ matrix.triplestore }} - run -v "$PWD/coverage:/app/coverage" -e CI=true + $COMPOSE_CMD run -v "$PWD/coverage:/app/coverage" -e CI=true test-linux bundle exec rake test TESTOPTS="-v" - # docker compose rake test:docker:${{ matrix.triplestore }}:linux TESTOPTS="-v" - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v5 with: From 9c1b35fa316a31061c9c336e6c1d695afebad927 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 11 Feb 2026 21:14:04 -0800 Subject: [PATCH 14/18] add image build caching --- .github/workflows/ruby-unit-tests.yml | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ruby-unit-tests.yml b/.github/workflows/ruby-unit-tests.yml index 018acbbdc..94ce33d7b 100644 --- a/.github/workflows/ruby-unit-tests.yml +++ b/.github/workflows/ruby-unit-tests.yml @@ -11,8 +11,10 @@ on: jobs: test: env: + RUBY_VERSION: '3.2' COMPOSE_CMD: > docker compose -f docker-compose.yml + -f dev/compose/linux/docker-compose.ci.yml -f dev/compose/linux/${{ matrix.triplestore }}.yml --profile linux --profile ${{ matrix.triplestore }} @@ -24,14 +26,27 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: create config.rb file run: cp config/config.test.rb config/config.rb - - name: Build docker container - run: > - $COMPOSE_CMD build + - name: Build test image with cache + uses: docker/bake-action@v6 + with: + files: | + docker-compose.yml + dev/compose/linux/docker-compose.ci.yml + dev/compose/linux/${{ matrix.triplestore }}.yml + targets: test-linux + set: | + test-linux.args.RUBY_VERSION=${{ env.RUBY_VERSION }} + test-linux.cache-from=type=gha,scope=test-linux-ruby-${{ env.RUBY_VERSION }} + test-linux.cache-to=type=gha,mode=max,scope=test-linux-ruby-${{ env.RUBY_VERSION }} + test-linux.output=type=docker + test-linux.tags=ontologies_linked_data-test-linux:ci - name: Run unit tests run: > - $COMPOSE_CMD run -v "$PWD/coverage:/app/coverage" -e CI=true + $COMPOSE_CMD run --no-build -v "$PWD/coverage:/app/coverage" -e CI=true test-linux bundle exec rake test TESTOPTS="-v" - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v5 From d2b49e672c92712b7d4bf3d4667e4eaaf8065f07 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 11 Feb 2026 21:16:01 -0800 Subject: [PATCH 15/18] add ci docker compose profile for image build caching --- dev/compose/linux/docker-compose.ci.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 dev/compose/linux/docker-compose.ci.yml diff --git a/dev/compose/linux/docker-compose.ci.yml b/dev/compose/linux/docker-compose.ci.yml new file mode 100644 index 000000000..4397c33d6 --- /dev/null +++ b/dev/compose/linux/docker-compose.ci.yml @@ -0,0 +1,3 @@ +services: + test-linux: + image: ontologies_linked_data-test-linux:ci From 2a023c680bbe8700bac2b32c30ee0e741fbf0472 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 11 Feb 2026 21:19:36 -0800 Subject: [PATCH 16/18] remove invalid --no-build flag --- .github/workflows/ruby-unit-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruby-unit-tests.yml b/.github/workflows/ruby-unit-tests.yml index 94ce33d7b..6433deb14 100644 --- a/.github/workflows/ruby-unit-tests.yml +++ b/.github/workflows/ruby-unit-tests.yml @@ -46,7 +46,7 @@ jobs: test-linux.tags=ontologies_linked_data-test-linux:ci - name: Run unit tests run: > - $COMPOSE_CMD run --no-build -v "$PWD/coverage:/app/coverage" -e CI=true + $COMPOSE_CMD run -v "$PWD/coverage:/app/coverage" -e CI=true test-linux bundle exec rake test TESTOPTS="-v" - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v5 From 2d382a5848991006fe63232e9115b2b926207f00 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Wed, 11 Feb 2026 21:53:23 -0800 Subject: [PATCH 17/18] create config.rb in Dockerfile --- Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Dockerfile b/Dockerfile index b252ba3d2..0b920394f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,11 +15,15 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ WORKDIR /app +# set default test config +COPY config/config.test.rb config/config.rb + COPY Gemfile* *.gemspec ./ # Copy only the `version.rb` file to prevent missing file errors! COPY lib/ontologies_linked_data/version.rb lib/ontologies_linked_data/ + #Install the exact Bundler version from Gemfile.lock (if it exists) RUN gem update --system && \ if [ -f Gemfile.lock ]; then \ From d452834d1bd4fd5610db196999c6ad2db5eb7007 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Thu, 12 Feb 2026 09:50:13 -0800 Subject: [PATCH 18/18] revert image build caching --- .github/workflows/ruby-unit-tests.yml | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ruby-unit-tests.yml b/.github/workflows/ruby-unit-tests.yml index 6433deb14..63d322633 100644 --- a/.github/workflows/ruby-unit-tests.yml +++ b/.github/workflows/ruby-unit-tests.yml @@ -14,7 +14,6 @@ jobs: RUBY_VERSION: '3.2' COMPOSE_CMD: > docker compose -f docker-compose.yml - -f dev/compose/linux/docker-compose.ci.yml -f dev/compose/linux/${{ matrix.triplestore }}.yml --profile linux --profile ${{ matrix.triplestore }} @@ -26,24 +25,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: create config.rb file - run: cp config/config.test.rb config/config.rb - - name: Build test image with cache - uses: docker/bake-action@v6 - with: - files: | - docker-compose.yml - dev/compose/linux/docker-compose.ci.yml - dev/compose/linux/${{ matrix.triplestore }}.yml - targets: test-linux - set: | - test-linux.args.RUBY_VERSION=${{ env.RUBY_VERSION }} - test-linux.cache-from=type=gha,scope=test-linux-ruby-${{ env.RUBY_VERSION }} - test-linux.cache-to=type=gha,mode=max,scope=test-linux-ruby-${{ env.RUBY_VERSION }} - test-linux.output=type=docker - test-linux.tags=ontologies_linked_data-test-linux:ci + - name: Build docker container + run: > + $COMPOSE_CMD build - name: Run unit tests run: > $COMPOSE_CMD run -v "$PWD/coverage:/app/coverage" -e CI=true