diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cabc044..103d762 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,22 +6,22 @@ on: jobs: ci-rails-app: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: matrix: - ruby-version: ['3.0.3'] + ruby-version: ['3.2.2'] env: RAILS_ENV: test NOKOGIRI_USE_SYSTEM_LIBRARIES: true NLS_LANG: AMERICAN_AMERICA.US7ASCII steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 # Caching the solr download makes a huge difference. It can take up to 10 minutes to download. # Note that this action's caches will be evicted if not accessed for more than a week. - name: Cache Oracle Downloads id: cache-oracle-downloads - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: /opt/oracle/downloads key: ${{ runner.os }}-oracle-download diff --git a/.rubocop.yml b/.rubocop.yml index af8c095..b447e03 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,7 +4,7 @@ inherit_gem: inherit_from: .rubocop_todo.yml AllCops: - TargetRubyVersion: 3.0.3 + TargetRubyVersion: 3.2.2 TargetRailsVersion: 7.0 Exclude: - 'app/javascript/**/*' diff --git a/.ruby-version b/.ruby-version index c939cb5..9e79f6c 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-3.0.3 \ No newline at end of file +ruby-3.2.2 diff --git a/Capfile b/Capfile index 8079e0d..2a5fe4b 100644 --- a/Capfile +++ b/Capfile @@ -10,7 +10,6 @@ install_plugin Capistrano::SCM::Git # additional modules require 'capistrano/rails' -require 'capistrano/rvm' require 'capistrano/passenger' require 'capistrano/cul' require 'whenever/capistrano' diff --git a/Gemfile b/Gemfile index 2b86002..9d035cd 100644 --- a/Gemfile +++ b/Gemfile @@ -19,7 +19,7 @@ gem 'uglifier', '>= 1.3.0' # gem 'mini_racer', platforms: :ruby # Need to pin nokogiri to 1.10.x for now because we can't build 1.11 on our deploy VMs (because of incompatible GLIBC version) -gem 'nokogiri', '~> 1.10.10' +gem 'nokogiri', '~> 1.15.4' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.5' @@ -35,7 +35,10 @@ gem 'jbuilder', '~> 2.5' gem 'bootsnap', '>= 1.1.0', require: false # For z3950 -gem 'zoom', '0.5.0' +# gem 'zoom', '0.5.0' +# gem 'alexandria-zoom', '0.6.0' # Using this gem instead of regular 'zoom' because this PR has not been merged: https://github.com/bricestacey/ruby-zoom/pull/4 +gem 'alexandria-zoom', git: 'https://github.com/cul/cul-zoom.git', branch: 'yaz-config-fallback' +# gem 'alexandria-zoom', path: '../cul-zoom' # For MARC parsing (using fork until PR is merged into main project) gem 'marc', '1.0.4' # gem 'marc', path: '../ruby-marc' @@ -71,11 +74,10 @@ group :development do gem 'listen', '~> 3.3' # Capistrano gems for deployment - gem 'capistrano', '~> 3.17.0', require: false + gem 'capistrano', '~> 3.18.0', require: false gem 'capistrano-cul', require: false gem 'capistrano-passenger', '~> 0.1', require: false gem 'capistrano-rails', '~> 1.4', require: false - gem 'capistrano-rvm', '~> 0.1', require: false # Use net-ssh >= 4.2 to prevent warnings with Ruby 2.4 gem 'net-ssh', '>= 4.2' diff --git a/Gemfile.lock b/Gemfile.lock index a303a3a..1f2adbe 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,11 @@ +GIT + remote: https://github.com/cul/cul-zoom.git + revision: ef094e238aac2e6f5759240bd78fdf98b2f3f82b + branch: yaz-config-fallback + specs: + alexandria-zoom (0.6.0) + pkg-config (~> 1.5.1) + GEM remote: https://rubygems.org/ specs: @@ -68,16 +76,16 @@ GEM i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - airbrussh (1.4.0) + airbrussh (1.5.0) sshkit (>= 1.6.1, != 1.7.0) ast (2.4.2) bcrypt_pbkdf (1.1.0) bindex (0.8.1) - bootsnap (1.11.1) + bootsnap (1.16.0) msgpack (~> 1.2) builder (3.2.4) byebug (11.1.3) - capistrano (3.17.0) + capistrano (3.18.0) airbrussh (>= 1.0.0) i18n rake (>= 10.0.0) @@ -97,9 +105,6 @@ GEM capistrano-rails (1.6.2) capistrano (~> 3.1) capistrano-bundler (>= 1.1, < 3) - capistrano-rvm (0.1.2) - capistrano (~> 3.0) - sshkit (~> 1.2) chronic (0.10.2) concurrent-ruby (1.1.10) crass (1.0.6) @@ -109,7 +114,7 @@ GEM unf (>= 0.0.5, < 1.0.0) ed25519 (1.3.0) erubi (1.10.0) - execjs (2.8.1) + execjs (2.9.1) factory_bot (6.1.0) activesupport (>= 5.0.0) factory_bot_rails (6.1.0) @@ -144,9 +149,9 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2022.0105) mini_mime (1.1.2) - mini_portile2 (2.4.0) + mini_portile2 (2.8.5) minitest (5.15.0) - msgpack (1.5.1) + msgpack (1.7.2) net-imap (0.2.3) digest net-protocol @@ -157,22 +162,25 @@ GEM timeout net-protocol (0.1.3) timeout - net-scp (3.0.0) - net-ssh (>= 2.6.5, < 7.0.0) + net-scp (4.0.0) + net-ssh (>= 2.6.5, < 8.0.0) net-smtp (0.3.1) digest net-protocol timeout - net-ssh (6.1.0) + net-ssh (7.2.0) netrc (0.11.0) nio4r (2.5.8) - nokogiri (1.10.10) - mini_portile2 (~> 2.4.0) + nokogiri (1.15.4) + mini_portile2 (~> 2.8.2) + racc (~> 1.4) parallel (1.22.1) parser (3.1.1.0) ast (~> 2.4.1) + pkg-config (1.5.5) puma (5.6.2) nio4r (~> 2.0) + racc (1.7.1) rack (2.2.3) rack-test (1.1.0) rack (>= 1.0, < 3) @@ -265,7 +273,7 @@ GEM rubocop-performance rubocop-rails rubocop-rspec - ruby-oci8 (2.2.11) + ruby-oci8 (2.2.12) ruby-progressbar (1.11.0) rubyzip (2.3.2) sass (3.7.4) @@ -288,7 +296,7 @@ GEM activesupport (>= 5.2) sprockets (>= 3.0.0) sqlite3 (1.4.2) - sshkit (1.21.2) + sshkit (1.21.5) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) strscan (3.0.1) @@ -314,27 +322,26 @@ GEM whenever (1.0.0) chronic (>= 0.6.3) zeitwerk (2.5.4) - zoom (0.5.0) PLATFORMS ruby DEPENDENCIES activerecord-nulldb-adapter + alexandria-zoom! bootsnap (>= 1.1.0) byebug - capistrano (~> 3.17.0) + capistrano (~> 3.18.0) capistrano-cul capistrano-passenger (~> 0.1) capistrano-rails (~> 1.4) - capistrano-rvm (~> 0.1) factory_bot_rails (~> 6.1.0) io-wait (= 0.2.0) jbuilder (~> 2.5) listen (~> 3.3) marc (= 1.0.4) net-ssh (>= 4.2) - nokogiri (~> 1.10.10) + nokogiri (~> 1.15.4) puma (~> 5.2) rails (~> 7.0.2) rainbow (~> 3.0) @@ -352,7 +359,6 @@ DEPENDENCIES uglifier (>= 1.3.0) web-console (>= 3.3.0) whenever - zoom (= 0.5.0) BUNDLED WITH 2.3.9 diff --git a/README.md b/README.md index b9b6f8f..58bbb47 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,11 @@ This app depends on oci8; this requires installing the Oracle client libraries a Check out the ruby-oci8 repository for setup instructions: https://github.com/kubo/ruby-oci8 -Or if you want quick macOS setup instructions (which are hopefully still up to date by the time you're reading this, and still support Oracle 12.1) and you use homebrew, just run the following: +### For INTEL-ONLY** macOS + +(Hopefully this is still up to date by the time you're reading this, and still supports Oracle 12.1.) + +Use homebrew, just run the following: ``` brew tap InstantClientTap/instantclient @@ -28,6 +32,40 @@ And then add this environment variable to your bash/zsh profile: export OCI_DIR=$(brew --prefix)/lib ``` +# For ARM-based Macs + +Unfortunately, Oracle doesn't currently offer a release of the above libraries that are compatible with ARM-based Macs. As an alternative, you can run an Ubuntu 22 VM and download the following files: + +https://download.oracle.com/otn_software/linux/instantclient/instantclient-basic-linux-arm64.zip +https://download.oracle.com/otn_software/linux/instantclient/instantclient-sdk-linux-arm64.zip +https://download.oracle.com/otn_software/linux/instantclient/instantclient-sqlplus-linux-arm64.zip + +Save them in a new directory at `/opt/oracle/downloads` and then cd to `/opt/oracle` and unzip them: + +``` +cd /opt/oracle +find ./downloads -name '*.zip' -exec unzip {} \; +``` + +Then add this to your .bash_profile: +``` +# For oci8 gem (connecting to Oracle DB) +export OCI_DIR=/opt/oracle/instantclient_19_19 +export NLS_LANG='AMERICAN_AMERICA.US7ASCII' +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/oracle/instantclient_19_19 +``` + +When you run `bundle install`, you might encounter an issue with OpenSSL on Ubuntu 22. The problem is that Ubuntu 22 comes with OpenSSL 3, but Ruby 3.0 expects OpenSSL 1. You can fix this by uninstalling and reinstalling Ruby 3.0, but specifying OpenSSL 1: + +``` +rvm pkg install openssl # Use RVM to install OpenSSL 1 +rvm install ruby-3.0.3 --with-openssl-dir=$HOME/.rvm/usr # Point to RVM-installed OpenSSL 1 +``` + +If you have bundle install issues related to bootsnap, you may need to install a JS runtime. One way to fix this is to install nvm and then install Node 12. + +### NLS_LANG setup + **Important note:** When connecting to the Voyager OPAC, you must set environment variable `NLS_LANG` to `'AMERICAN_AMERICA.US7ASCII'`. The best way to do this is by adding an export to your `.bashrc`/`.zshrc` file: `export NLS_LANG='AMERICAN_AMERICA.US7ASCII'` To verify that NLS_LANG is set properly and being picked up by the OCI8 gem for all connections, you can run the `hysync:check_oci8_encoding` rake task. If set correctly, you should see the following output: @@ -40,8 +78,14 @@ OCI8 encoding is: # This app also depends on yaz, a Z39.50 client library. You can install it via homebrew by running: ``` - brew install yaz - ``` +brew install yaz +``` + +Or using apt on Ubuntu 22: + +``` +apt install yaz libyazpp-dev +``` ## Deployment instructions The deployment is standard CUL deployment via capistrano. diff --git a/VERSION b/VERSION index 63ebd3f..dc1e644 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.5.4 \ No newline at end of file +1.6.0 diff --git a/config/deploy.rb b/config/deploy.rb index 50fba2d..9073ef0 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -1,53 +1,74 @@ # config valid for current version and patch releases of Capistrano -lock "~> 3.17.0" +lock "~> 3.18.0" -set :department, 'ldpd' -set :instance, fetch(:department) +# Until we retire all old CentOS VMs, we need to set the rvm_custom_path because rvm is installed +# in a non-standard location for our AlmaLinux VMs. This is because our service accounts need to +# maintain two rvm installations for two different Linux OS versions. +set :rvm_custom_path, '~/.rvm-alma8' + +set :remote_user, 'renserv' set :application, 'hysync' -set :repo_name, "#{fetch(:department)}-#{fetch(:application)}" +set :repo_name, "ldpd-#{fetch(:application)}" +set :repo_url, "git@github.com:cul/#{fetch(:repo_name)}.git" set :deploy_name, "#{fetch(:application)}_#{fetch(:stage)}" # used to run rake db:migrate, etc -# Default value for :rails_env is fetch(:stage) set :rails_env, fetch(:deploy_name) -# use the rvm wrapper -set :rvm_ruby_version, fetch(:deploy_name) - -set :repo_url, "git@github.com:cul/#{fetch(:repo_name)}.git" -set :remote_user, "#{fetch(:instance)}serv" # Default deploy_to directory is /var/www/:application -# set :deploy_to, '/var/www/my_app_name' -set :deploy_to, "/opt/passenger/#{fetch(:instance)}/#{fetch(:deploy_name)}" +set :deploy_to, "/opt/passenger/#{fetch(:deploy_name)}" -# Default value for :scm is :git -# set :scm, :git - -# Default value for :format is :pretty -# set :format, :pretty - -# Default value for :log_level is :debug -# set :log_level, :debug -set :log_level, :info +set :linked_files, fetch(:linked_files, []).push( + 'config/master.key', + 'config/database.yml', + 'config/hysync.yml', + 'config/hyacinth.yml', + 'config/voyager.yml' +) # Default value for linked_dirs is [] set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids') +set :passenger_restart_with_touch, true + # Default value for keep_releases is 5 set :keep_releases, 3 -set :passenger_restart_with_touch, true +# Set default log level (which can be overridden by other environments) +set :log_level, :info -set :linked_files, fetch(:linked_files, []).push( - 'config/master.key', - 'config/database.yml', - 'config/hysync.yml', - 'config/hyacinth.yml', - 'config/voyager.yml' -) +# RVM Setup, for selecting the correct ruby version (instead of capistrano-rvm gem) +set :rvm_ruby_version, fetch(:deploy_name) +[:rake, :gem, :bundle, :ruby].each do |command_to_prefix| + SSHKit.config.command_map.prefix[command_to_prefix].push( + "#{fetch(:rvm_custom_path, '~/.rvm')}/bin/rvm #{fetch(:rvm_ruby_version)} do" + ) +end # Whenever gem set :whenever_identifier, ->{ "#{fetch(:application)}_#{fetch(:stage)}" } +# Default branch is :master +# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp + +# Default value for :scm is :git +# set :scm, :git + +# Default value for :format is :airbrussh +# set :format, :airbrussh + +# You can configure the Airbrussh format using :format_options. +# These are the defaults. +# set :format_options, command_output: true, log_file: "log/capistrano.log", color: :auto, truncate: :auto + +# Default value for :pty is false +# set :pty, true + +# Default value for local_user is ENV['USER'] +# set :local_user, -> { `git config user.name`.chomp } + +# Uncomment the following to require manually verifying the host key before first deploy. +# set :ssh_options, verify_host_key: :secure + namespace :deploy do desc "Report the environment" task :report do diff --git a/config/deploy/dev.rb b/config/deploy/dev.rb index b4a2b72..a257b70 100644 --- a/config/deploy/dev.rb +++ b/config/deploy/dev.rb @@ -1,3 +1,3 @@ -server 'all-nginx-dev1.cul.columbia.edu', user: fetch(:remote_user), roles: %w(app db web) +server 'diglib-rails-dev1.cul.columbia.edu', user: fetch(:remote_user), roles: %w(app db web) # Current branch is suggested by default in development ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp diff --git a/config/deploy/prod.rb b/config/deploy/prod.rb index ec7c66c..b7534ad 100644 --- a/config/deploy/prod.rb +++ b/config/deploy/prod.rb @@ -1,3 +1,3 @@ -server "#{fetch(:instance)}-nginx-#{fetch(:stage)}1.cul.columbia.edu", user: fetch(:remote_user), roles: %w(app db web) +server 'diglib-rails-prod1.cul.columbia.edu', user: fetch(:remote_user), roles: %w(app db web) # In test/prod, deploy from release tags; most recent version is default ask :branch, proc { `git tag --sort=version:refname`.split("\n").last } diff --git a/config/deploy/test.rb b/config/deploy/test.rb index ec7c66c..5b5f734 100644 --- a/config/deploy/test.rb +++ b/config/deploy/test.rb @@ -1,3 +1,3 @@ -server "#{fetch(:instance)}-nginx-#{fetch(:stage)}1.cul.columbia.edu", user: fetch(:remote_user), roles: %w(app db web) +server 'diglib-rails-test1.cul.columbia.edu', user: fetch(:remote_user), roles: %w(app db web) # In test/prod, deploy from release tags; most recent version is default ask :branch, proc { `git tag --sort=version:refname`.split("\n").last } diff --git a/lib/hysync/marc_synchronizer/runner.rb b/lib/hysync/marc_synchronizer/runner.rb index d916d20..5526930 100644 --- a/lib/hysync/marc_synchronizer/runner.rb +++ b/lib/hysync/marc_synchronizer/runner.rb @@ -162,7 +162,7 @@ def create_or_update_hyacinth_record(marc_record, base_digital_object_data, forc Rails.logger.error msg end - return @errors.blank?, @errors + [@errors.blank?, @errors] end # If given hyacinth_record marc_005_last_modified value is equal to given marc_record 005 diff --git a/lib/voyager/client.rb b/lib/voyager/client.rb index 0b0eca7..d1d30d6 100644 --- a/lib/voyager/client.rb +++ b/lib/voyager/client.rb @@ -1,3 +1,5 @@ +require 'zoom' + module Voyager class Client include Voyager::ClientBehavior::OracleQueryBehavior