From 6013f89b916a9a97729474ebd643a80952a41165 Mon Sep 17 00:00:00 2001 From: tamsin johnson Date: Wed, 23 Aug 2023 21:29:52 -0700 Subject: [PATCH] [semver-major] drop support for Ruby before 3.2 drop support for older rubies that we're no longer testing. --- .circleci/config.yml | 207 ------------------ .dassie/db/schema.rb | 17 +- app/services/hyrax/visibility_intention.rb | 5 +- .../hyrax/workflow/grant_edit_to_depositor.rb | 2 +- .../hyrax/workflow/grant_read_to_depositor.rb | 2 +- .../developing-your-hyrax-based-app.md | 2 +- hyrax.gemspec | 2 +- 7 files changed, 8 insertions(+), 229 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f08f245141..4e5488bcb2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -137,187 +137,6 @@ jobs: - ruby/rspec-test: app-dir: /app/samvera/hyrax-engine - bundle: - parameters: - ruby_version: - type: string - default: 2.7.8 - bundler_version: - type: string - default: 2.4.15 - rails_version: - type: string - default: 6.1.7.4 - executor: - name: 'samvera/ruby' - ruby_version: << parameters.ruby_version >> - resource_class: medium - environment: - RAILS_VERSION: << parameters.rails_version >> - NOKOGIRI_USE_SYSTEM_LIBRARIES: true - steps: - - samvera/cached_checkout - - - run: - name: Check for a branch named 'master' - command: | - git fetch --all --quiet --prune --prune-tags - if [[ -n "$(git branch --all --list master */master)" ]]; then - echo "A branch named 'master' was found. Please remove it." - echo "$(git branch --all --list master */master)" - fi - [[ -z "$(git branch --all --list master */master)" ]] - - - samvera/bundle: - ruby_version: << parameters.ruby_version >> - bundler_version: << parameters.bundler_version >> - - # Run rubocop in parallel with caching - # This should get added to the orb once proven here - - - restore_cache: - name: Restore rubocop cache - keys: - - v1-rubocop-ruby<< parameters.ruby_version >>-bundle{{ checksum "Gemfile.lock" }} - - v1-rubocop-ruby<< parameters.ruby_version >> - - v1 - - - run: - name: Run rubocop in parallel - command: bundle exec rubocop --parallel - - - save_cache: - name: Save rubocop cache - key: v1-rubocop-ruby<< parameters.ruby_version >>-bundle{{ checksum "Gemfile.lock" }} - paths: - - ~/.cache/rubocop_cache - - - persist_to_workspace: - root: ~/ - paths: - - project/* - - project/**/* - - build: - parameters: - ruby_version: - type: string - default: 2.7.8 - bundler_version: - type: string - default: 2.4.15 - rails_version: - type: string - default: 6.1.7.4 - executor: - name: 'samvera/ruby_fcrepo_solr_redis_postgres' - ruby_version: << parameters.ruby_version >> - solr_version: 8.11-slim - resource_class: medium - environment: - RAILS_VERSION: << parameters.rails_version >> - NOKOGIRI_USE_SYSTEM_LIBRARIES: true - ENGINE_CART_RAILS_OPTIONS: --database=postgresql --skip-git --skip-bundle --skip-listen --skip-spring --skip-keeps --skip-test --skip-bootsnap --skip-javascript - DATABASE_URL: postgresql://postgres@127.0.0.1/circle_test # Hard-coded with data from CircleCI orb, related to https://github.com/samvera-labs/samvera-circleci-orb/issues/42 - steps: - - attach_workspace: - at: ~/ - - samvera/engine_cart_generate: - cache_key: v1-internal-test-app-{{ checksum "hyrax.gemspec" }}-{{ checksum ".regen" }}-{{ checksum ".circleci/config.yml" }}-<< parameters.rails_version >>-<< parameters.ruby_version >> - - samvera/bundle: - ruby_version: << parameters.ruby_version >> - bundler_version: << parameters.bundler_version >> - - run: - name: Generate .internal_test_app/Gemfile.lock - command: bundle lock - working_directory: .internal_test_app - - ruby/install-deps: - app-dir: .internal_test_app - - node/install-packages: - pkg-manager: yarn - app-dir: .internal_test_app - - persist_to_workspace: - root: ~/ - paths: - - project/* - - project/**/* - - test: - parameters: - ruby_version: - type: string - default: 2.7.8 - bundler_version: - type: string - default: 2.4.15 - hyrax_valkyrie: - type: string - default: "false" - executor: - name: 'samvera/ruby_fcrepo_solr_redis_postgres' - ruby_version: << parameters.ruby_version >> - solr_version: 8.11-slim - resource_class: medium+ - parallelism: 10 - environment: - HYRAX_VALKYRIE: << parameters.hyrax_valkyrie >> - VALKYRIE_SOLR_PORT: 8985 - DATABASE_URL: postgresql://postgres@127.0.0.1/circle_test # Hard-coded with data from CircleCI orb, related to https://github.com/samvera-labs/samvera-circleci-orb/issues/42 - KARMA_BROWSER: ChromeHeadlessCustom - RAILS_ROOT: .internal_test_app - SPEC_OPTS: "" # Clear output conflicts between samvera orb executor and ruby orb rspec command - steps: - - attach_workspace: - at: ~/ - - run: - name: Install system dependencies - command: | - sudo apt-get update - sudo apt-get install imagemagick librsvg2-bin lsof - - browser-tools/install-chrome - - browser-tools/install-chromedriver - - run: - name: Check Chrome install - command: | - google-chrome --version - chromedriver --version - - restore_cache: - keys: - - engine-node-v1-{{ checksum "package.json" }} - # Call yarn directly for hyrax engine; node orb demands a lockfile to use caching - - run: - name: Yarn Install (engine) - command: yarn install - - save_cache: - key: engine-node-v1-{{ checksum "package.json" }} - paths: - - node_modules - - samvera/install_solr_core: - solr_config_path: .internal_test_app/solr/conf - - samvera/install_solr_core: - solr_config_path: .internal_test_app/solr/conf - core_name: hyrax-valkyrie-test - # Rerun bundler in case this is a different ruby version than bundle and build steps - - samvera/bundle: - ruby_version: << parameters.ruby_version >> - bundler_version: << parameters.bundler_version >> - # Ensure gems needed by the test app are installed - - ruby/install-deps: - app-dir: .internal_test_app - - node/install-packages: - pkg-manager: yarn - app-dir: .internal_test_app - - run: - command: bundle exec rake db:migrate - working_directory: .internal_test_app - - ruby/rspec-test - - store_artifacts: - path: Gemfile.lock - destination: engine-gemfile-lock - - store_artifacts: - path: .internal_test_app/Gemfile.lock - destination: webapp-gemfile-lock - workflows: version: 2 dassie: @@ -339,29 +158,3 @@ workflows: hyrax_valkyrie: "1" requires: - dassie-build - - ruby2-7: - jobs: - - bundle: - ruby_version: "2.7.8" - rails_version: "6.1.7.4" - bundler_version: "2.4.15" - - build: - ruby_version: "2.7.8" - rails_version: "6.1.7.4" - bundler_version: "2.4.15" - requires: - - bundle - - test: - name: "ruby2-7" - ruby_version: "2.7.8" - bundler_version: "2.4.15" - requires: - - build - - test: - name: "ruby2-7-valkyrie" - ruby_version: "2.7.8" - bundler_version: "2.4.15" - hyrax_valkyrie: "true" - requires: - - build diff --git a/.dassie/db/schema.rb b/.dassie/db/schema.rb index 368cd762fb..0a0abf2248 100644 --- a/.dassie/db/schema.rb +++ b/.dassie/db/schema.rb @@ -2,15 +2,15 @@ # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # -# This file is the source Rails uses to define your schema when running `rails -# db:schema:load`. When creating a new database, `rails db:schema:load` tends to +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to # be faster and is potentially less error prone than running all of your # migrations from scratch. Old migrations may fail to apply correctly if those # migrations use external dependencies or application code. # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2023_07_25_222727) do +ActiveRecord::Schema.define(version: 2021_11_30_181150) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -140,17 +140,6 @@ t.index ["machine_id"], name: "index_hyrax_collection_types_on_machine_id", unique: true end - create_table "hyrax_counter_metrics", force: :cascade do |t| - t.string "worktype" - t.string "resource_type" - t.integer "work_id" - t.date "date" - t.integer "total_item_investigations" - t.integer "total_item_requests" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - end - create_table "hyrax_default_administrative_set", force: :cascade do |t| t.string "default_admin_set_id", null: false t.datetime "created_at", null: false diff --git a/app/services/hyrax/visibility_intention.rb b/app/services/hyrax/visibility_intention.rb index 3340fb2d6c..6236400e02 100644 --- a/app/services/hyrax/visibility_intention.rb +++ b/app/services/hyrax/visibility_intention.rb @@ -86,10 +86,7 @@ def a_valid_date?(date) return true if date.is_a?(Date) return true if date.is_a?(Time) Date.parse(date) - # In Ruby 2.7.x, Date::Error descends from ArgumentError; Once - # we stop supporting pre-2.7, we can switch this to the more - # narrow Date::Error - rescue ArgumentError + rescue Date::Error false end end diff --git a/app/services/hyrax/workflow/grant_edit_to_depositor.rb b/app/services/hyrax/workflow/grant_edit_to_depositor.rb index fd07ddf24a..9da4023711 100644 --- a/app/services/hyrax/workflow/grant_edit_to_depositor.rb +++ b/app/services/hyrax/workflow/grant_edit_to_depositor.rb @@ -11,7 +11,7 @@ def self.call(target:, **) return true unless target.try(:depositor) model = target.try(:model) || target # get the model if target is a ChangeSet - model.edit_users = model.edit_users.to_a + Array.wrap(target.depositor) # += works in Ruby 2.6+ + model.edit_users += Array.wrap(target.depositor) model.try(:permission_manager)&.acl&.save # If there are a lot of members, granting access to each could take a diff --git a/app/services/hyrax/workflow/grant_read_to_depositor.rb b/app/services/hyrax/workflow/grant_read_to_depositor.rb index 793a418721..96d443526d 100644 --- a/app/services/hyrax/workflow/grant_read_to_depositor.rb +++ b/app/services/hyrax/workflow/grant_read_to_depositor.rb @@ -12,7 +12,7 @@ def self.call(target:, **) return true unless target.try(:depositor) model = target.try(:model) || target # get the model if target is a ChangeSet - model.read_users = model.read_users.to_a + Array.wrap(target.depositor) # += works in Ruby 2.6+ + model.read_users += Array.wrap(target.depositor) model.try(:permission_manager)&.acl&.save # If there are a lot of members, granting access to each could take a diff --git a/documentation/developing-your-hyrax-based-app.md b/documentation/developing-your-hyrax-based-app.md index ca1237c2bc..3e014ebd6b 100644 --- a/documentation/developing-your-hyrax-based-app.md +++ b/documentation/developing-your-hyrax-based-app.md @@ -95,7 +95,7 @@ Note here that the following commands assume you're setting up Hyrax in a develo First, you'll need a working Ruby installation. You can install this via your operating system's package manager -- you are likely to get farther with OSX, Linux, or UNIX than Windows but your mileage may vary -- but we recommend using a Ruby version manager such as [RVM](https://rvm.io/) or [rbenv](https://github.com/sstephenson/rbenv). -Hyrax supports Ruby 2.5, 2.6, and 2.7. When starting a new project, we recommend using the latest Ruby 2.7 version. +Hyrax supports Ruby 3.2. When starting a new project, we recommend using the latest Ruby 3.2 version. ## Redis diff --git a/hyrax.gemspec b/hyrax.gemspec index dffeda13c2..fb0d4a555d 100644 --- a/hyrax.gemspec +++ b/hyrax.gemspec @@ -25,7 +25,7 @@ SUMMARY spec.license = 'Apache-2.0' spec.metadata = { "rubygems_mfa_required" => "true" } - spec.required_ruby_version = '>= 2.7' + spec.required_ruby_version = '>= 3.2' # NOTE: rails does not follow sem-ver conventions, it's # minor version releases can include breaking changes; see