Skip to content
Draft
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
32 changes: 0 additions & 32 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: "-v"
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: ncbo_annotator
app_service: test-container
backends:
- fs
- ag
- vo
- gd
dependency_services:
- mgrep
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.6
3.2.10
28 changes: 4 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,18 @@
ARG RUBY_VERSION=3.1
ARG RUBY_VERSION=3.2
ARG DISTRO=bullseye

FROM ruby:$RUBY_VERSION-$DISTRO

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
git \
libxml2 \
libxslt-dev \
openjdk-11-jre-headless \
raptor2-utils \
&& rm -rf /var/lib/apt/lists/*
ARG TESTKIT_BASE_IMAGE=ontoportal/testkit-base:ruby${RUBY_VERSION}-${DISTRO}
FROM ${TESTKIT_BASE_IMAGE}

WORKDIR /app

# Use a dedicated bundle path
ENV BUNDLE_PATH=/usr/local/bundle
ENV GEM_HOME=/usr/local/bundle
ENV PATH="$BUNDLE_PATH/bin:$PATH"

COPY Gemfile* *.gemspec ./

RUN gem update --system

#I nstall the exact Bundler version from Gemfile.lock (if it exists)
# 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"; \
else \
gem install bundler; \
fi

RUN bundle config set --local path '/usr/local/bundle'
RUN bundle config set --global no-document 'true'
RUN bundle install --jobs 4 --retry 3

COPY . ./
Expand Down
20 changes: 13 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
source 'https://rubygems.org'

gem 'cube-ruby'
gem 'faraday'
gem 'ffi'
gem 'oj', '~> 3.0'
gem 'rake', '~> 10.0'
gem 'rake'
gem 'request_store'
gem 'parallel'
gem 'json-ld'
gem 'jwt'
gem 'ruby-xxHash'
gem 'activesupport'

group :development do
gem 'minitest', '~> 4.0'
group :test do
gem 'minitest'
gem 'minitest-reporters'
gem 'ontoportal_testkit', github: 'alexskr/ontoportal_testkit', branch: 'main'
gem 'pry'
gem 'simplecov'
gem 'simplecov-cobertura' # for codecov.io
end

# NCBO gems (can be from a local dev path or from rubygems/git)
gem 'goo', github: 'ncbo/goo', branch: 'develop'
gem 'ontologies_linked_data', github: 'ncbo/ontologies_linked_data', branch: 'develop'
gem 'sparql-client', github: 'ncbo/sparql-client', tag: 'v6.3.0'
gem 'goo', github: 'ncbo/goo', branch: 'main'
gem 'ontologies_linked_data', github: 'ncbo/ontologies_linked_data', branch: 'chore/ontoportal-lirmm-goo-compat'
gem 'sparql-client', github: 'ncbo/sparql-client', branch: 'main'
Loading
Loading