From c905b4097bbde6b59fdb0222d4bcd95d69115b06 Mon Sep 17 00:00:00 2001 From: Graeme Porteous Date: Wed, 8 Jan 2025 11:14:43 +0000 Subject: [PATCH] Drop support for Ruby 3.1 Fixes: #8512 --- .github/workflows/ci.yml | 1 - .github/workflows/rubocop.yml | 2 +- .ruby-style.yml | 2 +- .ruby-version.example | 2 +- README.md | 3 +-- app/controllers/refusal_advice_controller.rb | 6 +----- app/models/post_redirect.rb | 20 ++++++++----------- config/routes/redirects.rb | 6 +----- docker-compose.yml | 4 ++-- docker/Dockerfile | 2 +- .../alaveteli_features.gemspec | 1 + gems/excel_analyzer/excel_analyzer.gemspec | 2 +- lib/tasks/config_files.rake | 8 ++++---- script/update-rubocop-config.rb | 6 +----- 14 files changed, 24 insertions(+), 41 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9164f85ce..b89359d9db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,7 +53,6 @@ jobs: fail-fast: false matrix: include: - - { ruby: '3.1', postgres: 13.5 } - { ruby: '3.2', postgres: 13.5 } services: diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 3a0c56f579..44e51ed7b9 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -18,7 +18,7 @@ jobs: - name: Install Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.1 + ruby-version: 3.2 - name: Run RuboCop linter uses: reviewdog/action-rubocop@v2.14.0 diff --git a/.ruby-style.yml b/.ruby-style.yml index 314ba67d63..cbf656c550 100644 --- a/.ruby-style.yml +++ b/.ruby-style.yml @@ -5,7 +5,7 @@ require: - "./lib/custom_cops/empty_lines_around_rescued_exceptions.rb" AllCops: - TargetRubyVersion: 3.1 + TargetRubyVersion: 3.2 RubyInterpreters: - ruby - rake diff --git a/.ruby-version.example b/.ruby-version.example index 9cec7165ab..34cde5690e 100644 --- a/.ruby-version.example +++ b/.ruby-version.example @@ -1 +1 @@ -3.1.6 +3.2.6 diff --git a/README.md b/README.md index 71b60698ec..71c6dea15a 100644 --- a/README.md +++ b/README.md @@ -37,10 +37,9 @@ see [the project website](http://alaveteli.org) for instructions on installing A Every Alaveteli commit is tested by GitHub Actions on the [following Ruby platforms](https://github.com/mysociety/alaveteli/blob/develop/.github/workflows/ci.yml#L27-L29) -* ruby-3.1 * ruby-3.2 -If you use a ruby version management tool (such as RVM or .rbenv) and want to use the default development version used by the Alaveteli team (currently 3.1.6), you can create a `.ruby-version` symlink with a target of `.ruby-version.example` to switch to that automatically in the project directory. +If you use a ruby version management tool (such as RVM or .rbenv) and want to use the default development version used by the Alaveteli team (currently 3.2.6), you can create a `.ruby-version` symlink with a target of `.ruby-version.example` to switch to that automatically in the project directory. ## How to contribute diff --git a/app/controllers/refusal_advice_controller.rb b/app/controllers/refusal_advice_controller.rb index a8b99c6a14..753127f5a7 100644 --- a/app/controllers/refusal_advice_controller.rb +++ b/app/controllers/refusal_advice_controller.rb @@ -85,15 +85,11 @@ def refusal_advice_params end def parsed_refusal_advice_params - parsed_params = refusal_advice_params.merge( + refusal_advice_params.merge( actions: refusal_advice_params.fetch(:actions). each_pair do |_, suggestions| suggestions.transform_values! { |v| v == 'true' } end ).to_h - - return parsed_params.deep_symbolize_keys if RUBY_VERSION < '3.0' - - parsed_params end end diff --git a/app/models/post_redirect.rb b/app/models/post_redirect.rb index 42fafa59bc..472bbc85fb 100644 --- a/app/models/post_redirect.rb +++ b/app/models/post_redirect.rb @@ -71,18 +71,14 @@ def post_params=(params) def post_params return {} if post_params_yaml.nil? - if RUBY_VERSION < "3.1" - YAML.load(post_params_yaml) - else - YAML.load( - post_params_yaml, - permitted_classes: [ - ActionController::Parameters, - ActiveSupport::HashWithIndifferentAccess, - Symbol - ] - ) - end + YAML.load( + post_params_yaml, + permitted_classes: [ + ActionController::Parameters, + ActiveSupport::HashWithIndifferentAccess, + Symbol + ] + ) end # We store YAML version of textual "reason for redirect" parameters diff --git a/config/routes/redirects.rb b/config/routes/redirects.rb index 37c7ac6c1b..7bc8c2e687 100644 --- a/config/routes/redirects.rb +++ b/config/routes/redirects.rb @@ -18,11 +18,7 @@ encoded_parts = [ *params[:locale], 'request', info_request.url_title, *prefix, *suffix ].map do |part| - if RUBY_VERSION < '3.1' - URI.encode_www_form_component(part).gsub('+', '%20') - else - URI.encode_uri_component(part) - end + URI.encode_uri_component(part) end # join encoded parts together with slashes diff --git a/docker-compose.yml b/docker-compose.yml index edc0604465..b96316b549 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: context: . dockerfile: docker/Dockerfile args: - RUBY_VERSION: '${RUBY_VERSION:-3.1}' + RUBY_VERSION: '${RUBY_VERSION:-3.2}' tty: true stdin_open: true environment: @@ -30,7 +30,7 @@ services: context: . dockerfile: docker/Dockerfile args: - RUBY_VERSION: '${RUBY_VERSION:-3.1}' + RUBY_VERSION: '${RUBY_VERSION:-3.2}' command: bundle exec sidekiq volumes: - ./:/alaveteli diff --git a/docker/Dockerfile b/docker/Dockerfile index aa658ad685..a6bb106edc 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -ARG RUBY_VERSION=3.1 +ARG RUBY_VERSION=3.2 FROM ruby:${RUBY_VERSION}-bullseye ENV DOCKER 1 diff --git a/gems/alaveteli_features/alaveteli_features.gemspec b/gems/alaveteli_features/alaveteli_features.gemspec index 291561eefa..18fc94f928 100644 --- a/gems/alaveteli_features/alaveteli_features.gemspec +++ b/gems/alaveteli_features/alaveteli_features.gemspec @@ -12,6 +12,7 @@ Gem::Specification.new do |spec| spec.summary = "Helper methods to manage and test Alaveteli features" spec.homepage = "https://alaveteli.org" spec.license = "MIT" + spec.required_ruby_version = ">= 3.2.0" spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR) spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } diff --git a/gems/excel_analyzer/excel_analyzer.gemspec b/gems/excel_analyzer/excel_analyzer.gemspec index 5731f6c5dc..0fa1b75e67 100644 --- a/gems/excel_analyzer/excel_analyzer.gemspec +++ b/gems/excel_analyzer/excel_analyzer.gemspec @@ -12,7 +12,7 @@ Gem::Specification.new do |spec| spec.summary = "File analysers for ActiveStorage" spec.description = "Extra ActiveStorage Analysers for Alaveteli" spec.homepage = "https://alaveteli.org" - spec.required_ruby_version = ">= 3.1.0" + spec.required_ruby_version = ">= 3.2.0" spec.metadata["homepage_uri"] = spec.homepage diff --git a/lib/tasks/config_files.rake b/lib/tasks/config_files.rake index 755ec0eb94..2e8428aa5b 100644 --- a/lib/tasks/config_files.rake +++ b/lib/tasks/config_files.rake @@ -29,7 +29,7 @@ namespace :config_files do cpus: ENV.fetch('CPUS') { '1' }, mailto: ENV.fetch('MAILTO') { "#{ ENV['DEPLOY_USER'] }@localhost" }, rails_env: ENV.fetch('RAILS_ENV') { 'development' }, - ruby_version: ENV.fetch('RUBY_VERSION') { '3.1.6' }, + ruby_version: ENV.fetch('RUBY_VERSION') { '3.2.6' }, site: ENV.fetch('SITE') { 'foi' }, user: ENV.fetch('DEPLOY_USER') { 'alaveteli' }, vcspath: ENV.fetch('VCSPATH') { 'alaveteli' }, @@ -123,7 +123,7 @@ namespace :config_files do 'VCSPATH=alaveteli ' \ 'SITE=alaveteli ' \ 'SCRIPT_FILE=config/sysvinit-thin.example ' \ - 'RUBY_VERSION=3.1.6 ' \ + 'RUBY_VERSION=3.2.6 ' \ 'USE_RBENV=false ' check_for_env_vars(%w[DEPLOY_USER VHOST_DIR SCRIPT_FILE], example) @@ -147,7 +147,7 @@ namespace :config_files do 'VCSPATH=alaveteli ' \ 'SITE=alaveteli ' \ 'DAEMON=alert-tracks.service ' \ - 'RUBY_VERSION=3.1.6 ' \ + 'RUBY_VERSION=3.2.6 ' \ 'USE_RBENV=false ' check_for_env_vars(%w[DEPLOY_USER VHOST_DIR DAEMON], example) @@ -167,7 +167,7 @@ namespace :config_files do 'VHOST_DIR=/dir/above/alaveteli VCSPATH=alaveteli ' \ 'SITE=alaveteli CRONTAB=config/crontab-example ' \ 'MAILTO=cron-alaveteli@example.org ' \ - 'RUBY_VERSION=3.1.6 ' \ + 'RUBY_VERSION=3.2.6 ' \ 'USE_RBENV=false ' check_for_env_vars(%w[DEPLOY_USER VHOST_DIR VCSPATH SITE CRONTAB], example) convert_erb(ENV['CRONTAB'], **default_replacements) diff --git a/script/update-rubocop-config.rb b/script/update-rubocop-config.rb index 395da2633a..f3f5e585d9 100755 --- a/script/update-rubocop-config.rb +++ b/script/update-rubocop-config.rb @@ -34,11 +34,7 @@ def default_config File.write(tmp_path, Net::HTTP.get(uri)) unless File.exist?(tmp_path) - if RUBY_VERSION < "3.1" - yaml = YAML.load_file(tmp_path) - else - yaml = YAML.load_file(tmp_path, permitted_classes: [Regexp, Symbol]) - end + yaml = YAML.load_file(tmp_path, permitted_classes: [Regexp, Symbol]) m.deep_merge!(yaml) end