From e2b4b6c1703c81c268c57f94489cab6ed5b5d028 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Thu, 2 Nov 2023 07:25:29 +0100 Subject: [PATCH] tmp --- .github/workflows/tests.yml | 51 +++++ Dockerfile | 34 ++-- Gemfile.lock | 43 ++-- app/controllers/application_controller.rb | 5 +- app/controllers/landscape_controller.rb | 1 + app/views/projects/index.html.haml | 2 +- bin/wait-for-it | 182 +++++++++++++++++ config/bioportal_config_test.rb | 183 ++++++++++++++++++ config/database.yml.sample | 3 +- docker-compose.yml | 24 ++- .../application_controller_test.rb | 18 ++ .../controllers/ontologies_controller_test.rb | 19 ++ 12 files changed, 511 insertions(+), 54 deletions(-) create mode 100644 .github/workflows/tests.yml create mode 100755 bin/wait-for-it create mode 100644 config/bioportal_config_test.rb create mode 100644 test/controllers/application_controller_test.rb create mode 100644 test/controllers/ontologies_controller_test.rb diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000000..a0ead655f2 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,51 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake +# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby + +name: unit-tests + +on: + push: + pull_request_target: + types: [ opened, reopened ] + + +env: + API_URL: ${{ secrets.API_URL }} + API_KEY: ${{ secrets.API_KEY }} + BIOMIXER_URL: ${{ secrets.BIOMIXER_URL }} + FAIRNESS_URL: ${{ secrets.FAIRNESS_URL }} + ANNOTATOR_URL: ${{ secrets.ANNOTATOR_URL }} + DB_HOST: ${{ secrets.DB_HOST || '127.0.0.1' }} + DB_PORT: ${{ secrets.DB_PORT || 3306 }} + RAILS_ENV: test + +jobs: + test: + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/checkout@v3 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7.6 # Not needed with a .ruby-version file + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + - name: set up config file + run: cp .env.sample .env && cp config/database.yml.sample config/database.yml + - name: build docker + run: docker compose --profile cache-db up -d + - name: wait for MySQL to start + run: | + for i in {1..10}; do + if nc -z ${{ env.DB_HOST }} ${{ env.DB_PORT }}; then + break + fi + sleep 1 + done + + - name: run test docker + run: RAILS_ENV=test bin/rails db:setup && bin/rails test -v \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 88f019fdb5..d5950edb14 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:2.7.5-alpine AS app +FROM ruby:2.7.8-alpine AS app WORKDIR /app @@ -17,34 +17,26 @@ RUN apk add --no-cache \ less \ && addgroup --gid ${GID} ruby \ && adduser -u ${UID} -G ruby -D ruby \ - && chown ruby:ruby -R /app \ - && mkdir /node_modules \ - && chown ruby:ruby -R /node_modules /app + && mkdir /node_modules -USER ruby - -COPY --chown=ruby:ruby bin/ ./bin -RUN chmod 0755 bin/* +COPY --chown=ruby:ruby Gemfile* ./ +COPY --chown=ruby:ruby package.json *yarn* ./ -ARG RAILS_ENV="production" +# Set ownership and permissions +RUN chown -R ruby:ruby /app -ENV RAILS_ENV="${RAILS_ENV}" \ - NODE_ENV="${NODE_ENV}" \ - PATH="${PATH}:/home/ruby/.local/bin:/node_modules/.bin" \ - USER="ruby" \ - BUNDLE_PATH=/usr/local/bundle +USER ruby -COPY --chown=ruby:ruby Gemfile* ./ +# Install dependencies RUN bundle install --jobs "$(nproc)" -RUN gem install rails - - +RUN gem install rails +RUN yarn install RUN echo "--modules-folder /node_modules" > .yarnrc -COPY --chown=ruby:ruby package.json *yarn* ./ -RUN yarn install +# Copy application code +COPY --chown=ruby:ruby . . EXPOSE 3000 -CMD ["sh"] \ No newline at end of file +CMD ["bash"] \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index e1035012ca..ccb8564173 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -101,7 +101,7 @@ GEM smart_properties bindata (2.4.15) bindex (0.8.1) - bootsnap (1.16.0) + bootsnap (1.17.0) msgpack (~> 1.2) bootstrap (4.2.1) autoprefixer-rails (>= 9.1.0) @@ -156,7 +156,7 @@ GEM erubi (1.12.0) erubis (2.7.0) eventmachine (1.2.7) - excon (0.103.0) + excon (0.104.0) execjs (2.9.1) faraday (2.0.1) faraday-net_http (~> 2.0) @@ -169,13 +169,13 @@ GEM faraday-multipart (1.0.4) multipart-post (~> 2) faraday-net_http (2.1.0) - ffi (1.16.1) + ffi (1.16.3) flag-icons-rails (3.4.6.1) sass-rails flamegraph (0.9.5) globalid (1.2.1) activesupport (>= 6.1) - graphql (2.1.3) + graphql (2.1.5) racc (~> 1.4) graphql-client (0.18.0) activesupport (>= 3.0) @@ -197,20 +197,21 @@ GEM domain_name (~> 0.5) i18n (1.14.1) concurrent-ruby (~> 1.0) - i18n-tasks (1.0.12) + i18n-tasks (1.0.13) activesupport (>= 4.0.2) ast (>= 2.1.0) better_html (>= 1.0, < 3.0) erubi highline (>= 2.0.0) i18n - parser (>= 2.2.3.0) + parser (>= 3.2.2.1) rails-i18n rainbow (>= 2.2.2, < 4.0) terminal-table (>= 1.5.1) iconv (1.0.8) - importmap-rails (1.2.1) + importmap-rails (1.2.3) actionpack (>= 6.0.0) + activesupport (>= 6.0.0) railties (>= 6.0.0) inline_svg (1.9.0) activesupport (>= 3.0) @@ -280,7 +281,7 @@ GEM time net-http (0.3.2) uri - net-imap (0.4.1) + net-imap (0.4.3) date net-protocol net-pop (0.1.2) @@ -293,7 +294,8 @@ GEM net-protocol net-ssh (7.2.0) netrc (0.11.0) - newrelic_rpm (9.5.0) + newrelic_rpm (9.6.0) + base64 nio4r (2.5.9) nokogiri (1.15.4-x86_64-darwin) racc (~> 1.4) @@ -345,7 +347,7 @@ GEM public_suffix (5.0.3) puma (5.6.7) nio4r (~> 2.0) - racc (1.7.1) + racc (1.7.2) rack (2.2.8) rack-accept (0.4.5) rack (>= 0.4) @@ -391,7 +393,7 @@ GEM thor (~> 1.0) zeitwerk (~> 2.5) rainbow (3.1.1) - rake (13.0.6) + rake (13.1.0) rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) @@ -399,8 +401,8 @@ GEM recaptcha (5.9.0) json redcarpet (3.6.0) - regexp_parser (2.8.1) - reline (0.3.8) + regexp_parser (2.8.2) + reline (0.3.9) io-console (~> 0.5) rest-client (2.1.0) http-accept (>= 1.7.0, < 2.0) @@ -408,7 +410,7 @@ GEM mime-types (>= 1.16, < 4.0) netrc (~> 0.8) rexml (3.2.6) - rouge (4.1.3) + rouge (4.2.0) rspec-core (3.12.2) rspec-support (~> 3.12.0) rspec-expectations (3.12.3) @@ -426,8 +428,7 @@ GEM rspec-mocks (~> 3.12) rspec-support (~> 3.12) rspec-support (3.12.1) - rubocop (1.56.3) - base64 (~> 0.1.1) + rubocop (1.57.2) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -438,7 +439,7 @@ GEM rubocop-ast (>= 1.28.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.29.0) + rubocop-ast (1.30.0) parser (>= 3.2.1.0) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) @@ -480,16 +481,16 @@ GEM stackprof (0.2.25) stimulus-rails (1.3.0) railties (>= 6.0.0) - temple (0.10.2) + temple (0.10.3) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) - terser (1.1.18) + terser (1.1.19) execjs (>= 0.3.0, < 3) thin (1.8.2) daemons (~> 1.0, >= 1.0.9) eventmachine (~> 1.0, >= 1.0.4) rack (>= 1, < 3) - thor (1.2.2) + thor (1.3.0) tilt (2.3.0) time (0.2.2) date @@ -532,7 +533,7 @@ GEM xpath (3.2.0) nokogiri (~> 1.8) yard (0.9.34) - zeitwerk (2.6.11) + zeitwerk (2.6.12) PLATFORMS x86_64-darwin-21 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1c3bc48a0b..2a4155e02c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -128,10 +128,7 @@ def domain_ontology_set Thread.current[:slice] = @subdomain_filter end - def anonymous_user - user = DataAccess.getUser($ANONYMOUS_USER) - user ||= User.new({"id" => 0}) - end + def ontology_not_found(ontology_acronym) not_found("Ontology #{ontology_acronym} not found") diff --git a/app/controllers/landscape_controller.rb b/app/controllers/landscape_controller.rb index c3f81dc9a8..df189593cd 100644 --- a/app/controllers/landscape_controller.rb +++ b/app/controllers/landscape_controller.rb @@ -110,6 +110,7 @@ def index # Get hash of natural language use if !sub.naturalLanguage.nil? && !sub.naturalLanguage.empty? sub.naturalLanguage.each do |sub_lang| + next unless sub_lang.is_a?(String) # replace lexvo URI by lexvo prefix prefixed_sub_lang = sub_lang if sub_lang.start_with?("http://lexvo.org/id/iso639-3/") diff --git a/app/views/projects/index.html.haml b/app/views/projects/index.html.haml index e17084d21d..1aaf9aed37 100644 --- a/app/views/projects/index.html.haml +++ b/app/views/projects/index.html.haml @@ -5,7 +5,7 @@ %h1.tab_header= t("projects.self") %p.tab_description = t("projects.index.intro", site: "#{$SITE}") - = link_to(help_path(anchor: "Projects_Tab"), id: "projects-help", aria: {label: t("projects.view_projects_help")}) do + = link_to("#{Rails.configuration.settings.links[:help]}#Projects_Tab", id: "projects-help", aria: {label: t("projects.view_projects_help")}) do %i.fas.fa-question-circle.fa-lg{aria: {hidden: "true"}, style: "margin-left: .25em"} %div{:style => "padding:10px;"} diff --git a/bin/wait-for-it b/bin/wait-for-it new file mode 100755 index 0000000000..7888ed4326 --- /dev/null +++ b/bin/wait-for-it @@ -0,0 +1,182 @@ +#!/usr/bin/env sh +# Use this script to test if a given TCP host/port are available + +WAITFORIT_cmdname=${0##*/} + +echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi } + +usage() +{ + cat << USAGE >&2 +Usage: + $WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args] + -h HOST | --host=HOST Host or IP under test + -p PORT | --port=PORT TCP port under test + Alternatively, you specify the host and port as host:port + -s | --strict Only execute subcommand if the test succeeds + -q | --quiet Don't output any status messages + -t TIMEOUT | --timeout=TIMEOUT + Timeout in seconds, zero for no timeout + -- COMMAND ARGS Execute command with args after the test finishes +USAGE + exit 1 +} + +wait_for() +{ + if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then + echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT" + else + echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout" + fi + WAITFORIT_start_ts=$(date +%s) + while : + do + if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then + nc -z $WAITFORIT_HOST $WAITFORIT_PORT + WAITFORIT_result=$? + else + (echo -n > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1 + WAITFORIT_result=$? + fi + if [[ $WAITFORIT_result -eq 0 ]]; then + WAITFORIT_end_ts=$(date +%s) + echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds" + break + fi + sleep 1 + done + return $WAITFORIT_result +} + +wait_for_wrapper() +{ + # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692 + if [[ $WAITFORIT_QUIET -eq 1 ]]; then + timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT & + else + timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT & + fi + WAITFORIT_PID=$! + trap "kill -INT -$WAITFORIT_PID" INT + wait $WAITFORIT_PID + WAITFORIT_RESULT=$? + if [[ $WAITFORIT_RESULT -ne 0 ]]; then + echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT" + fi + return $WAITFORIT_RESULT +} + +# process arguments +while [[ $# -gt 0 ]] +do + case "$1" in + *:* ) + WAITFORIT_hostport=(${1//:/ }) + WAITFORIT_HOST=${WAITFORIT_hostport[0]} + WAITFORIT_PORT=${WAITFORIT_hostport[1]} + shift 1 + ;; + --child) + WAITFORIT_CHILD=1 + shift 1 + ;; + -q | --quiet) + WAITFORIT_QUIET=1 + shift 1 + ;; + -s | --strict) + WAITFORIT_STRICT=1 + shift 1 + ;; + -h) + WAITFORIT_HOST="$2" + if [[ $WAITFORIT_HOST == "" ]]; then break; fi + shift 2 + ;; + --host=*) + WAITFORIT_HOST="${1#*=}" + shift 1 + ;; + -p) + WAITFORIT_PORT="$2" + if [[ $WAITFORIT_PORT == "" ]]; then break; fi + shift 2 + ;; + --port=*) + WAITFORIT_PORT="${1#*=}" + shift 1 + ;; + -t) + WAITFORIT_TIMEOUT="$2" + if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi + shift 2 + ;; + --timeout=*) + WAITFORIT_TIMEOUT="${1#*=}" + shift 1 + ;; + --) + shift + WAITFORIT_CLI=("$@") + break + ;; + --help) + usage + ;; + *) + echoerr "Unknown argument: $1" + usage + ;; + esac +done + +if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then + echoerr "Error: you need to provide a host and port to test." + usage +fi + +WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15} +WAITFORIT_STRICT=${WAITFORIT_STRICT:-0} +WAITFORIT_CHILD=${WAITFORIT_CHILD:-0} +WAITFORIT_QUIET=${WAITFORIT_QUIET:-0} + +# Check to see if timeout is from busybox? +WAITFORIT_TIMEOUT_PATH=$(type -p timeout) +WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH) + +WAITFORIT_BUSYTIMEFLAG="" +if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then + WAITFORIT_ISBUSY=1 + # Check if busybox timeout uses -t flag + # (recent Alpine versions don't support -t anymore) + if timeout &>/dev/stdout | grep -q -e '-t '; then + WAITFORIT_BUSYTIMEFLAG="-t" + fi +else + WAITFORIT_ISBUSY=0 +fi + +if [[ $WAITFORIT_CHILD -gt 0 ]]; then + wait_for + WAITFORIT_RESULT=$? + exit $WAITFORIT_RESULT +else + if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then + wait_for_wrapper + WAITFORIT_RESULT=$? + else + wait_for + WAITFORIT_RESULT=$? + fi +fi + +if [[ $WAITFORIT_CLI != "" ]]; then + if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then + echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess" + exit $WAITFORIT_RESULT + fi + exec "${WAITFORIT_CLI[@]}" +else + exit $WAITFORIT_RESULT +fi diff --git a/config/bioportal_config_test.rb b/config/bioportal_config_test.rb new file mode 100644 index 0000000000..0ab2fc81a4 --- /dev/null +++ b/config/bioportal_config_test.rb @@ -0,0 +1,183 @@ +# coding: utf-8 + + +$SITE = 'Testportal' +$UI_HOSTNAME = 'localhost' +$UI_URL = "http://#{$UI_HOSTNAME}:3000" + + +$API_KEY = ENV["API_KEY"] +$REST_URL = ENV["API_URL"] +$BIOMIXER_URL = ENV['BIOMIXER_URL'] +$ANNOTATOR_URL = $PROXY_URL = ENV['ANNOTATOR_URL'] +$FAIRNESS_URL = ENV['ANNOTATOR_URL'] + +# config/initializers/omniauth_providers.rb +$OMNIAUTH_PROVIDERS = { + github: { + client_id: 'id', + client_secret: 'secret', + icon: 'icons/github.svg', + }, + google: { + strategy: :google_oauth2, + client_id: 'id', + client_secret: 'secret', + icon: 'icons/google.svg', + }, + orcid: { + client_id: 'YOUR_ORCID_CLIENT_ID', + client_secret: 'YOUR_ORCID_CLIENT_SECRET', + icon: 'icons/orcid.svg' + }, + keycloak: { + strategy: :keycloak_openid, + client_id: 'YOUR_KEYCLOAK_CLIENT_ID', + client_secret: 'YOUR_KEYCLOAK_CLIENT_SECRET', + client_options: { site: 'KEYCLOAK_SITE', realm: 'KEYCLOAK_REALM' }, + name: 'keycloak', + icon: 'icons/keycloak.svg' + } +}.freeze + + +$INTERPORTAL_HASH = {} + + + +# If your BioPortal installation includes Fairness score set this to true +$FAIRNESS_DISABLED = false + + + + +# Pairing a name with an array of ontology virtual ids will allow you to filter ontologies based on a subdomain. +# If your main UI is hosted at example.org and you add custom.example.org pointing to the same Rails installation +# you could filter the ontologies visible at custom.example.org by adding this to the hash: "custom" => { :name => "Custom Slice", :ontologies => [1032, 1054, 1099] } +# Any number of slices can be added. Groups are added automatically using the group acronym as the subdomain. +$ENABLE_SLICES = true +$ONTOLOGY_SLICES = {} + + +# Cube metrics reporting +$ENABLE_CUBE = false + +$NOT_DOWNLOADABLE = {} +# Enable client request caching +$CLIENT_REQUEST_CACHING = true + +# If you don't use Airbrake you can have exceptions emailed to the $ERROR_EMAIL address by setting this to 'true' +$EMAIL_EXCEPTIONS = false + + +# Announcements mailman mailing list REQUEST address, EX: list-request@lists.example.org +# NOTE: You must use the REQUEST address for the mailing list. ONLY WORKS WITH MAILMAN LISTS. +$ANNOUNCE_LIST ||= "appliance-users-request@localhost" + +# Email addresses used for sending notifications (errors, feedback, support) +$SUPPORT_EMAIL ||= "support@localhost" +$ADMIN_EMAIL ||= "admin@localhost" +$ERROR_EMAIL ||= "errors@localhost" + +# Custom BioPortal logging +require 'log' +$REMOTE_LOGGING = false + +## +# Custom Ontology Details +# Custom details can be added on a per ontology basis using a key/value pair as columns of the details table +# +# Example: +# $ADDITIONAL_ONTOLOGY_DETAILS = { 1000 => { "Additional Detail" => "Text to be shown in the right-hand column." } } +## +$ADDITIONAL_ONTOLOGY_DETAILS = {} + + +# Site notice appears on all pages and remains closed indefinitely. Stored below as a hash with a unique key and a +# EX: $SITE_NOTICE = { :unique_key => 'Put your message here (can include html if you use +$SITE_NOTICE = {} +################################ +## AUTO-GENERATED DO NOT MODIFY +################################# + +# Full string for site, EX: "NCBO BioPortal" +$ORG_SITE = ($ORG.nil? || $ORG.empty?) ? $SITE : "#{$ORG} #{$SITE}" + +$HOME_PAGE_LOGOS = { + supported_by: [ + { + img_src: 'logos/supports/numev.png', + url: 'http://www.lirmm.fr/numev', + target: '_blank', + }, + { + img_src: 'logos/supports/anr.png', + url: 'https://anr.fr/en', + target: '_blank', + }, + { + img_src: 'logos/supports/eu.png', + url: 'https://commission.europa.eu/research-and-innovation_en', + target: '_blank', + } + ], + with_the_collaboration_of: [ + { + img_src: 'logos/collaboration/d2kab.png', + url: 'http://d2kab.mystrikingly.com', + target: '_blank', + }, + { + img_src: 'logos/collaboration/lirmm.png', + url: 'http://www.lirmm.fr', + target: '_blank', + }, + { + img_src: 'logos/collaboration/inrae.png', + url: 'https://www.inrae.fr/enm', + target: '_blank', + }, + { + img_src: 'logos/collaboration/stanford.png', + url: 'https://www.stanford.edu', + target: '_blank', + }, + ] +} + +$FOOTER_LINKS = { + social: [ + { logo: "social/people.svg", link: "https://github.com/orgs/agroportal/people" }, + { logo: "social/github.svg", link: "https://github.com/agroportal" }, + { logo: "social/twitter.svg", link: "https://twitter.com/lagroportal" }, + ], + sections: { + products: { + ontoportal: "https://ontoportal.org/", + release_notes: "https://doc.jonquetlab.lirmm.fr/share/e6158eda-c109-4385-852c-51a42de9a412/doc/release-notes-btKjZk5tU2", + api: "https://data.agroportal.lirmm.fr/", + sparql: "https://sparql.agroportal.lirmm.fr/test/" + }, + support: { + contact_us: "https://agroportal.lirmm.fr/feedback", + wiki: "https://www.bioontology.org/wiki/", + documentation: "https://ontoportal.github.io/documentation/" + }, + agreements: { + terms: "", + privacy_policy: "", + cite_us: "", + acknowledgments: "" + }, + about: { + about_us: "https://github.com/agroportal/project-management", + projects: "https://d2kab.mystrikingly.com/", + team: "https://github.com/orgs/agroportal/people" + } + } +} + +$UI_THEME = :stageportal +if File.exist?('config/bioportal_config_development_testportal.lirmm.fr.rb') + require_relative 'bioportal_config_development_testportal.lirmm.fr.rb' # local credentials +end \ No newline at end of file diff --git a/config/database.yml.sample b/config/database.yml.sample index c92d72df20..431cbfc63c 100644 --- a/config/database.yml.sample +++ b/config/database.yml.sample @@ -12,10 +12,9 @@ default: &default adapter: mysql2 encoding: utf8mb4 - pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: root password: bp_user - host: db + host: <%= ENV["DB_HOST"] %> development: <<: *default diff --git a/docker-compose.yml b/docker-compose.yml index 38be0278fb..f8f8ecd249 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,7 +18,7 @@ x-app: &default-app tty: true volumes: - "${DOCKER_WEB_VOLUME}" - - bundle:/usr/local/bundle + - bundle:/usr/local/bundle - node:/node_modules services: @@ -26,7 +26,7 @@ services: environment: MYSQL_ROOT_PASSWORD: 'bp_user' image: "mysql:latest" - profiles: ["db"] + profiles: [ "cache-db", "db", "web", "test" ] ports: - "3306:3306" volumes: @@ -38,14 +38,28 @@ services: cpus: "${DOCKER_REDIS_CPUS:-0}" memory: "${DOCKER_REDIS_MEMORY:-0}" image: "memcached:1.6.17-bullseye" - profiles: ["cache"] + profiles: [ "cache-db", "cache", "web", "test" ] - web: + yarn: <<: *default-app ports: - "${DOCKER_WEB_PORT_FORWARD:-127.0.0.1:3000}:${PORT:-3000}" - profiles: ["web"] + profiles: [ "web" ] command: "yarn build --watch" + + web: + <<: *default-app + environment: + API_URL: ${API_URL} + API_KEY: ${API_KEY} + BIOMIXER_URL: ${BIOMIXER_URL} + FAIRNESS_URL: ${FAIRNESS_URL} + ANNOTATOR_URL: ${ANNOTATOR_URL} + BUNDLE_PATH: /usr/local/bundle + ports: + - "${DOCKER_WEB_PORT_FORWARD:-127.0.0.1:3000}:${PORT:-3000}" + profiles: [ "test" ] + command: RAILS_ENV=test bin/rails s volumes: db-v: bundle: diff --git a/test/controllers/application_controller_test.rb b/test/controllers/application_controller_test.rb new file mode 100644 index 0000000000..61fae4fb65 --- /dev/null +++ b/test/controllers/application_controller_test.rb @@ -0,0 +1,18 @@ +require 'test_helper' + +class ApplicationControllerTest < ActionDispatch::IntegrationTest + + test 'should show home page' do + get '' + assert_response :success + end + + + test 'should show projects page' do + get '/projects' + assert_response :success + end + +end + + diff --git a/test/controllers/ontologies_controller_test.rb b/test/controllers/ontologies_controller_test.rb new file mode 100644 index 0000000000..ece3d84bd6 --- /dev/null +++ b/test/controllers/ontologies_controller_test.rb @@ -0,0 +1,19 @@ +require 'test_helper' + +class OntologiesControllerTest < ActionDispatch::IntegrationTest + ONTOLOGIES = LinkedData::Client::Models::Ontology.all(include: 'acronym') + PAGES = %w[summary classes properties notes mappings schemes collections widgets].freeze + + test 'should return all the ontologies' do + get ontologies_path + assert_response :success + end + + ONTOLOGIES.sample(ENV['CI'] ? 20 : 5).flat_map { |ont| PAGES.map { |page| [ont, page] } }.each do |ont, page| + test "should get page #{page} of #{ont.acronym} ontology" do + path = "#{ontologies_path}/#{ont.acronym}?p=#{page}" + get path + assert_response :success, "GET #{path} returned #{response.status}" + end + end +end