From cbc3ec810842c81af5659c33441c200e9b3255de Mon Sep 17 00:00:00 2001 From: meyric Date: Mon, 2 Dec 2024 09:04:04 +0000 Subject: [PATCH 1/7] Update background jobs docs --- doc/background-jobs.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/background-jobs.md b/doc/background-jobs.md index e6aae55f5..04440986d 100644 --- a/doc/background-jobs.md +++ b/doc/background-jobs.md @@ -1,17 +1,20 @@ # Background jobs -We use Sidekiq (backed by Redis) to handle sending emails. See +We use Sidekiq (backed by Redis) to handle sending emails and other asynchronous +jobs. See [ADR9](/doc/architecture/decisions/0009-use-sidekiq-and-redis-to-send-emails.md). -This might be expanded to handle other asynchronous jobs in the future. The container which runs Sidekiq and processes 'jobs' taken from the Redis queue is defined in AWS task definitions as a "sideCar" container. -## Debugging via console +## Sidekiq UI + +The application provides the Sidekiq UI at `/sidekiq` for service owner users. -### Connect to the instance +## Debugging via console -Currently, dxw developers don't have access to the live application console. +You will first need to get a console on the environment, see the +[documentation](/doc/console-access.md) for details. ### See overview of jobs From e01d2dd9b9f70ed35782290cf3582cbebb0b198b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 08:41:13 +0000 Subject: [PATCH 2/7] Bump aws-sdk-s3 from 1.174.0 to 1.175.0 Bumps [aws-sdk-s3](https://github.com/aws/aws-sdk-ruby) from 1.174.0 to 1.175.0. - [Release notes](https://github.com/aws/aws-sdk-ruby/releases) - [Changelog](https://github.com/aws/aws-sdk-ruby/blob/version-3/gems/aws-sdk-s3/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-ruby/commits) --- updated-dependencies: - dependency-name: aws-sdk-s3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index bb0e50ffe..0829c55e2 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ ruby File.read(".ruby-version").strip gem "acts_as_tree" gem "addressable" gem "audited", "~> 5.4" -gem "aws-sdk-s3", "~> 1.174" +gem "aws-sdk-s3", "~> 1.175" gem "bootsnap", ">= 1.1.0", require: false gem "cssbundling-rails", "~> 1.4" gem "csv-safe" diff --git a/Gemfile.lock b/Gemfile.lock index 76eef1919..d36ef9c2e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -71,7 +71,7 @@ GEM activerecord (>= 5.0, < 7.2) request_store (~> 1.2) aws-eventstream (1.3.0) - aws-partitions (1.1013.0) + aws-partitions (1.1016.0) aws-sdk-core (3.214.0) aws-eventstream (~> 1, >= 1.3.0) aws-partitions (~> 1, >= 1.992.0) @@ -80,7 +80,7 @@ GEM aws-sdk-kms (1.96.0) aws-sdk-core (~> 3, >= 3.210.0) aws-sigv4 (~> 1.5) - aws-sdk-s3 (1.174.0) + aws-sdk-s3 (1.175.0) aws-sdk-core (~> 3, >= 3.210.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.5) @@ -547,7 +547,7 @@ DEPENDENCIES acts_as_tree addressable audited (~> 5.4) - aws-sdk-s3 (~> 1.174) + aws-sdk-s3 (~> 1.175) better_errors binding_of_caller bootsnap (>= 1.1.0) From 3f06437fd315ce53f7958ab4b08408328423badb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2024 08:53:28 +0000 Subject: [PATCH 3/7] Bump rails-html-sanitizer from 1.6.0 to 1.6.1 Bumps [rails-html-sanitizer](https://github.com/rails/rails-html-sanitizer) from 1.6.0 to 1.6.1. - [Release notes](https://github.com/rails/rails-html-sanitizer/releases) - [Changelog](https://github.com/rails/rails-html-sanitizer/blob/main/CHANGELOG.md) - [Commits](https://github.com/rails/rails-html-sanitizer/compare/v1.6.0...v1.6.1) --- updated-dependencies: - dependency-name: rails-html-sanitizer dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index d36ef9c2e..8e74ae9b7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -285,14 +285,14 @@ GEM net-smtp (0.5.0) net-protocol nio4r (2.7.4) - nokogiri (1.16.7) + nokogiri (1.16.8) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.16.7-arm64-darwin) + nokogiri (1.16.8-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.7-x86_64-darwin) + nokogiri (1.16.8-x86_64-darwin) racc (~> 1.4) - nokogiri (1.16.7-x86_64-linux) + nokogiri (1.16.8-x86_64-linux) racc (~> 1.4) notifications-ruby-client (6.2.0) jwt (>= 1.5, < 3) @@ -354,9 +354,9 @@ GEM activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.6.0) + rails-html-sanitizer (1.6.1) loofah (~> 2.21) - nokogiri (~> 1.14) + nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) rails-i18n (7.0.10) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) From a5a824e081b3ddca70ee38ca11a52e4745f406da Mon Sep 17 00:00:00 2001 From: meyric Date: Wed, 4 Dec 2024 10:39:11 +0000 Subject: [PATCH 4/7] Remove Spring and switch to Zeitwerk For an application of this size and the kind of hardware developers have access to, Spring is not required, ahead of an update to Rails 7, which does not include Spring by default, let's remove it here. We also want to run the Zeitwerk autoloader ahead of Rails 7 and we only appear to NOT be using it in the test environment, the reasoning for which also appears to relate to Spring?! The only Zeitwerk issue was in the GuidanceUrl spec, which was trying to load it from a non-existent module - not sure how this was ever working, but it is now! --- CHANGELOG.md | 3 +++ Gemfile | 3 --- Gemfile.lock | 9 --------- bin/rails | 1 - bin/rake | 1 - bin/rspec | 5 ----- bin/spring | 14 -------------- config/environments/test.rb | 6 +----- config/spring.rb | 16 ---------------- spec/models/guidance_url_spec.rb | 2 +- 10 files changed, 5 insertions(+), 55 deletions(-) delete mode 100755 bin/spring delete mode 100644 config/spring.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bd50a94f..18aae48e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ [Full changelog][unreleased] +- Remove Spring from development +- Switch to the Zeitwerk autoloader + ## Release 153 - 2024-12-02 [Full changelog][153] diff --git a/Gemfile b/Gemfile index 0829c55e2..506b1c9bd 100644 --- a/Gemfile +++ b/Gemfile @@ -67,9 +67,6 @@ group :development do gem "better_errors" gem "html2haml" gem "listen", ">= 3.0.5", "< 3.10" - gem "spring" - gem "spring-commands-rspec" - gem "spring-watcher-listen", "~> 2.1.0" gem "rails_layout" gem "web-console", ">= 3.3.0" end diff --git a/Gemfile.lock b/Gemfile.lock index 8e74ae9b7..e6c958f2f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -479,12 +479,6 @@ GEM slim (4.1.0) temple (>= 0.7.6, < 0.9) tilt (>= 2.0.6, < 2.1) - spring (4.2.1) - spring-commands-rspec (1.0.4) - spring (>= 0.9.1) - spring-watcher-listen (2.1.0) - listen (>= 2.7, < 4.0) - spring (>= 4) sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) @@ -608,9 +602,6 @@ DEPENDENCIES sidekiq (~> 7) simplecov (~> 0.22.0) simplecov-lcov (~> 0.8.0) - spring - spring-commands-rspec - spring-watcher-listen (~> 2.1.0) standard strip_attributes tzinfo-data diff --git a/bin/rails b/bin/rails index 40b071ea5..073966023 100755 --- a/bin/rails +++ b/bin/rails @@ -1,5 +1,4 @@ #!/usr/bin/env ruby -load File.expand_path("spring", __dir__) APP_PATH = File.expand_path('../config/application', __dir__) require_relative '../config/boot' require 'rails/commands' diff --git a/bin/rake b/bin/rake index 7327f471e..4fbf10b96 100755 --- a/bin/rake +++ b/bin/rake @@ -1,5 +1,4 @@ #!/usr/bin/env ruby -load File.expand_path("spring", __dir__) require_relative "../config/boot" require "rake" Rake.application.run diff --git a/bin/rspec b/bin/rspec index 053bb19a3..caedbbad6 100755 --- a/bin/rspec +++ b/bin/rspec @@ -1,10 +1,5 @@ #!/usr/bin/env ruby # frozen_string_literal: true -begin - load File.expand_path('spring', __dir__) -rescue LoadError => e - raise unless e.message.include?('spring') -end require 'bundler/setup' load Gem.bin_path('rspec-core', 'rspec') diff --git a/bin/spring b/bin/spring deleted file mode 100755 index b4147e843..000000000 --- a/bin/spring +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env ruby -if !defined?(Spring) && [nil, "development", "test"].include?(ENV["RAILS_ENV"]) - gem "bundler" - require "bundler" - - # Load Spring without loading other gems in the Gemfile, for speed. - Bundler.locked_gems&.specs&.find { |spec| spec.name == "spring" }&.tap do |spring| - Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path - gem "spring", spring.version - require "spring/binstub" - rescue Gem::LoadError - # Ignore when Spring is not installed. - end -end diff --git a/config/environments/test.rb b/config/environments/test.rb index 7567499e4..389fb74e0 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -10,14 +10,10 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - config.cache_classes = !(defined?(Spring::Env) && Spring::Env.new.server_running?) + config.cache_classes = false config.action_view.cache_template_loading = true - # Prevent 'reloading is disabled' errors from Spring - # https://github.com/rails/spring/issues/598 - config.autoloader = :classic - # Do not eager load code on boot. This avoids loading your whole application # just for the purpose of running a single test. If you are using a tool that # preloads Rails for running tests, you may have to set it to true. diff --git a/config/spring.rb b/config/spring.rb deleted file mode 100644 index 83202c25d..000000000 --- a/config/spring.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -Spring.watch( - ".ruby-version", - ".rbenv-vars", - "tmp/restart.txt", - "tmp/caching-dev.txt" -) - -Spring.after_fork do - if Rails.env.test? - RSpec.configure do |config| - config.seed = srand % 0xFFFF unless ARGV.any? { |arg| arg =~ /seed/ } - end - end -end diff --git a/spec/models/guidance_url_spec.rb b/spec/models/guidance_url_spec.rb index cb008cf0c..113acd9e1 100644 --- a/spec/models/guidance_url_spec.rb +++ b/spec/models/guidance_url_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Activity::GuidanceUrl, type: :model do +RSpec.describe GuidanceUrl, type: :model do describe "#to_s" do it "returns a url if one exists" do url = GuidanceUrl.new(:activity, :programme_status) From ef4263d835bd1d639b54b5985e56104259f7851c Mon Sep 17 00:00:00 2001 From: meyric Date: Wed, 4 Dec 2024 12:33:35 +0000 Subject: [PATCH 5/7] Use Rails 6.1 defaults We've been running Rails 6.1 for a while now and inline with the upgrade documentation, we should now be using the 6.1 defaults: https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#configure-framework-defaults Rather than change each individual setting, we've gone all in and taken confidence from our extensive test suite that everything is good. This clears a path for the Rails 6 to 7 upgrade. --- CHANGELOG.md | 1 + config/application.rb | 2 +- .../new_framework_defaults_6_1.rb | 67 ------------------- 3 files changed, 2 insertions(+), 68 deletions(-) delete mode 100644 config/initializers/new_framework_defaults_6_1.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 18aae48e9..61d805da2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Remove Spring from development - Switch to the Zeitwerk autoloader +- Use Rails 6.1 default configuration ## Release 153 - 2024-12-02 diff --git a/config/application.rb b/config/application.rb index 8b5b0d8ce..2b1d2f5c9 100644 --- a/config/application.rb +++ b/config/application.rb @@ -37,7 +37,7 @@ class Application < Rails::Application end # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 6.0 + config.load_defaults 6.1 # Settings in config/environments/* take precedence over those specified here. # Application configuration can go into files in config/initializers diff --git a/config/initializers/new_framework_defaults_6_1.rb b/config/initializers/new_framework_defaults_6_1.rb deleted file mode 100644 index 9526b835a..000000000 --- a/config/initializers/new_framework_defaults_6_1.rb +++ /dev/null @@ -1,67 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file contains migration options to ease your Rails 6.1 upgrade. -# -# Once upgraded flip defaults one by one to migrate to the new default. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. - -# Support for inversing belongs_to -> has_many Active Record associations. -# Rails.application.config.active_record.has_many_inversing = true - -# Track Active Storage variants in the database. -# Rails.application.config.active_storage.track_variants = true - -# Apply random variation to the delay when retrying failed jobs. -# Rails.application.config.active_job.retry_jitter = 0.15 - -# Stop executing `after_enqueue`/`after_perform` callbacks if -# `before_enqueue`/`before_perform` respectively halts with `throw :abort`. -# Rails.application.config.active_job.skip_after_callbacks_if_terminated = true - -# Specify cookies SameSite protection level: either :none, :lax, or :strict. -# -# This change is not backwards compatible with earlier Rails versions. -# It's best enabled when your entire app is migrated and stable on 6.1. -# Rails.application.config.action_dispatch.cookies_same_site_protection = :lax - -# Generate CSRF tokens that are encoded in URL-safe Base64. -# -# This change is not backwards compatible with earlier Rails versions. -# It's best enabled when your entire app is migrated and stable on 6.1. -# Rails.application.config.action_controller.urlsafe_csrf_tokens = true - -# Specify whether `ActiveSupport::TimeZone.utc_to_local` returns a time with an -# UTC offset or a UTC time. -# ActiveSupport.utc_to_local_returns_utc_offset_times = true - -# Change the default HTTP status code to `308` when redirecting non-GET/HEAD -# requests to HTTPS in `ActionDispatch::SSL` middleware. -# Rails.application.config.action_dispatch.ssl_default_redirect_status = 308 - -# Use new connection handling API. For most applications this won't have any -# effect. For applications using multiple databases, this new API provides -# support for granular connection swapping. -# Rails.application.config.active_record.legacy_connection_handling = false - -# Make `form_with` generate non-remote forms by default. -# Rails.application.config.action_view.form_with_generates_remote_forms = false - -# Set the default queue name for the analysis job to the queue adapter default. -# Rails.application.config.active_storage.queues.analysis = nil - -# Set the default queue name for the purge job to the queue adapter default. -# Rails.application.config.active_storage.queues.purge = nil - -# Set the default queue name for the incineration job to the queue adapter default. -# Rails.application.config.action_mailbox.queues.incineration = nil - -# Set the default queue name for the routing job to the queue adapter default. -# Rails.application.config.action_mailbox.queues.routing = nil - -# Set the default queue name for the mail deliver job to the queue adapter default. -# Rails.application.config.action_mailer.deliver_later_queue_name = nil - -# Generate a `Link` header that gives a hint to modern browsers about -# preloading assets when using `javascript_include_tag` and `stylesheet_link_tag`. -# Rails.application.config.action_view.preload_links_header = true From c095ff5f4f79febb57098aa11f40ef97532cca50 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 4 Dec 2024 15:23:37 +0000 Subject: [PATCH 6/7] Bump aws-sdk-s3 from 1.175.0 to 1.176.0 Bumps [aws-sdk-s3](https://github.com/aws/aws-sdk-ruby) from 1.175.0 to 1.176.0. - [Release notes](https://github.com/aws/aws-sdk-ruby/releases) - [Changelog](https://github.com/aws/aws-sdk-ruby/blob/version-3/gems/aws-sdk-s3/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-ruby/commits) --- updated-dependencies: - dependency-name: aws-sdk-s3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 506b1c9bd..602b64616 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ ruby File.read(".ruby-version").strip gem "acts_as_tree" gem "addressable" gem "audited", "~> 5.4" -gem "aws-sdk-s3", "~> 1.175" +gem "aws-sdk-s3", "~> 1.176" gem "bootsnap", ">= 1.1.0", require: false gem "cssbundling-rails", "~> 1.4" gem "csv-safe" diff --git a/Gemfile.lock b/Gemfile.lock index e6c958f2f..95c14263f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -71,7 +71,7 @@ GEM activerecord (>= 5.0, < 7.2) request_store (~> 1.2) aws-eventstream (1.3.0) - aws-partitions (1.1016.0) + aws-partitions (1.1017.0) aws-sdk-core (3.214.0) aws-eventstream (~> 1, >= 1.3.0) aws-partitions (~> 1, >= 1.992.0) @@ -80,7 +80,7 @@ GEM aws-sdk-kms (1.96.0) aws-sdk-core (~> 3, >= 3.210.0) aws-sigv4 (~> 1.5) - aws-sdk-s3 (1.175.0) + aws-sdk-s3 (1.176.0) aws-sdk-core (~> 3, >= 3.210.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.5) @@ -541,7 +541,7 @@ DEPENDENCIES acts_as_tree addressable audited (~> 5.4) - aws-sdk-s3 (~> 1.175) + aws-sdk-s3 (~> 1.176) better_errors binding_of_caller bootsnap (>= 1.1.0) From dd4d49db5da46e2e9222e4b0df9a7db4c195ef05 Mon Sep 17 00:00:00 2001 From: meyric Date: Thu, 5 Dec 2024 10:21:44 +0000 Subject: [PATCH 7/7] Release 154 - Remove Spring from development - Switch to the Zeitwerk autoloader - Use Rails 6.1 default configuration --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61d805da2..5664621e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ [Full changelog][unreleased] +## Release 154 - 2024-12-05 + +[Full changelog][154] + - Remove Spring from development - Switch to the Zeitwerk autoloader - Use Rails 6.1 default configuration @@ -1723,7 +1727,8 @@ - Planned start and end dates are mandatory - Actual start and end dates must not be in the future -[unreleased]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-153...HEAD +[unreleased]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-154...HEAD +[154]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-153...release-154 [153]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-152...release-153 [152]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-151...release-152 [151]: https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/compare/release-150...release-151