diff --git a/.github/workflows/build-test-lint.yaml b/.github/workflows/build-test-lint.yaml index 2bdf3c6..998e948 100644 --- a/.github/workflows/build-test-lint.yaml +++ b/.github/workflows/build-test-lint.yaml @@ -17,7 +17,7 @@ on: jobs: build: - uses: scientist-softserv/actions/.github/workflows/build.yaml@v0.0.15 + uses: scientist-softserv/actions/.github/workflows/build.yaml@v0.0.18 secrets: inherit with: platforms: 'linux/amd64' @@ -26,7 +26,7 @@ jobs: test: needs: build - uses: scientist-softserv/actions/.github/workflows/test.yaml@v0.0.15 + uses: scientist-softserv/actions/.github/workflows/test.yaml@v0.0.18 with: confdir: '/app/samvera/hyrax-webapp/solr/conf' webTarget: hyku-web @@ -35,7 +35,7 @@ jobs: lint: needs: build - uses: scientist-softserv/actions/.github/workflows/lint.yaml@v0.0.15 + uses: scientist-softserv/actions/.github/workflows/lint.yaml@v0.0.18 with: webTarget: hyku-web workerTarget: hyku-worker diff --git a/.gitignore b/.gitignore index e00f97c..fbf5d9b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ scratch.md .DS_Store /coverage +file_cache/ diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..2c1a663 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,78 @@ +inherit_gem: + bixby: bixby_default.yml + +AllCops: + NewCops: disable + TargetRubyVersion: 3.2.2 + DisplayCopNames: true + Exclude: + # NOTE: When we run knapsack's rubocop, we don't want to check the submodule + # for Hyku. We'll assume it's okay and has it's own policing policies. + - "hyrax-webapp/**/*" + +Metrics/BlockLength: + IgnoredMethods: ['included', 'describe', 'it', 'context'] + Exclude: + - "spec/**/*.rb" + +Style/AsciiComments: + Enabled: false + +# rubocop suggests !thing.nil? instead, but that is NOT equivalent +Style/DoubleNegation: + Enabled: false + +Style/CollectionMethods: + PreferredMethods: + collect: 'map' + collect!: 'map!' + inject: 'reduce' + detect: 'find' + find_all: 'select' + +Style/SymbolArray: + Enabled: false + +Style/ClassAndModuleChildren: + Enabled: false + +Style/SingleLineBlockParams: + Enabled: false + +Rails/ApplicationJob: + Enabled: false + +Rails/ApplicationMailer: + Enabled: false + +Rails/ApplicationRecord: + Enabled: false + +Rails/RakeEnvironment: + Enabled: false + +# We define custom methods like `find_by_user_key`, +# `find_by_created_date`, etc +Rails/DynamicFindBy: + Enabled: false + +# # By default RSpec/MessageSpies has the following: +# # Prefer have_received for setting message expectations. Setup form as a spy using allow or instance_spy. +# # The default assumes EnforcedStyle is 'have_received'. Most of our specs are 'receive' +RSpec/MessageSpies: + Enabled: false + +RSpec/ExpectActual: + Enabled: false + +RSpec/LetSetup: + Enabled: false + +RSpec/MessageExpectation: + Enabled: false + +RSpec/NestedGroups: + Enabled: false + +RSpec/LeadingSubject: + Enabled: false diff --git a/Dockerfile b/Dockerfile index 9cb9e52..54ace04 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,8 @@ COPY --chown=1001:101 . /app/samvera ENV BUNDLE_LOCAL__HYKU_KNAPSACK=/app/samvera ENV BUNDLE_DISABLE_LOCAL_BRANCH_CHECK=true +RUN bundle install --jobs "$(nproc)" + # Ensure root permissions for installing Tesseract data USER root diff --git a/Rakefile b/Rakefile index 8577623..d6deb3b 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "bundler/setup" load "rails/tasks/statistics.rake" diff --git a/bin/rails b/bin/rails index 0739660..15d6bce 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,6 @@ #!/usr/bin/env ruby + +# frozen_string_literal: true APP_PATH = File.expand_path('../config/application', __dir__) require_relative '../config/boot' require 'rails/commands' diff --git a/bundler.d/example.rb b/bundler.d/example.rb index 05862d1..6b9acc1 100644 --- a/bundler.d/example.rb +++ b/bundler.d/example.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # see https://github.com/kbrock/bundler-inject/tree/gem_path # specify one or more ruby files in this directory to be injected into bundler diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb new file mode 100644 index 0000000..06ccf6f --- /dev/null +++ b/config/initializers/sentry.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'sentry-ruby' +require 'sentry-sidekiq' + +Sentry.init do |config| + config.dsn = ENV['SENTRY_DSN'] + config.breadcrumbs_logger = [:active_support_logger, :http_logger, :sentry_logger] + # example: + # config.enabled_environments = %w[hykuup-knapsack-staging hykuup-knapsack-production] + config.enabled_environments = %w[] + config.debug = true +end diff --git a/config/routes.rb b/config/routes.rb index 648092a..30a6e9e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,2 +1,3 @@ +# frozen_string_literal: true HykuKnapsack::Engine.routes.draw do end diff --git a/db-migrate-seed.sh b/db-migrate-seed.sh index eeecf94..6e8b081 100755 --- a/db-migrate-seed.sh +++ b/db-migrate-seed.sh @@ -10,6 +10,7 @@ db-wait.sh "$SOLR_HOST:$SOLR_PORT" migrations_run=`PGPASSWORD=$DB_PASSWORD psql -h $DB_HOST -U $DB_USER $DB_NAME -t -c "SELECT version FROM schema_migrations ORDER BY schema_migrations" | wc -c` migrations_fs=`ls -l db/migrate/ | awk '{print $9}' | grep -o '[0-9]\+' | wc -c` if [[ "$migrations_run" -lt "$migrations_fs" ]]; then + bundle bundle exec rails db:create bundle exec rails db:migrate bundle exec rails db:seed diff --git a/hyku_knapsack.gemspec b/hyku_knapsack.gemspec index ffc994a..4d272de 100644 --- a/hyku_knapsack.gemspec +++ b/hyku_knapsack.gemspec @@ -25,4 +25,7 @@ Gem::Specification.new do |spec| end spec.add_dependency "rails", ">= 5.2.0" + spec.add_dependency "sentry-ruby" + spec.add_dependency "sentry-rails" + spec.add_dependency "sentry-sidekiq" end diff --git a/hyrax-webapp b/hyrax-webapp index 4717a5b..ca49a19 160000 --- a/hyrax-webapp +++ b/hyrax-webapp @@ -1 +1 @@ -Subproject commit 4717a5b576cdbc87ab000345465a8da4cf4774a8 +Subproject commit ca49a195cea73034ffa3da0434f772d591450d35 diff --git a/lib/hyku_knapsack.rb b/lib/hyku_knapsack.rb index bc57770..c6255d4 100644 --- a/lib/hyku_knapsack.rb +++ b/lib/hyku_knapsack.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "hyku_knapsack/version" require "hyku_knapsack/engine" diff --git a/lib/hyku_knapsack/engine.rb b/lib/hyku_knapsack/engine.rb index 1452de4..d73eb3f 100644 --- a/lib/hyku_knapsack/engine.rb +++ b/lib/hyku_knapsack/engine.rb @@ -32,7 +32,7 @@ def self.load_translations! config.before_initialize do config.i18n.load_path += Dir["#{config.root}/config/locales/**/*.yml"] - #if Hyku::Application.respond_to?(:user_devise_parameters=) + # if Hyku::Application.respond_to?(:user_devise_parameters=) # Hyku::Application.user_devise_parameters = %i[ # database_authenticatable # invitable @@ -42,7 +42,7 @@ def self.load_translations! # validatable # omniauthable # ] - #end + # end end config.after_initialize do @@ -54,13 +54,7 @@ def self.load_translations! Rails.configuration.cache_classes ? require(c) : load(c) end - # By default plain text files are not processed for text extraction. In adding - # Adventist::TextFileTextExtractionService to the beginning of the services array we are - # enabling text extraction from plain text files. - # - # https://github.com/scientist-softserv/adventist-dl/blob/97bd05946345926b2b6c706bd90e183a9d78e8ef/config/application.rb#L68-L73 Hyrax::DerivativeService.services = [ - # Adventist::TextFileTextExtractionService, IiifPrint::PluggableDerivativeService ] diff --git a/ops/staging-deploy.tmpl.yaml b/ops/staging-deploy.tmpl.yaml index 0921062..7226ce7 100644 --- a/ops/staging-deploy.tmpl.yaml +++ b/ops/staging-deploy.tmpl.yaml @@ -1,16 +1,24 @@ replicaCount: 2 +resources: + limits: + memory: "4Gi" + cpu: "500m" + requests: + memory: "2Gi" + cpu: "250m" + livenessProbe: enabled: false readinessProbe: enabled: false brandingVolume: - storageClass: aws-efs + storageClass: efs-sc derivativesVolume: - storageClass: aws-efs + storageClass: efs-sc uploadsVolume: - storageClass: aws-efs + storageClass: efs-sc size: 200Gi imagePullSecrets: @@ -32,6 +40,9 @@ extraVolumeMounts: &volMounts - name: uploads mountPath: /app/samvera/hyrax-webapp/tmp/network_files subPath: network-files + - name: uploads + mountPath: /app/samvera/hyrax-webapp/storage/files + subPath: storage-files ingress: enabled: true @@ -123,15 +134,19 @@ extraEnvVars: &envVars - name: HYRAX_ACTIVE_JOB_QUEUE value: sidekiq - name: HYRAX_ANALYTICS + value: "false" + - name: HYRAX_FITS_PATH + value: /app/fits/fits.sh + - name: HYRAX_VALKYRIE value: "true" - name: HYKU_BULKRAX_ENABLED value: "true" + - name: HYKU_BLOCK_VALKYRIE_REDIRECT + value: "false" - name: HYKU_CONTACT_EMAIL value: REPLACE_ME - name: HYKU_FILE_ACL value: "false" - - name: HYRAX_FITS_PATH - value: /app/fits/fits.sh - name: HYKU_ADMIN_HOST value: RPLACEME - name: HYKU_ADMIN_ONLY_TENANT_CREATION @@ -182,6 +197,8 @@ extraEnvVars: &envVars value: user@example.com - name: TEST_USER_PASSWORD value: testing123 + - name: VALKYRIE_ID_TYPE + value: string worker: replicaCount: 1 @@ -219,7 +236,7 @@ externalFcrepoHost: fcrepo.staging-fcrepo.svc.cluster.local externalPostgresql: host: pg-postgresql.staging-postgres.svc.cluster.local username: postgres - password: $POSTGRES_PASSWORD + password: $DB_PASSWORD externalSolrHost: solr.staging-solr.svc.cluster.local externalSolrUser: admin diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 7c92fd4..4323be0 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -5,14 +5,17 @@ ENV["RAILS_ENV"] ||= "test" # require File.expand_path('../config/environment', __dir__) -require File.expand_path("hyrax-webapp/config/environment", __dir__) +require Rails.root.join("config", "environment") # Prevent database truncation if the environment is production abort("The Rails environment is running in production mode!") if Rails.env.production? require "rspec/rails" # Add additional requires below this line. Rails is not loaded until this point! require "factory_bot_rails" -FactoryBot.definition_file_paths = [File.expand_path("spec/factories", HykuAddons::Engine.root)] -FactoryBot.find_definitions + +if defined?(HykuAddons) + FactoryBot.definition_file_paths = [File.expand_path("spec/factories", HykuAddons::Engine.root)] + FactoryBot.find_definitions +end # Requires supporting ruby files with custom matchers and macros, etc, in # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are @@ -39,5 +42,5 @@ # TODO is this needed? config.include HykuKnapsack::Engine.routes.url_helpers - ## End override + # End override end