Skip to content

Commit

Permalink
🎁 Contribute back from HykuUp Knapsack
Browse files Browse the repository at this point in the history
These files are what we changed in HykuUp Knapsack to get the build,
test, and lint workflows working.  Also, updating the Hyku submodule to
bring in the Valkyrie work.
  • Loading branch information
kirkkwang committed Apr 2, 2024
1 parent 0bdd510 commit 810f7f1
Show file tree
Hide file tree
Showing 16 changed files with 140 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-test-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:

jobs:
build:
uses: scientist-softserv/actions/.github/workflows/[email protected].15
uses: scientist-softserv/actions/.github/workflows/[email protected].18
secrets: inherit
with:
platforms: 'linux/amd64'
Expand All @@ -26,7 +26,7 @@ jobs:

test:
needs: build
uses: scientist-softserv/actions/.github/workflows/[email protected].15
uses: scientist-softserv/actions/.github/workflows/[email protected].18
with:
confdir: '/app/samvera/hyrax-webapp/solr/conf'
webTarget: hyku-web
Expand All @@ -35,7 +35,7 @@ jobs:

lint:
needs: build
uses: scientist-softserv/actions/.github/workflows/[email protected].15
uses: scientist-softserv/actions/.github/workflows/[email protected].18
with:
webTarget: hyku-web
workerTarget: hyku-worker
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ scratch.md
.DS_Store

/coverage
file_cache/
78 changes: 78 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "bundler/setup"

load "rails/tasks/statistics.rake"
Expand Down
2 changes: 2 additions & 0 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -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'
1 change: 1 addition & 0 deletions bundler.d/example.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 13 additions & 0 deletions config/initializers/sentry.rb
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# frozen_string_literal: true
HykuKnapsack::Engine.routes.draw do
end
1 change: 1 addition & 0 deletions db-migrate-seed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions hyku_knapsack.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion hyrax-webapp
Submodule hyrax-webapp updated 922 files
1 change: 1 addition & 0 deletions lib/hyku_knapsack.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "hyku_knapsack/version"
require "hyku_knapsack/engine"

Expand Down
10 changes: 2 additions & 8 deletions lib/hyku_knapsack/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -42,7 +42,7 @@ def self.load_translations!
# validatable
# omniauthable
# ]
#end
# end
end

config.after_initialize do
Expand All @@ -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
]

Expand Down
29 changes: 23 additions & 6 deletions ops/staging-deploy.tmpl.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -182,6 +197,8 @@ extraEnvVars: &envVars
value: [email protected]
- name: TEST_USER_PASSWORD
value: testing123
- name: VALKYRIE_ID_TYPE
value: string

worker:
replicaCount: 1
Expand Down Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -39,5 +42,5 @@
# TODO is this needed?
config.include HykuKnapsack::Engine.routes.url_helpers

## End override
# End override
end

0 comments on commit 810f7f1

Please sign in to comment.