Skip to content

Commit

Permalink
Merge pull request #553 from samvera/ruby3
Browse files Browse the repository at this point in the history
Test with ruby 3
  • Loading branch information
cjcolvar authored Jan 27, 2023
2 parents 1194849 + 9c62aa7 commit 71cc636
Show file tree
Hide file tree
Showing 13 changed files with 114 additions and 29 deletions.
92 changes: 79 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
default: '~> 7'
bundler_version:
type: string
default: 1.17.3
default: 2.4.5
rails_version:
type: string
solr_port:
Expand Down Expand Up @@ -69,14 +69,50 @@ jobs:
workflows:
ci:
jobs:
- bundle_and_test:
name: "ruby3-2_rails7.0"
ruby_version: 3.2.0
rails_version: 7.0.4.1
- bundle_and_test:
name: "ruby3-1_rails7.0"
ruby_version: 3.1.3
rails_version: 7.0.4.1
- bundle_and_test:
name: "ruby3-0_rails7.0"
ruby_version: 3.0.5
rails_version: 7.0.4.1
- bundle_and_test:
name: "ruby3-2_rails6.1"
ruby_version: 3.2.0
rails_version: 6.1.7.1
- bundle_and_test:
name: "ruby3-1_rails6.1"
ruby_version: 3.1.3
rails_version: 6.1.7.1
- bundle_and_test:
name: "ruby3-0_rails6.1"
ruby_version: 3.0.5
rails_version: 6.1.7.1
- bundle_and_test:
name: "ruby2-7_rails6.1"
ruby_version: 2.7.6
rails_version: 6.1.6.1
rails_version: 6.1.7.1
- bundle_and_test:
name: "ruby3-2_rails6.0"
ruby_version: 3.2.0
rails_version: 6.0.6.1
- bundle_and_test:
name: "ruby3-1_rails6.0"
ruby_version: 3.1.3
rails_version: 6.0.6.1
- bundle_and_test:
name: "ruby3-0_rails6.0"
ruby_version: 3.0.5
rails_version: 6.1.7.1
- bundle_and_test:
name: "ruby2-7_rails6.0"
ruby_version: 2.7.6
rails_version: 6.0.5.1
rails_version: 6.0.6.1
- bundle_and_test:
name: "ruby2-7_rails5.2"
ruby_version: 2.7.6
Expand All @@ -86,10 +122,7 @@ workflows:
blacklight_version: 6.23.0
ruby_version: 2.7.6
rails_version: 5.2.8.1
- bundle_and_test:
name: "ruby2-6_rails5.2"
ruby_version: 2.6.10
rails_version: 5.2.8.1

nightly:
triggers:
- schedule:
Expand All @@ -98,15 +131,52 @@ workflows:
branches:
only:
- main

jobs:
- bundle_and_test:
name: "ruby3-2_rails7.0"
ruby_version: 3.2.0
rails_version: 7.0.4.1
- bundle_and_test:
name: "ruby3-1_rails7.0"
ruby_version: 3.1.3
rails_version: 7.0.4.1
- bundle_and_test:
name: "ruby3-0_rails7.0"
ruby_version: 3.0.5
rails_version: 7.0.4.1
- bundle_and_test:
name: "ruby3-2_rails6.1"
ruby_version: 3.2.0
rails_version: 6.1.7.1
- bundle_and_test:
name: "ruby3-1_rails6.1"
ruby_version: 3.1.3
rails_version: 6.1.7.1
- bundle_and_test:
name: "ruby3-0_rails6.1"
ruby_version: 3.0.5
rails_version: 6.1.7.1
- bundle_and_test:
name: "ruby2-7_rails6.1"
ruby_version: 2.7.6
rails_version: 6.1.6.1
rails_version: 6.1.7.1
- bundle_and_test:
name: "ruby3-2_rails6.0"
ruby_version: 3.2.0
rails_version: 6.0.6.1
- bundle_and_test:
name: "ruby3-1_rails6.0"
ruby_version: 3.1.3
rails_version: 6.0.6.1
- bundle_and_test:
name: "ruby3-0_rails6.0"
ruby_version: 3.0.5
rails_version: 6.1.7.1
- bundle_and_test:
name: "ruby2-7_rails6.0"
ruby_version: 2.7.6
rails_version: 6.0.5.1
rails_version: 6.0.6.1
- bundle_and_test:
name: "ruby2-7_rails5.2"
ruby_version: 2.7.6
Expand All @@ -116,7 +186,3 @@ workflows:
blacklight_version: 6.23.0
ruby_version: 2.7.6
rails_version: 5.2.8.1
- bundle_and_test:
name: "ruby2-6_rails5.2"
ruby_version: 2.6.10
rails_version: 5.2.8.1
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source "https://rubygems.org"

gem 'rspec-its'

# Specify gem dependencies in hydra-head.gemspec
gemspec

Expand Down Expand Up @@ -41,8 +42,13 @@ else
end
# END ENGINE_CART BLOCK

if !ENV['RAILS_VERSION'] || ENV['RAILS_VERSION'] =~ /^6.0/
gem 'psych', '< 4'
end

if !ENV['RAILS_VERSION'] || ENV['RAILS_VERSION'] =~ /^5/
gem 'rails-controller-testing'
gem 'psych', '< 4'
end

if ENV['ACTIVE_FEDORA_VERSION']
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ begin
require 'yard/rake/yardoc_task'
project_root = File.expand_path(".")
doc_destination = File.join(project_root, 'doc')
if !File.exists?(doc_destination)
if !File.exist?(doc_destination)
FileUtils.mkdir_p(doc_destination)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def validate_visibility_complies_with_embargo
end
if visibility != expected_visibility
failure_message << "visibility should be #{expected_visibility} but it is currently #{visibility}. Call embargo_visibility! on this object to repair."
self.errors[:embargo] << failure_message
self.errors.add(:embargo, failure_message)
return false
end
true
Expand Down Expand Up @@ -122,7 +122,7 @@ def validate_visibility_complies_with_lease
end
if visibility != expected_visibility
failure_message << "visibility should be #{expected_visibility} but it is currently #{visibility}. Call lease_visibility! on this object to repair."
self.errors[:lease] << failure_message
self.errors.add(:lease, failure_message)
return false
end
true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ def validate_each(record, attribute, value)
begin
if date = value.to_date
if date <= Date.today
record.errors[attribute] << "Must be a future date"
record.errors.add(attribute, "Must be a future date")
end
else
record.errors[attribute] << "Invalid Date Format"
record.errors.add(attribute, "Invalid Date Format")
end
rescue ArgumentError, NoMethodError
record.errors[attribute] << "Invalid Date Format"
record.errors.add(attribute, "Invalid Date Format")
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion hydra-access-controls/hydra-access-controls.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |gem|

gem.required_ruby_version = '>= 2.4'

gem.add_dependency 'activesupport', '>= 5.2', '< 7'
gem.add_dependency 'activesupport', '>= 5.2', '< 7.1'
gem.add_dependency 'active-fedora', '>= 10.0.0'
gem.add_dependency 'blacklight-access_controls', '~> 6.0'
gem.add_dependency 'cancancan', '>= 1.8', '< 4'
Expand Down
8 changes: 6 additions & 2 deletions hydra-access-controls/lib/hydra/ip_based_groups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@ def self.load_groups

file = File.join(Rails.root, filename)

unless File.exists?(file)
unless File.exist?(file)
raise "ip-range configuration file not found. Expected: #{file}."
end

begin
yml = YAML::load_file(file)
yml = if Psych::VERSION > '4.0'
YAML.safe_load(File.read(file), aliases: true)
else
YAML.safe_load(File.read(file), [], [], true)
end
rescue
raise("#{filename} was found, but could not be parsed.\n")
end
Expand Down
8 changes: 6 additions & 2 deletions hydra-access-controls/lib/hydra/role_mapper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def load_role_map
filename = 'config/role_map.yml'
file = File.join(Rails.root, filename)

unless File.exists?(file)
unless File.exist?(file)
raise "You are missing a role map configuration file: #{filename}. Have you run \"rails generate hydra:head\"?"
end

Expand All @@ -67,7 +67,11 @@ def load_role_map
end

begin
yml = YAML::load(erb)
yml = if Psych::VERSION > '4.0'
YAML.safe_load(erb, aliases: true)
else
YAML.safe_load(erb, [], [], true)
end
rescue
raise("#{filename} was found, but could not be parsed.\n")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def content_options
# @return [String] the filename
def file_name
fname = params[:filename] || file.original_name || (asset.respond_to?(:label) && asset.label) || file.id
fname = URI.unescape(fname) if Rails.version >= '6.0'
fname = CGI.unescape(fname) if Rails.version >= '6.0'
fname
end

Expand Down
2 changes: 1 addition & 1 deletion hydra-core/hydra-core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
gem.required_ruby_version = '>= 2.4'

gem.add_dependency 'hydra-access-controls', version
gem.add_dependency "railties", '>= 5.2', '< 7'
gem.add_dependency "railties", '>= 5.2', '< 7.1'

gem.add_development_dependency 'rails-controller-testing', '~> 1'
gem.add_development_dependency 'rspec-rails', '~> 4.0'
Expand Down
5 changes: 3 additions & 2 deletions hydra-core/lib/generators/hydra/head_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def create_configuration_files

def create_conneg_configuration
file_path = "config/initializers/mime_types.rb"
create_file file_path unless File.exist?(file_path)
append_to_file file_path do
"Mime::Type.register \"application/n-triples\", :nt\n" +
"Mime::Type.register \"application/ld+json\", :jsonld\n" +
Expand All @@ -79,7 +80,7 @@ def create_conneg_configuration

def inject_solr_document_conneg
file_path = "app/models/solr_document.rb"
if File.exists?(file_path)
if File.exist?(file_path)
inject_into_file file_path, :before => /end\Z/ do
"\n # Do content negotiation for AF models. \n" +
"\n use_extension( Hydra::ContentNegotiation )\n"
Expand All @@ -90,7 +91,7 @@ def inject_solr_document_conneg
# Add Hydra behaviors to the user model
def inject_hydra_user_behavior
file_path = "app/models/#{model_name.underscore}.rb"
if File.exists?(file_path)
if File.exist?(file_path)
inject_into_class file_path, model_name.classify do
" # Connects this user object to Hydra behaviors.\n" +
" include Hydra::User\n\n"
Expand Down
2 changes: 1 addition & 1 deletion hydra-head.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |s|

s.add_dependency 'hydra-access-controls', version
s.add_dependency 'hydra-core', version
s.add_dependency 'rails', '>= 5.2', '< 7'
s.add_dependency 'rails', '>= 5.2', '< 7.1'

s.add_development_dependency 'coveralls'
s.add_development_dependency 'engine_cart', '~> 2.3'
Expand Down
4 changes: 4 additions & 0 deletions spec/test_app_templates/Gemfile.extra
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ if ENV['ACTIVE_FEDORA_VERSION']
gem 'active-fedora', ENV['ACTIVE_FEDORA_VERSION']
end

if !ENV['RAILS_VERSION'] || ENV['RAILS_VERSION'] =~ /^6.0/ || ENV['RAILS_VERSION'] =~ /^5/
gem 'psych', '< 4'
end

if ENV['BLACKLIGHT_VERSION']
gem 'blacklight', ENV['BLACKLIGHT_VERSION']
end

0 comments on commit 71cc636

Please sign in to comment.