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

upgrade to ruby 3.1.4 #38

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
ELASTIC_PASSWORD: ${{ secrets.RE3DATA_ES_PASSWORD }}
steps:
- uses: actions/checkout@v2
- name: Set up Ruby 2.7
- name: Set up Ruby 3.1.4
uses: actions/setup-ruby@v1
with:
ruby-version: '2.7.6'
ruby-version: '3.1.4'
- uses: actions/cache@v2
with:
path: vendor/bundle
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
- 11211/tcp
steps:
- uses: actions/checkout@v2
- name: Set up Ruby 2.7
- name: Set up Ruby 3.1.4
uses: actions/setup-ruby@v1
with:
ruby-version: '2.7.6'
ruby-version: '3.1.4'
- uses: actions/cache@v2
with:
path: vendor/bundle
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
ELASTIC_PASSWORD: ${{ secrets.RE3DATA_ES_PASSWORD }}
steps:
- uses: actions/checkout@v2
- name: Set up Ruby 2.7
- name: Set up Ruby 3.1.4
uses: actions/setup-ruby@v1
with:
ruby-version: '2.7.6'
ruby-version: '3.1.4'
- uses: actions/cache@v2
with:
path: vendor/bundle
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ inherit_from: .rubocop_todo.yml
# from https://github.com/rails/rails/blob/master/.rubocop.yml

AllCops:
TargetRubyVersion: 2.5
TargetRubyVersion: 3.1
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
# to ignore them, so only the ones explicitly set in this file are enabled.
DisabledByDefault: true
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM phusion/passenger-full:2.3.0
FROM phusion/passenger-full:2.5.1
LABEL maintainer="tech@datacite.org"

# Set correct environment variables.
Expand All @@ -10,8 +10,8 @@ RUN usermod -a -G docker_env app
# Use baseimage-docker's init process.
CMD ["/sbin/my_init"]

# Install Ruby 2.7.6
RUN bash -lc 'rvm --default use ruby-2.7.6'
# Install Ruby 3.1.4
RUN bash -lc 'rvm --default use ruby-3.1.4'

# Update installed APT packages
RUN apt-get update -y -o Dpkg::Options::="--force-confold" && \
Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ gem "dalli", "~> 2.7.6"
gem 'lograge', '~> 0.5'
gem 'sentry-raven', '~> 2.9'
gem 'active_model_serializers', '~> 0.10.0'
gem 'fast_jsonapi', '~> 1.3'
gem 'jsonapi-serializer', '~> 2.2'
gem 'kaminari', '~> 1.2'
gem 'elasticsearch', '~> 1.1', '>= 1.1.3'
gem 'elasticsearch-model', '~> 0.1.9', require: 'elasticsearch/model'
Expand Down Expand Up @@ -45,9 +45,9 @@ end
group :test do
gem 'capybara'
gem 'webmock', '~> 3.1'
gem 'vcr', '~> 3.0.3'
gem 'vcr', '~> 6.1'
gem 'codeclimate-test-reporter', '~> 1.0.0'
gem 'simplecov'
gem 'shoulda-matchers', '~> 3.1'
gem 'elasticsearch-extensions'
end
end
14 changes: 6 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ GEM
faraday
faraday_middleware (0.14.0)
faraday (>= 0.7.4, < 1.0)
fast_jsonapi (1.5)
activesupport (>= 4.2)
ffi (1.15.5)
git (1.12.0)
addressable (~> 2.8)
Expand All @@ -174,6 +172,8 @@ GEM
ice_nine (0.11.2)
json (2.6.2)
jsonapi-renderer (0.2.2)
jsonapi-serializer (2.2.0)
activesupport (>= 4.2)
kaminari (1.2.2)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.2)
Expand All @@ -186,10 +186,9 @@ GEM
activerecord
kaminari-core (= 1.2.2)
kaminari-core (1.2.2)
listen (3.1.5)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
lograge (0.12.0)
actionpack (>= 4)
activesupport (>= 4)
Expand Down Expand Up @@ -305,7 +304,6 @@ GEM
rubocop-performance (1.3.0)
rubocop (>= 0.68.0)
ruby-progressbar (1.11.0)
ruby_dep (1.5.0)
sentry-raven (2.13.0)
faraday (>= 0.7.6, < 1.0)
shoulda-matchers (3.1.3)
Expand Down Expand Up @@ -350,7 +348,7 @@ GEM
zeitwerk (2.6.0)

PLATFORMS
ruby
aarch64-linux

DEPENDENCIES
active_model_serializers (~> 0.10.0)
Expand All @@ -369,13 +367,13 @@ DEPENDENCIES
elasticsearch-model (~> 0.1.9)
elasticsearch-persistence (~> 0.1.9)
elasticsearch-rails (~> 0.1.9)
fast_jsonapi (~> 1.3)
git (~> 1.5)
google-protobuf (~> 3.0)
graphql (~> 1.9, >= 1.9.4)
graphql-batch (~> 0.4.0)
graphql-cache (~> 0.6.0)!
graphql-errors (~> 0.3.0)
jsonapi-serializer (~> 2.2)
kaminari (~> 1.2)
listen (>= 3.0.5, < 3.2)
lograge (~> 0.5)
Expand All @@ -395,4 +393,4 @@ DEPENDENCIES
webmock (~> 3.1)

BUNDLED WITH
2.3.20
2.3.20
14 changes: 7 additions & 7 deletions app/controllers/re3data_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def index
end

page = params[:page] || {}
if page[:size].present?
if page[:size].present?
page[:size] = [page[:size].to_i, 1000].min
max_number = page[:size] > 0 ? 10000/page[:size] : 1
else
Expand All @@ -26,11 +26,11 @@ def index
elsif params[:ids].present?
response = Repository.find_by_id(params[:ids], page: page, sort: sort)
else
response = Repository.query(params[:query],
page: page,
sort: sort,
response = Repository.query(params[:query],
page: page,
sort: sort,
subject: params[:subject],
open: params[:open],
open: params[:open],
certified: params[:certified],
pid: params[:pid],
software: params[:software],
Expand Down Expand Up @@ -59,7 +59,7 @@ def index
}.compact
options[:is_collection] = true

render json: Re3dataSerializer.new(@repositories, options).serialized_json, status: :ok
render json: Re3dataSerializer.new(@repositories, options).serializable_hash.to_json, status: :ok
rescue Elasticsearch::Transport::Transport::Errors::LengthRequired
render json: []
end
Expand All @@ -68,7 +68,7 @@ def show
options = {}
options[:is_collection] = false

render json: Re3dataSerializer.new(@repository, options).serialized_json, status: :ok
render json: Re3dataSerializer.new(@repository, options).serializable_hash.to_json, status: :ok
end

def suggest
Expand Down
8 changes: 4 additions & 4 deletions app/serializers/re3data_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
class Re3dataSerializer
include FastJsonapi::ObjectSerializer
include JSONAPI::Serializer
set_key_transform :camel_lower
set_type :re3data

attributes :re3data_id, :repositoryName, :repositoryUrl, :repositoryContacts, :description, :repositoryLanguages, :certificates, :types,
:additionalNames, :subjects, :contentTypes, :providerTypes,
attributes :re3data_id, :repositoryName, :repositoryUrl, :repositoryContacts, :description, :repositoryLanguages, :certificates, :types,
:additionalNames, :subjects, :contentTypes, :providerTypes,
:keywords, :institutions, :dataAccesses, :dataUploads, :dataUploadLicenses, :pidSystems,
:apis, :pidSystems, :software, :startDate, :endDate, :created, :updated

Expand All @@ -23,4 +23,4 @@ class Re3dataSerializer
attribute :updated do |object|
object.updated.strftime("%FT%TZ")
end
end
end
52 changes: 52 additions & 0 deletions config/initializers/serialization_core.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# frozen_string_literal: true

# Monkey patch for jsonapi-serializer gem

module FastJsonapi
module SerializationCore
class_methods do
def get_included_records(record, includes_list, known_included_objects, fieldsets, params = {})
return unless includes_list.present?
return [] unless relationships_to_serialize

includes_list = parse_includes_list(includes_list)

includes_list.each_with_object([]) do |include_item, included_records|
relationship_item = relationships_to_serialize[include_item.first]

next unless relationship_item&.include_relationship?(record, params)

associated_objects = relationship_item.fetch_associated_object(record, params)

if associated_objects.is_a?(Elasticsearch::Model::HashWrapper)
associated_objects = OpenStruct.new(associated_objects)
end

included_objects = Array(associated_objects)

next if included_objects.empty?

static_serializer = relationship_item.static_serializer
static_record_type = relationship_item.static_record_type

included_objects.each do |inc_obj|
serializer = static_serializer || relationship_item.serializer_for(inc_obj, params)
record_type = static_record_type || serializer.record_type

if include_item.last.any?
serializer_records = serializer.get_included_records(inc_obj, include_item.last, known_included_objects, fieldsets, params)
included_records.concat(serializer_records) unless serializer_records.empty?
end

code = "#{record_type}_#{serializer.id_from_record(inc_obj, params)}"
next if known_included_objects.include?(code)

known_included_objects << code

included_records << serializer.record_hash(inc_obj, fieldsets[record_type], includes_list, params)
end
end
end
end
end
end
5 changes: 5 additions & 0 deletions docker-compose.local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: "2.1"

services:
web:
build: .
Loading