From 8ca942852aaf442dbd81661fbd968f42fb09f16a Mon Sep 17 00:00:00 2001 From: Syphax bouazzouni Date: Mon, 6 May 2024 20:58:35 +0200 Subject: [PATCH 1/2] add slice controller action to sync slices and groups if wanted --- controllers/slices_controller.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/controllers/slices_controller.rb b/controllers/slices_controller.rb index 04e0d53e..727093e8 100644 --- a/controllers/slices_controller.rb +++ b/controllers/slices_controller.rb @@ -40,6 +40,30 @@ class SlicesController < ApplicationController end halt 204 end + + + # Check to make sure each group has a corresponding slice (and ontologies match) + get '/synchronize_groups' do + error 403, "Access denied" unless current_user && current_user.admin? + + groups = LinkedData::Models::Group.where.include(LinkedData::Models::Group.attributes(:all)).all + groups.each do |g| + slice = LinkedData::Models::Slice.find(g.acronym.downcase.gsub(" ", "_")).include(LinkedData::Models::Slice.attributes(:all)).first + if slice + slice.ontologies = g.ontologies + slice.save if slice.valid? + else + slice = LinkedData::Models::Slice.new({ + acronym: g.acronym.downcase.gsub(" ", "_"), + name: g.name, + description: g.description, + ontologies: g.ontologies + }) + slice.save rescue reply "Error creating slice: " + slice.errors.to_s + end + end + reply LinkedData::Models::Slice.where.include(LinkedData::Models::Slice.attributes(:all)).all + end private From 27bc7cb360b49981fb10b83c1910b886733f0f77 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Mon, 23 Sep 2024 23:21:38 -0700 Subject: [PATCH 2/2] =?UTF-8?q?Update=20Ruby:=20v2.7=20=E2=86=92=20v3.0=20?= =?UTF-8?q?(#159)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ruby v3.0 update * add rexml gem to Gemlock. unicorn fails to start under ruby 3 without rexml gem in the Gemfile; needs to be further investigated --- .github/workflows/ruby-unit-tests.yml | 4 +- .ruby-version | 2 +- Dockerfile | 7 +- Gemfile | 2 + Gemfile.lock | 129 +++++++++++++------------- docker-compose.yml | 4 +- 6 files changed, 72 insertions(+), 76 deletions(-) diff --git a/.github/workflows/ruby-unit-tests.yml b/.github/workflows/ruby-unit-tests.yml index d764159b..2aac1468 100644 --- a/.github/workflows/ruby-unit-tests.yml +++ b/.github/workflows/ruby-unit-tests.yml @@ -14,13 +14,13 @@ jobs: steps: - uses: actions/checkout@v4 - name: Build docker-compose - run: docker-compose --profile 4store build #profile flag is set in order to build all containers in this step + 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' + docker compose run $ci_env -e CI --rm ${{ matrix.backend }} bundle exec rake test TESTOPTS='-v' - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 with: diff --git a/.ruby-version b/.ruby-version index 6a81b4c8..818bd47a 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.8 +3.0.6 diff --git a/Dockerfile b/Dockerfile index a7adf16c..b6130644 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG RUBY_VERSION +ARG RUBY_VERSION=3.0 ARG DISTRO_NAME=bullseye FROM ruby:$RUBY_VERSION-$DISTRO_NAME @@ -14,10 +14,7 @@ COPY Gemfile* /srv/ontoportal/ontologies_api/ WORKDIR /srv/ontoportal/ontologies_api -# set rubygem and bundler to the last version supported by ruby 2.7 -# remove version after ruby v3 upgrade -RUN gem update --system '3.4.22' -RUN gem install bundler -v 2.4.22 +RUN gem update --system RUN gem install bundler ENV BUNDLE_PATH=/srv/ontoportal/bundle RUN bundle install diff --git a/Gemfile b/Gemfile index 5e5c0c8b..e050a768 100644 --- a/Gemfile +++ b/Gemfile @@ -9,6 +9,7 @@ gem 'oj', '~> 3.0' gem 'parseconfig' gem 'rack' gem 'rake', '~> 10.0' +gem 'rexml' # Investigate why unicorn fails to start under ruby 3 without adding rexml gem to the Gemfile gem 'sinatra', '~> 1.0' gem 'sinatra-advanced-routes' gem 'sinatra-contrib', '~> 1.0' @@ -77,4 +78,5 @@ group :test do gem 'simplecov', require: false gem 'simplecov-cobertura' # for codecov.io gem 'webmock', '~> 3.19.1' + gem 'webrick' end diff --git a/Gemfile.lock b/Gemfile.lock index 17ce1495..985a1127 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -16,7 +16,7 @@ GIT GIT remote: https://github.com/ncbo/ncbo_annotator.git - revision: 7531e10ad55ac66e925c099d7fc05a5a3ceae67e + revision: 2fb892f92f66b876b9793944124f72821f3b3eb8 branch: develop specs: ncbo_annotator (0.0.1) @@ -27,7 +27,7 @@ GIT GIT remote: https://github.com/ncbo/ncbo_cron.git - revision: 1fbfc8f7f3ca62de35912ec09f23cac72fea1550 + revision: 3bb491139267efc37d3b752888824ca3dd976e85 branch: develop specs: ncbo_cron (0.0.1) @@ -56,7 +56,7 @@ GIT GIT remote: https://github.com/ncbo/ontologies_linked_data.git - revision: 013a322440b4cfd899908d15ff605799acf8e6ef + revision: c30887ee907acd39500cae6c12f45edb06fe0802 branch: develop specs: ontologies_linked_data (0.0.1) @@ -108,7 +108,7 @@ GEM multi_json (~> 1.0) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) - airbrussh (1.5.2) + airbrussh (1.5.3) sshkit (>= 1.6.1, != 1.7.0) ast (2.4.2) backports (3.25.0) @@ -116,7 +116,6 @@ GEM bcrypt (3.1.20) bcrypt_pbkdf (1.1.1) bcrypt_pbkdf (1.1.1-arm64-darwin) - bcrypt_pbkdf (1.1.1-x86_64-darwin) bigdecimal (1.4.2) builder (3.3.0) capistrano (3.19.1) @@ -124,7 +123,7 @@ GEM i18n rake (>= 10.0.0) sshkit (>= 1.9.0) - capistrano-bundler (2.1.0) + capistrano-bundler (2.1.1) capistrano (~> 3.1) capistrano-locally (0.3.0) capistrano (~> 3.0) @@ -132,7 +131,7 @@ GEM capistrano (~> 3.1) sshkit (~> 1.3) coderay (1.1.3) - concurrent-ruby (1.3.3) + concurrent-ruby (1.3.4) connection_pool (2.4.1) crack (1.0.0) bigdecimal @@ -140,53 +139,52 @@ GEM cube-ruby (0.0.3) dante (0.2.0) date (3.3.4) - docile (1.4.0) + docile (1.4.1) domain_name (0.6.20240107) ed25519 (1.3.0) - faraday (2.8.1) - base64 - faraday-net_http (>= 2.0, < 3.1) - ruby2_keywords (>= 0.0.4) + faraday (2.12.0) + faraday-net_http (>= 2.0, < 3.4) + json + logger faraday-follow_redirects (0.3.0) faraday (>= 1, < 3) - faraday-net_http (3.0.2) + faraday-net_http (3.3.0) + net-http faraday-retry (2.2.1) faraday (~> 2.0) ffi (1.17.0-aarch64-linux-gnu) ffi (1.17.0-arm64-darwin) - ffi (1.17.0-x86_64-darwin) ffi (1.17.0-x86_64-linux-gnu) - gapic-common (0.21.1) + gapic-common (0.22.0) faraday (>= 1.9, < 3.a) faraday-retry (>= 1.0, < 3.a) - google-protobuf (~> 3.18) - googleapis-common-protos (>= 1.4.0, < 2.a) - googleapis-common-protos-types (>= 1.11.0, < 2.a) - googleauth (~> 1.9) - grpc (~> 1.59) + google-protobuf (>= 3.25, < 5.a) + googleapis-common-protos (~> 1.6) + googleapis-common-protos-types (~> 1.15) + googleauth (~> 1.11) + grpc (~> 1.65) get_process_mem (0.2.7) ffi (~> 1.0) - google-analytics-data (0.6.0) + google-analytics-data (0.6.1) google-analytics-data-v1beta (>= 0.11, < 2.a) google-cloud-core (~> 1.6) - google-analytics-data-v1beta (0.12.0) + google-analytics-data-v1beta (0.13.1) gapic-common (>= 0.21.1, < 2.a) google-cloud-errors (~> 1.0) - google-cloud-core (1.7.0) + google-cloud-core (1.7.1) google-cloud-env (>= 1.0, < 3.a) google-cloud-errors (~> 1.0) - google-cloud-env (2.1.1) + google-cloud-env (2.2.0) faraday (>= 1.0, < 3.a) google-cloud-errors (1.4.0) - google-protobuf (3.25.3-aarch64-linux) - google-protobuf (3.25.3-arm64-darwin) - google-protobuf (3.25.3-x86_64-darwin) - google-protobuf (3.25.3-x86_64-linux) + google-protobuf (3.25.5-aarch64-linux) + google-protobuf (3.25.5-arm64-darwin) + google-protobuf (3.25.5-x86_64-linux) googleapis-common-protos (1.6.0) google-protobuf (>= 3.18, < 5.a) googleapis-common-protos-types (~> 1.7) grpc (~> 1.41) - googleapis-common-protos-types (1.15.0) + googleapis-common-protos-types (1.16.0) google-protobuf (>= 3.18, < 5.a) googleauth (1.11.0) faraday (>= 1.0, < 3.a) @@ -195,24 +193,21 @@ GEM multi_json (~> 1.11) os (>= 0.9, < 2.0) signet (>= 0.16, < 2.a) - grpc (1.64.0-aarch64-linux) - google-protobuf (~> 3.25) - googleapis-common-protos-types (~> 1.0) - grpc (1.64.0-arm64-darwin) - google-protobuf (~> 3.25) + grpc (1.66.0-aarch64-linux) + google-protobuf (>= 3.25, < 5.0) googleapis-common-protos-types (~> 1.0) - grpc (1.64.0-x86_64-darwin) - google-protobuf (~> 3.25) + grpc (1.66.0-arm64-darwin) + google-protobuf (>= 3.25, < 5.0) googleapis-common-protos-types (~> 1.0) - grpc (1.64.0-x86_64-linux) - google-protobuf (~> 3.25) + grpc (1.66.0-x86_64-linux) + google-protobuf (>= 3.25, < 5.0) googleapis-common-protos-types (~> 1.0) haml (5.2.2) temple (>= 0.8.0) tilt - hashdiff (1.1.0) + hashdiff (1.1.1) http-accept (1.7.0) - http-cookie (1.0.6) + http-cookie (1.0.7) domain_name (~> 0.5) i18n (0.9.5) concurrent-ruby (~> 1.0) @@ -220,12 +215,12 @@ GEM json-schema (2.8.1) addressable (>= 2.4) json_pure (2.7.2) - jwt (2.8.2) + jwt (2.9.0) base64 kgio (2.11.4) language_server-protocol (3.17.0.3) libxml-ruby (5.0.3) - logger (1.6.0) + logger (1.6.1) macaddr (1.7.2) systemu (~> 2.6.5) mail (2.8.1) @@ -236,15 +231,17 @@ GEM method_source (1.1.0) mime-types (3.5.2) mime-types-data (~> 3.2015) - mime-types-data (3.2024.0702) + mime-types-data (3.2024.0903) mini_mime (1.1.5) minitest (4.7.5) minitest-stub_any_instance (1.0.3) mlanett-redis-lock (0.2.7) redis multi_json (1.15.0) + net-http (0.4.1) + uri net-http-persistent (2.9.4) - net-imap (0.4.14) + net-imap (0.4.16) date net-protocol net-pop (0.1.2) @@ -259,14 +256,15 @@ GEM net-protocol net-ssh (7.2.3) netrc (0.11.0) - newrelic_rpm (9.11.0) + newrelic_rpm (9.13.0) oj (3.16.1) omni_logger (0.1.4) logger os (1.1.4) - parallel (1.25.1) + ostruct (0.6.0) + parallel (1.26.3) parseconfig (1.1.2) - parser (3.3.3.0) + parser (3.3.5.0) ast (~> 2.4.1) racc pony (1.13.1) @@ -274,8 +272,8 @@ GEM pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - public_suffix (5.1.1) - racc (1.8.0) + public_suffix (6.0.1) + racc (1.8.1) rack (1.6.13) rack-accept (0.4.5) rack (>= 0.4) @@ -298,14 +296,14 @@ GEM rdf (1.0.8) addressable (>= 2.2) redcarpet (3.6.0) - redis (5.2.0) + redis (5.3.0) redis-client (>= 0.22.0) redis-client (0.22.2) connection_pool redis-rack-cache (2.2.1) rack-cache (>= 1.10, < 2) redis-store (>= 1.6, < 2) - redis-store (1.10.0) + redis-store (1.11.0) redis (>= 4, < 6) regexp_parser (2.9.2) request_store (1.7.0) @@ -315,27 +313,24 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rexml (3.3.1) - strscan + rexml (3.3.7) rsolr (2.6.0) builder (>= 2.1.2) faraday (>= 0.9, < 3, != 2.0.0) - rubocop (1.64.1) + rubocop (1.66.1) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.31.1, < 2.0) + regexp_parser (>= 2.4, < 3.0) + rubocop-ast (>= 1.32.2, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.31.3) + rubocop-ast (1.32.3) parser (>= 3.3.1.0) ruby-progressbar (1.13.0) ruby-xxHash (0.4.0.2) - ruby2_keywords (0.0.5) rubyzip (2.3.2) rufus-scheduler (2.0.24) tzinfo (>= 0.3.22) @@ -351,7 +346,7 @@ GEM simplecov-cobertura (2.1.0) rexml simplecov (~> 0.19) - simplecov-html (0.12.3) + simplecov-html (0.13.1) simplecov_json_formatter (0.1.4) sinatra (1.4.8) rack (~> 1.5) @@ -366,37 +361,37 @@ GEM rack-test sinatra (~> 1.4.0) tilt (>= 1.3, < 3) - sshkit (1.23.0) + sshkit (1.23.1) base64 net-scp (>= 1.1.2) net-sftp (>= 2.1.2) net-ssh (>= 2.8.0) - strscan (3.1.0) + ostruct systemu (2.6.5) temple (0.10.3) tilt (2.4.0) timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (2.5.0) + unicode-display_width (2.6.0) unicorn (6.1.0) kgio (~> 2.6) raindrops (~> 0.7) unicorn-worker-killer (0.4.5) get_process_mem (~> 0) unicorn (>= 4, < 7) + uri (0.13.1) uuid (2.3.9) macaddr (~> 1.0) webmock (3.19.1) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) + webrick (1.8.1) PLATFORMS aarch64-linux arm64-darwin-22 - arm64-darwin-23 - x86_64-darwin-23 x86_64-linux DEPENDENCIES @@ -437,6 +432,7 @@ DEPENDENCIES redis redis-rack-cache (~> 2.0) redis-store (~> 1.10) + rexml rubocop shotgun! simplecov @@ -448,6 +444,7 @@ DEPENDENCIES unicorn unicorn-worker-killer webmock (~> 3.19.1) + webrick BUNDLED WITH - 2.4.22 + 2.5.19 diff --git a/docker-compose.yml b/docker-compose.yml index 20934d3d..11811fe7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,9 +2,9 @@ x-app: &app build: context: . args: - RUBY_VERSION: '2.7' + RUBY_VERSION: '3.0' # Increase the version number in the image tag every time Dockerfile or its arguments is changed - image: ontologies_api:0.0.4 + image: ontologies_api:0.0.5 environment: &env BUNDLE_PATH: /srv/ontoportal/bundle # default bundle config resolves to /usr/local/bundle/config inside of the container