diff --git a/.docker/development/Dockerfile b/.docker/development/Dockerfile index 733b61b..54f9429 100644 --- a/.docker/development/Dockerfile +++ b/.docker/development/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:3.2.5 AS cartafact_base +FROM ruby:3.4.9 AS cartafact_base ENV HOME /cartafact diff --git a/.docker/production/Dockerfile b/.docker/production/Dockerfile index a21066b..a019cf3 100644 --- a/.docker/production/Dockerfile +++ b/.docker/production/Dockerfile @@ -2,7 +2,7 @@ ### app config ### ######################## -FROM ruby:3.2.5 AS app +FROM ruby:3.4.9 AS app ENV HOME /cartafact diff --git a/.docker/production/Dockerfile.gha b/.docker/production/Dockerfile.gha index 2c77731..05049cd 100644 --- a/.docker/production/Dockerfile.gha +++ b/.docker/production/Dockerfile.gha @@ -3,14 +3,14 @@ ############################################ # Taken from .ruby-version -ARG RUBY_VERSION=3.2.5 +ARG RUBY_VERSION=3.4.9 FROM ruby:$RUBY_VERSION-slim-bookworm AS base LABEL author="DCHBX" ARG DEBIAN_FRONTEND=noninteractive # Taken from Gemfile.lock -ARG BUNDLER_VERSION=2.4.19 +ARG BUNDLER_VERSION=2.6.9 ENV BUNDLER_VERSION=$BUNDLER_VERSION ARG NODE_MAJOR=20 @@ -44,6 +44,8 @@ RUN apt-get update \ unzip \ zip \ zlib1g \ + libyaml-dev \ + pkg-config \ libjemalloc2 \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ @@ -64,7 +66,7 @@ ENV HOME=/cartafact ENV PATH=$HOME/bin:$BUNDLE_BIN:$GEM_HOME/gems/bin:$PATH # rubygems-update > 3.4.22 requires ruby >= 3.0.0 -RUN gem update --system 3.4.22\ +RUN gem update --system \ && rm -f /usr/local/bin/ruby/gems/*/specifications/default/bundler-*.gemspec \ && gem install bundler -v $BUNDLER_VERSION diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index 9462b63..310b1b0 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -51,7 +51,7 @@ jobs: runs-on: ubuntu-latest services: mongo: - image: mongo:4.2 + image: mongo:5.0 ports: - 27017:27017 options: >- diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 543a7e9..040e07a 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -13,11 +13,11 @@ jobs: - name: Launch MongoDB uses: wbari/start-mongoDB@v0.2 with: - mongoDBVersion: 3.6 - - name: Set up Ruby 3.2.5 + mongoDBVersion: 5.0 + - name: Set up Ruby 3.4.9 uses: ruby/setup-ruby@v1 with: - ruby-version: 3.2.5 + ruby-version: 3.4.9 - name: Cache Gems uses: actions/cache@v4 with: @@ -35,4 +35,4 @@ jobs: bundle exec rspec - name: Run Rubocop run: | - bundle exec rubocop \ No newline at end of file + bundle exec rubocop diff --git a/.ruby-version b/.ruby-version index ac55709..7bcbb38 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-3.2.5 +3.4.9 diff --git a/Gemfile b/Gemfile index 0f0b1e5..16a4402 100644 --- a/Gemfile +++ b/Gemfile @@ -3,11 +3,11 @@ source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby '3.2.5' +ruby '3.4.9' -gem 'rails', '~> 7.2.0' +gem 'rails', '~> 8.1' -gem 'mongoid', '~> 8.1.5' +gem 'mongoid', '~> 9.0' # Use Puma as the app server gem 'puma', '~> 6.0' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder @@ -30,7 +30,7 @@ gem "aws-sdk-s3", "~> 1.14" # Settings, validation and dependency injection # TODO: Use tagged release for resource_registry instead of branch gem 'resource_registry', git: 'https://github.com/ideacrew/resource_registry.git', tag: 'v0.10.1' -gem 'fast_jsonapi' +gem 'jsonapi-serializer' gem 'shrine-mongoid', '~> 1.0' @@ -47,7 +47,7 @@ gem 'dry-container', '~> 0.7' gem 'dry-auto_inject', '~> 0.6' gem 'dry-transaction', '~> 0.13' gem 'dry-initializer', '~> 3.0' -gem 'jwt', '~> 2.2.1' +gem 'jwt', '~> 2.9' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console @@ -56,8 +56,8 @@ group :development, :test do gem 'shoulda-matchers' gem 'yard' gem 'climate_control' - gem 'factory_bot_rails', '~> 4.11' - gem 'database_cleaner', '~> 1.7' + gem 'factory_bot_rails', '~> 6.4' + gem 'database_cleaner-mongoid', '~> 2.0' gem 'pry-byebug' end diff --git a/Gemfile.lock b/Gemfile.lock index 5163669..59df758 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -20,79 +20,80 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (7.2.3) - actionpack (= 7.2.3) - activesupport (= 7.2.3) + action_text-trix (2.1.17) + railties + actioncable (8.1.2) + actionpack (= 8.1.2) + activesupport (= 8.1.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.2.3) - actionpack (= 7.2.3) - activejob (= 7.2.3) - activerecord (= 7.2.3) - activestorage (= 7.2.3) - activesupport (= 7.2.3) + actionmailbox (8.1.2) + actionpack (= 8.1.2) + activejob (= 8.1.2) + activerecord (= 8.1.2) + activestorage (= 8.1.2) + activesupport (= 8.1.2) mail (>= 2.8.0) - actionmailer (7.2.3) - actionpack (= 7.2.3) - actionview (= 7.2.3) - activejob (= 7.2.3) - activesupport (= 7.2.3) + actionmailer (8.1.2) + actionpack (= 8.1.2) + actionview (= 8.1.2) + activejob (= 8.1.2) + activesupport (= 8.1.2) mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (7.2.3) - actionview (= 7.2.3) - activesupport (= 7.2.3) - cgi + actionpack (8.1.2) + actionview (= 8.1.2) + activesupport (= 8.1.2) nokogiri (>= 1.8.5) - racc - rack (>= 2.2.4, < 3.3) + rack (>= 2.2.4) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) useragent (~> 0.16) - actiontext (7.2.3) - actionpack (= 7.2.3) - activerecord (= 7.2.3) - activestorage (= 7.2.3) - activesupport (= 7.2.3) + actiontext (8.1.2) + action_text-trix (~> 2.1.15) + actionpack (= 8.1.2) + activerecord (= 8.1.2) + activestorage (= 8.1.2) + activesupport (= 8.1.2) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.2.3) - activesupport (= 7.2.3) + actionview (8.1.2) + activesupport (= 8.1.2) builder (~> 3.1) - cgi erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.2.3) - activesupport (= 7.2.3) + activejob (8.1.2) + activesupport (= 8.1.2) globalid (>= 0.3.6) - activemodel (7.2.3) - activesupport (= 7.2.3) - activerecord (7.2.3) - activemodel (= 7.2.3) - activesupport (= 7.2.3) + activemodel (8.1.2) + activesupport (= 8.1.2) + activerecord (8.1.2) + activemodel (= 8.1.2) + activesupport (= 8.1.2) timeout (>= 0.4.0) - activestorage (7.2.3) - actionpack (= 7.2.3) - activejob (= 7.2.3) - activerecord (= 7.2.3) - activesupport (= 7.2.3) + activestorage (8.1.2) + actionpack (= 8.1.2) + activejob (= 8.1.2) + activerecord (= 8.1.2) + activesupport (= 8.1.2) marcel (~> 1.0) - activesupport (7.2.3) + activesupport (8.1.2) base64 - benchmark (>= 0.3) bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + json logger (>= 1.4.2) minitest (>= 5.1) securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) addressable (2.8.8) public_suffix (>= 2.0.2, < 8.0) ast (2.4.3) @@ -116,22 +117,24 @@ GEM aws-sigv4 (1.12.1) aws-eventstream (~> 1, >= 1.0.2) base64 (0.3.0) - benchmark (0.5.0) bigdecimal (4.0.1) bindex (0.8.1) - bootsnap (1.21.1) + bootsnap (1.23.0) msgpack (~> 1.2) bson (5.2.0) builder (3.3.0) - byebug (12.0.0) - cgi (0.5.1) + byebug (13.0.0) + reline (>= 0.6.0) climate_control (1.2.0) coderay (1.1.3) concurrent-ruby (1.3.6) connection_pool (3.0.2) content_disposition (1.0.0) crass (1.0.6) - database_cleaner (1.99.0) + database_cleaner-core (2.0.1) + database_cleaner-mongoid (2.0.1) + database_cleaner-core (~> 2.0.0) + mongoid date (3.5.1) deep_merge (1.2.2) diff-lcs (1.6.2) @@ -205,14 +208,13 @@ GEM zeitwerk (~> 2.6) erb (6.0.1) erubi (1.13.1) - factory_bot (4.11.1) - activesupport (>= 3.0.0) - factory_bot_rails (4.11.1) - factory_bot (~> 4.11.1) - railties (>= 3.0.0) - fast_jsonapi (1.5) - activesupport (>= 4.2) - ffi (1.17.3) + factory_bot (6.5.6) + activesupport (>= 6.1.0) + factory_bot_rails (6.5.1) + factory_bot (~> 6.5) + railties (>= 6.1.0) + ffi (1.17.3-arm64-darwin) + ffi (1.17.3-x86_64-linux-gnu) globalid (1.3.0) activesupport (>= 6.1) i18n (1.14.8) @@ -225,7 +227,13 @@ GEM reline (>= 0.4.2) jmespath (1.6.2) json (2.18.0) - jwt (2.2.3) + json-schema (6.2.0) + addressable (~> 2.8) + bigdecimal (>= 3.1, < 5) + jsonapi-serializer (2.2.0) + activesupport (>= 4.2) + jwt (2.10.2) + base64 language_server-protocol (3.17.0.5) lint_roller (1.1.0) listen (3.10.0) @@ -243,25 +251,25 @@ GEM net-pop net-smtp marcel (1.1.0) + mcp (0.8.0) + json-schema (>= 4.1) method_source (1.1.0) mime-types (3.7.0) logger mime-types-data (~> 3.2025, >= 3.2025.0507) mime-types-data (3.2026.0113) mini_mime (1.1.5) - mini_portile2 (2.8.9) minitest (6.0.1) prism (~> 1.5) - mongo (2.22.0) + mongo (2.23.0) base64 bson (>= 4.14.1, < 6.0.0) - mongoid (8.1.11) - activemodel (>= 5.1, < 8.1, != 7.0.0) + mongoid (9.0.10) + activemodel (>= 5.1, < 8.2, != 7.0.0) concurrent-ruby (>= 1.0.5, < 2.0) mongo (>= 2.18.0, < 3.0.0) - ruby2_keywords (~> 0.0.5) msgpack (1.8.0) - net-imap (0.6.2) + net-imap (0.6.3) date net-protocol net-pop (0.1.2) @@ -271,8 +279,9 @@ GEM net-smtp (0.5.1) net-protocol nio4r (2.7.5) - nokogiri (1.19.0) - mini_portile2 (~> 2.8.2) + nokogiri (1.19.1-arm64-darwin) + racc (~> 1.4) + nokogiri (1.19.1-x86_64-linux-gnu) racc (~> 1.4) ox (2.14.23) bigdecimal (>= 3.0) @@ -287,9 +296,9 @@ GEM pry (0.15.2) coderay (~> 1.1) method_source (~> 1.0) - pry-byebug (3.11.0) - byebug (~> 12.0) - pry (>= 0.13, < 0.16) + pry-byebug (3.12.0) + byebug (~> 13.0) + pry (>= 0.13, < 0.17) psych (5.3.1) date stringio @@ -297,7 +306,7 @@ GEM puma (6.6.1) nio4r (~> 2.0) racc (1.8.1) - rack (3.2.4) + rack (3.2.5) rack-cors (3.0.0) logger rack (>= 3.0.14) @@ -308,20 +317,20 @@ GEM rack (>= 1.3) rackup (2.3.1) rack (>= 3) - rails (7.2.3) - actioncable (= 7.2.3) - actionmailbox (= 7.2.3) - actionmailer (= 7.2.3) - actionpack (= 7.2.3) - actiontext (= 7.2.3) - actionview (= 7.2.3) - activejob (= 7.2.3) - activemodel (= 7.2.3) - activerecord (= 7.2.3) - activestorage (= 7.2.3) - activesupport (= 7.2.3) + rails (8.1.2) + actioncable (= 8.1.2) + actionmailbox (= 8.1.2) + actionmailer (= 8.1.2) + actionpack (= 8.1.2) + actiontext (= 8.1.2) + actionview (= 8.1.2) + activejob (= 8.1.2) + activemodel (= 8.1.2) + activerecord (= 8.1.2) + activestorage (= 8.1.2) + activesupport (= 8.1.2) bundler (>= 1.15.0) - railties (= 7.2.3) + railties (= 8.1.2) rails-dom-testing (2.3.0) activesupport (>= 5.0.0) minitest @@ -329,10 +338,9 @@ GEM rails-html-sanitizer (1.6.2) loofah (~> 2.21) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) - railties (7.2.3) - actionpack (= 7.2.3) - activesupport (= 7.2.3) - cgi + railties (8.1.2) + actionpack (= 8.1.2) + activesupport (= 8.1.2) irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) @@ -368,15 +376,16 @@ GEM rspec-mocks (~> 3.13) rspec-support (~> 3.13) rspec-support (3.13.6) - rubocop (1.82.1) + rubocop (1.85.1) json (~> 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) + mcp (~> 0.6) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 2.9.3, < 3.0) - rubocop-ast (>= 1.48.0, < 2.0) + rubocop-ast (>= 1.49.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) rubocop-ast (1.49.0) @@ -388,7 +397,6 @@ GEM lint_roller (~> 1.1) rubocop (~> 1.81) ruby-progressbar (1.13.0) - ruby2_keywords (0.0.5) securerandom (0.4.1) shoulda-matchers (7.0.1) activesupport (>= 7.1) @@ -400,19 +408,19 @@ GEM shrine (>= 3.0.0.beta3, < 4) stringio (3.2.0) thor (1.5.0) - timeout (0.6.0) + timeout (0.6.1) tsort (0.2.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (3.2.0) unicode-emoji (~> 4.1) unicode-emoji (4.2.0) + uri (1.1.1) useragent (0.16.11) - web-console (4.2.1) - actionview (>= 6.0.0) - activemodel (>= 6.0.0) + web-console (4.3.0) + actionview (>= 8.0.0) bindex (>= 0.4.0) - railties (>= 6.0.0) + railties (>= 8.0.0) websocket-driver (0.8.0) base64 websocket-extensions (>= 0.1.0) @@ -421,14 +429,15 @@ GEM zeitwerk (2.7.4) PLATFORMS - ruby + arm64-darwin-25 + x86_64-linux DEPENDENCIES aws-sdk-s3 (~> 1.14) bootsnap (>= 1.4.2) byebug climate_control - database_cleaner (~> 1.7) + database_cleaner-mongoid (~> 2.0) dry-auto_inject (~> 0.6) dry-container (~> 0.7) dry-core (~> 0.4) @@ -442,15 +451,15 @@ DEPENDENCIES dry-transaction (~> 0.13) dry-types (~> 1.2) dry-validation (~> 1.2) - factory_bot_rails (~> 4.11) - fast_jsonapi - jwt (~> 2.2.1) + factory_bot_rails (~> 6.4) + jsonapi-serializer + jwt (~> 2.9) listen (~> 3.3) - mongoid (~> 8.1.5) + mongoid (~> 9.0) pry-byebug puma (~> 6.0) rack-cors - rails (~> 7.2.0) + rails (~> 8.1) resource_registry! rspec-rails (~> 7.0) rubocop @@ -462,7 +471,7 @@ DEPENDENCIES yard RUBY VERSION - ruby 3.2.5p208 + ruby 3.4.9p82 BUNDLED WITH 2.4.19 diff --git a/app/serializers/document_serializer.rb b/app/serializers/document_serializer.rb index 8a5895e..b71b967 100644 --- a/app/serializers/document_serializer.rb +++ b/app/serializers/document_serializer.rb @@ -2,7 +2,7 @@ # Serializes a represented document for JSON resource format. class DocumentSerializer - include FastJsonapi::ObjectSerializer + include JSONAPI::Serializer attributes :title, :creator, :identifier, :description, :language, :format, :source, :date, :creator diff --git a/config/application.rb b/config/application.rb index d327487..3c5c2e8 100644 --- a/config/application.rb +++ b/config/application.rb @@ -23,7 +23,7 @@ module App class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.1 + config.load_defaults 8.1 # Settings in config/environments/* take precedence over those specified here. # Application configuration can go into files in config/initializers diff --git a/config/mongoid.yml b/config/mongoid.yml index c76178b..d79d60f 100644 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -20,11 +20,11 @@ development: # to master. (default: primary) # read: secondary_preferred - # How many times Moped should attempt to retry an operation after + # How many times the driver should attempt to retry an operation after # failure. (default: The number of nodes in the cluster) # max_retries: 20 - # The time in seconds that Moped should wait before retrying an + # The time in seconds that the driver should wait before retrying an # operation on failure. (default: 0.25) # retry_interval: 0.25 @@ -77,20 +77,16 @@ production: default: database: cartafact_production hosts: - - <%= ENV['CARTAFACT_DB_HOST'] %>:<%= ENV['CARTAFACT_DB_PORT'] %> + - <%= ENV.fetch('CARTAFACT_DB_HOST', 'localhost') %>:<%= ENV.fetch('CARTAFACT_DB_PORT', '27017') %> options: - <% if ENV['CARTAFACT_DB_AUTH'] == true %> +<% if ENV['CARTAFACT_DB_AUTH'] == true %> replica_set: <%= ENV['CARTAFACT_DB_REPLICA_SET_NAME'] %> - user: <%= ENV['CARTAFACT_DB_USERNAME'] %> password: <%= ENV['CARTAFACT_DB_PASSWORD'] %> auth_source: admin - write: w: 1 j: true - <% end %> - # In the test environment we lower the retries and retry interval to - # low amounts for fast failures. +<% end %> max_retries: 1 retry_interval: 0 diff --git a/config/routes.rb b/config/routes.rb index c3f9696..9880e2f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,7 +5,7 @@ namespace :api do namespace :v1 do - resources :documents, only: [:index, :show, :create, :copy] do + resources :documents, only: [:index, :show, :create] do member do get :download get :copy diff --git a/docker-compose.yml b/docker-compose.yml index b7b9f69..450cd70 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,8 +6,8 @@ services: context: . dockerfile: ./.docker/development/Dockerfile args: - RUBY_VERSION: '3.2.5' - BUNDLER_VERSION: '2.4.19' + RUBY_VERSION: '3.4.9' + BUNDLER_VERSION: '2.6.9' image: cartafact-dev:0.1.0 volumes: - .:/app:cached @@ -27,7 +27,7 @@ services: - DB_PORT=${DB_PORT:-27017} db: - image: mongo:4.2 + image: mongo:5.0 volumes: - mongodb:/data/db - mongodb_config:/data/configdb diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index a4f0316..265cc75 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -63,10 +63,10 @@ config.filter_rails_from_backtrace! # arbitrary gems may also be filtered via: # config.filter_gems_from_backtrace("gem name") - DatabaseCleaner.strategy = :truncation + DatabaseCleaner[:mongoid].strategy = :deletion config.around(:each) do |example| - DatabaseCleaner.cleaning do + DatabaseCleaner[:mongoid].cleaning do example.run end end