Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Green sirenia or bust! #6976

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e17e337
Convert Ldp::Gone to ObjectNotFoundError
dlpierce Oct 25, 2024
3ae878d
Use the real metadata adapter
dlpierce Nov 1, 2024
832e0aa
Ensure embargo/lease factory is using DateTime
dlpierce Nov 4, 2024
043a6d9
Avoid using << on frozen default array in specs
dlpierce Nov 4, 2024
54f0477
Sometimes the original file is not first in file_ids
dlpierce Nov 20, 2024
a26fa2d
Convert Ldp::NotFound to Valkyrie::Persistence::ObjectNotFoundError
dlpierce Nov 20, 2024
990e8b3
Fix specs stubbing Hyrax::TimeService with a string
dlpierce Nov 20, 2024
c808e0a
More date format spec fixes
dlpierce Nov 20, 2024
d372fa9
Limit rails versions to speed dependency resolution
dlpierce Nov 22, 2024
b32da53
Bump valkyrie, use main until new release
dlpierce Nov 22, 2024
40e5cc0
Unpin faraday, rdf 3.3.2 fixed the bug
dlpierce Nov 22, 2024
7a7b4ec
Add sirenia to Github Actions CI; Significant rework of docker compose
dlpierce Nov 22, 2024
6aea561
rubocop
dlpierce Nov 22, 2024
020fc94
Docker and GHA fixes
dlpierce Dec 2, 2024
20d138b
Relax class matcher strictness
dlpierce Dec 5, 2024
05efaac
Restore `rake assets:precompile` for javascript tests
dlpierce Dec 5, 2024
d0a3560
Publish deletion first to avoid encountering tombstones
dlpierce Dec 6, 2024
c53d55f
Use correct rails root
dlpierce Dec 6, 2024
8918bea
rubocop
dlpierce Dec 6, 2024
1c0c533
Convert custom queries added for statistics to solr
dlpierce Dec 6, 2024
c3b6eec
Optimize admin set list (also fixes sorting issues)
dlpierce Dec 6, 2024
1d72867
Sort the admin sets for real life
dlpierce Dec 9, 2024
f127690
:clean_repo for flaky specs
dlpierce Dec 10, 2024
b555c49
Bump valkyrie version
dlpierce Dec 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dassie/.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ANALYTICS_START_DATE=2021-08-21
BUNDLE_GEMFILE=Gemfile.dassie
BUNDLE_PATH=/app/bundle
CH12N_TOOL=fits_servlet
CHROME_HEADLESS_MODE=false
CHROME_HEADLESS_MODE=true
DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL=true
DATABASE_TEST_URL=postgresql://hyrax_user:hyrax_password@postgres/hyrax_test?pool=5
DATABASE_URL=postgresql://hyrax_user:hyrax_password@postgres/hyrax?pool=5
Expand Down
2 changes: 1 addition & 1 deletion .dassie/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ gem 'jbuilder', '~> 2.5'
gem 'jquery-rails'
gem 'pg', '~> 1.3'
gem 'puma'
gem 'rails', '~> 6.1'
gem 'rails', '~> 6.1', '>= 6.1.7.10'
gem 'riiif', '~> 2.1'
gem 'rsolr', '>= 1.0', '< 3'
gem 'sass-rails', '~> 6.0'
Expand Down
10 changes: 6 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ artifacts/*
coverage/*
chart/*

Gemfile.lock
.dassie/Gemfile.lock
.koppie/Gemfile.lock
Gemfile*lock
*/Gemfile*lock

node_modules/*

node_modules
*/node_modules
yarn.lock
*/yarn.lock
28 changes: 12 additions & 16 deletions .github/workflows/lint-build-test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'Lint Build Test'
run-name: Link Build Test of ${{ github.ref_name }} by @${{ github.actor }}
run-name: Lint Build Test of ${{ github.ref_name }} by @${{ github.actor }}
on:
push:
branches:
Expand Down Expand Up @@ -44,39 +44,35 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ci_test_app: [dassie,koppie]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and export
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
build-args: |
APP_PATH=.${{ matrix.ci_test_app }}
cache-from: type=gha
cache-to: type=gha, mode=max
context: .
target: hyrax-engine-dev
tags: samvera/${{ matrix.ci_test_app }}:latest,samvera/${{ matrix.ci_test_app }}:${{ github.sha }}
outputs: type=docker,dest=/tmp/${{ matrix.ci_test_app }}-${{ github.sha }}.tar
tags: samvera/hyrax-dev:latest,samvera/hyrax-dev:${{ github.sha }}
outputs: type=docker,dest=/tmp/hyrax-dev-${{ github.sha }}.tar
- name: Upload built image artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.ci_test_app }}-image
path: /tmp/${{ matrix.ci_test_app }}-${{ github.sha }}.tar
name: hyrax-dev
path: /tmp/hyrax-dev-${{ github.sha }}.tar

test:
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ci_test_app: [dassie,koppie]
ci_node_total: [8]
ci_node_index: [0,1,2,3,4,5,6,7]
ci_test_app: [dassie,koppie,sirenia]
ci_node_total: [4]
ci_node_index: [0,1,2,3]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -89,11 +85,11 @@ jobs:
- name: Download built image artifact
uses: actions/download-artifact@v4
with:
name: ${{ matrix.ci_test_app }}-image
name: hyrax-dev
path: /tmp
- name: Start containers
run: |
docker load --input /tmp/${{ matrix.ci_test_app }}-${{ github.sha }}.tar
docker load --input /tmp/hyrax-dev-${{ github.sha }}.tar
docker image ls -a
docker compose -f docker-compose-${{ matrix.ci_test_app }}.yml up -d --quiet-pull --pull missing --no-build
- name: RSpec
Expand All @@ -107,7 +103,7 @@ jobs:
if: always()
uses: jwalton/gh-docker-logs@v2
with:
images: 'seleniarm/standalone-chromium'
images: 'selenium/standalone-chromium,postgres,fcrepo/fcrepo,solr,bitnami/redis,ghcr.io/samvera/fitsservlet,ghcr.io/samvera/fcrepo4'
- name: Move Test Files
if: always()
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-results.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Test Results

run-name: Test Results of ${{ github.ref_name }} by @${{ github.actor }}
on:
workflow_run:
workflows: ["Lint Build Test"]
Expand Down
8 changes: 4 additions & 4 deletions .koppie/.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ APP_NAME=koppie
BUNDLE_GEMFILE=Gemfile.koppie
BUNDLE_PATH=/app/bundle
CH12N_TOOL=fits_servlet
CHROME_HEADLESS_MODE=false
CHROME_HEADLESS_MODE=true
DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL=true
DATABASE_TEST_URL=postgresql://hyrax_user:hyrax_password@postgres/hyrax_test?pool=5
DATABASE_URL=postgresql://hyrax_user:hyrax_password@postgres/hyrax?pool=5
Expand All @@ -14,9 +14,9 @@ DB_USERNAME=hyrax_user
FCREPO_URL=http://fedoraAdmin:fedoraAdmin@fcrepo:8080/fcrepo/rest
FITS_SERVLET_URL=http://fits:8080/fits
HUB_URL=http://chrome:4444/wd/hub
HYRAX_DERIVATIVES_PATH=/app/samvera/hyrax-webapp/derivatives/
HYRAX_DERIVATIVES_PATH=/app/samvera/hyrax-koppie/derivatives/
HYRAX_ENGINE_PATH=/app/samvera/hyrax-engine
HYRAX_UPLOAD_PATH=/app/samvera/hyrax-webapp/uploads/
HYRAX_UPLOAD_PATH=/app/samvera/hyrax-koppie/uploads/
HYRAX_VALKYRIE=true
IN_DOCKER=true
KARMA_BROWSER=remote-chromium
Expand All @@ -29,7 +29,7 @@ POSTGRES_PASSWORD=hyrax_password
POSTGRES_USER=hyrax_user
RACK_ENV=development
RAILS_ENV=development
RAILS_ROOT=.koppie
RAILS_ROOT=/app/samvera/hyrax-koppie
RAILS_LOG_TO_STDOUT=false
RAILS_QUEUE=sidekiq
REDIS_HOST=redis
Expand Down
2 changes: 1 addition & 1 deletion .koppie/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ gem 'jbuilder', '~> 2.5'
gem 'jquery-rails'
gem 'pg', '~> 1.3'
gem 'puma'
gem 'rails', '~> 6.1'
gem 'rails', '~> 6.1', '>= 6.1.7.10'
gem 'riiif', '~> 2.1'
gem 'rsolr', '>= 1.0', '< 3'
gem 'sass-rails', '~> 6.0'
Expand Down
9 changes: 0 additions & 9 deletions .koppie/scripts/db-migrate-seed.sh

This file was deleted.

10 changes: 0 additions & 10 deletions .koppie/scripts/entrypoint.sh

This file was deleted.

51 changes: 16 additions & 35 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG ALPINE_VERSION=3.19
ARG RUBY_VERSION=3.2.4
ARG RUBY_VERSION=3.2.6

FROM ruby:$RUBY_VERSION-alpine$ALPINE_VERSION as hyrax-base
FROM ruby:$RUBY_VERSION-alpine$ALPINE_VERSION AS hyrax-base

ARG DATABASE_APK_PACKAGE="postgresql-dev"
ARG EXTRA_APK_PACKAGES="git"
Expand Down Expand Up @@ -49,7 +49,7 @@ ENTRYPOINT ["hyrax-entrypoint.sh"]
CMD ["bundle", "exec", "puma", "-v", "-b", "tcp://0.0.0.0:3000"]


FROM hyrax-base as hyrax
FROM hyrax-base AS hyrax

ARG APP_PATH=.
ARG BUNDLE_WITHOUT="development test"
Expand All @@ -59,7 +59,7 @@ ONBUILD RUN bundle install --jobs "$(nproc)"
ONBUILD RUN RAILS_ENV=production SECRET_KEY_BASE=`bin/rake secret` DB_ADAPTER=nulldb DATABASE_URL='postgresql://fake' bundle exec rake assets:precompile


FROM hyrax-base as hyrax-worker-base
FROM hyrax-base AS hyrax-worker-base

USER root
RUN apk --no-cache add bash \
Expand All @@ -78,10 +78,10 @@ RUN mkdir -p /app/fits && \
sed -i 's/\(<tool.*TikaTool.*>\)/<!--\1-->/' /app/fits/xml/fits.xml
ENV PATH="${PATH}:/app/fits"

CMD bundle exec sidekiq
CMD ["bundle", "exec", "sidekiq"]


FROM hyrax-worker-base as hyrax-worker
FROM hyrax-worker-base AS hyrax-worker

ARG APP_PATH=.
ARG BUNDLE_WITHOUT="development test"
Expand All @@ -91,40 +91,21 @@ ONBUILD RUN bundle install --jobs "$(nproc)"
ONBUILD RUN RAILS_ENV=production SECRET_KEY_BASE=`bin/rake secret` DB_ADAPTER=nulldb DATABASE_URL='postgresql://fake' bundle exec rake assets:precompile


FROM hyrax-base as hyrax-engine-dev
FROM hyrax-worker-base AS hyrax-engine-dev

USER root
RUN apk --no-cache add bash \
ffmpeg \
mediainfo \
perl
USER app

ARG APP_PATH=.dassie
ARG BUNDLE_WITHOUT=
ENV HYRAX_ENGINE_PATH=/app/samvera/hyrax-engine

ENV HYRAX_ENGINE_PATH /app/samvera/hyrax-engine

COPY --chown=1001:101 $APP_PATH /app/samvera/hyrax-webapp
COPY --chown=1001:101 .dassie /app/samvera/hyrax-webapp
COPY --chown=1001:101 .koppie /app/samvera/hyrax-koppie
COPY --chown=1001:101 . /app/samvera/hyrax-engine

RUN bundle -v && \
bundle install --jobs "$(nproc)" && \
cd $HYRAX_ENGINE_PATH && \
bundle install --jobs "$(nproc)" && \
yarn && yarn cache clean

RUN RAILS_ENV=production SECRET_KEY_BASE='fakesecret1234' DB_ADAPTER=nulldb DATABASE_URL='postgresql://fake' bundle exec rake assets:precompile


FROM hyrax-worker-base as hyrax-engine-dev-worker

ARG APP_PATH=.dassie
ARG BUNDLE_WITHOUT=

ENV HYRAX_ENGINE_PATH /app/samvera/hyrax-engine

COPY --chown=1001:101 $APP_PATH /app/samvera/hyrax-webapp
COPY --chown=1001:101 . /app/samvera/hyrax-engine
BUNDLE_GEMFILE=Gemfile.dassie bundle install --jobs "$(nproc)" && yarn && \
cd ../hyrax-koppie && BUNDLE_GEMFILE=Gemfile.koppie bundle install --jobs "$(nproc)" && yarn && \
cd $HYRAX_ENGINE_PATH && bundle install --jobs "$(nproc)" && yarn && \
yarn cache clean

RUN bundle install --jobs "$(nproc)"
ENTRYPOINT ["dev-entrypoint.sh"]
CMD ["bundle", "exec", "puma", "-v", "-b", "tcp://0.0.0.0:3000"]
16 changes: 15 additions & 1 deletion app/controllers/hyrax/my/works_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,21 @@ def managed_works_count

def admin_sets_for_select
source_ids = Hyrax::Collections::PermissionsService.source_ids_for_deposit(ability: current_ability, source_type: 'admin_set')
source_ids.map { |admin_set_id| [Hyrax.query_service.find_by(id: admin_set_id).title.first, admin_set_id] }

admin_sets_list = Hyrax.query_service.find_many_by_ids(ids: source_ids).map do |source|
[source.title.first, source.id]
end

# Sorts the default admin set to be first, then the rest by title.
admin_sets_list.sort do |a, b|
if Hyrax::AdminSetCreateService.default_admin_set?(id: a[1])
-1
elsif Hyrax::AdminSetCreateService.default_admin_set?(id: b[1])
1
else
a[0] <=> b[0]
end
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/services/hyrax/custom_queries/find_access_control.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def find_access_control_for(resource:)
.find_inverse_references_by(resource: resource, property: :access_to)
.find { |r| r.is_a?(Hyrax::AccessControl) } ||
raise(Valkyrie::Persistence::ObjectNotFoundError)
rescue ArgumentError, Ldp::Gone # some adapters raise ArgumentError for missing resources
rescue ArgumentError, Ldp::Gone, Ldp::NotFound # some adapters raise ArgumentError for missing resources
raise(Valkyrie::Persistence::ObjectNotFoundError)
end
end
Expand Down
27 changes: 4 additions & 23 deletions app/services/hyrax/custom_queries/find_by_date_range.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,10 @@ def initialize(query_service:)
# @param start_datetime [DateTime]
# @param end_datetime [DateTime]
def find_by_date_range(start_datetime:, end_datetime: nil, models: nil)
end_datetime = 1.second.since(Time.zone.now) if end_datetime.blank?
if models.present?
query_service.run_query(find_models_by_date_range_query, start_datetime.to_s, end_datetime.to_s, models)
else
query_service.run_query(find_by_date_range_query, start_datetime.to_s, end_datetime.to_s)
end
end

def find_models_by_date_range_query
<<-SQL
SELECT * FROM orm_resources
WHERE created_at >= ?
AND created_at <= ?
AND internal_resource IN (?);
SQL
end

def find_by_date_range_query
<<-SQL
SELECT * FROM orm_resources
WHERE created_at >= ?
AND created_at <= ?;
SQL
end_range = end_datetime.blank? ? '*' : end_datetime.utc.xmlschema
args = "system_create_dtsi:[#{start_datetime.utc.xmlschema} TO #{end_range}]"
args += " AND has_model_ssim: (#{models.map { |m| "\"#{m}\"" }.join(' OR ')})" unless models.empty?
Hyrax::SolrService.query(args)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this change the flavor of thing returned? instead of models [Array] is it now SolrHit [Array]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this should be changed to return a model.

end
end
end
Expand Down
35 changes: 0 additions & 35 deletions app/services/hyrax/custom_queries/find_count_by.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,45 +25,10 @@ def initialize(query_service:)
# @param hash [Hash] the hash representation of the query
def find_count_by(hash = {}, models: nil)
return nil if models.empty? && hash.blank?
return find_count_by_af(hash, models: models) unless query_service.respond_to?(:orm_class)

internal_array = ["{ #{hash.map { |k, v| "\"#{k}\": #{v}" }.join(', ')} }"] if hash.present?
if models.empty?
query_service.orm_class.count_by_sql(([find_count_by_properties_query] + internal_array))
elsif hash.blank?
query_service.orm_class.count_by_sql([find_count_by_models_query] + [models])
else
query_service.orm_class.count_by_sql(([find_count_by_properties_and_models_query] + internal_array + [models]))
end
end

def find_count_by_af(hash, models: nil)
flat_hash = hash.map { |k, v| "#{k}: \"#{v}\"" }.join(' ')
flat_hash += " has_model_ssim: (#{models.map { |m| "\"#{m}\"" }.join(' OR ')})" unless models.empty?
Hyrax::SolrService.count(flat_hash)
end

def find_count_by_properties_and_models_query
<<-SQL
SELECT count(*) FROM orm_resources
WHERE metadata @> ?
AND internal_resource IN (?);
SQL
end

def find_count_by_models_query
<<-SQL
SELECT count(*) FROM orm_resources
WHERE internal_resource IN (?);
SQL
end

def find_count_by_properties_query
<<-SQL
SELECT count(*) FROM orm_resources
WHERE metadata @> ?;
SQL
end
end
end
end
Loading
Loading