Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAP-359: Upgrade Ruby to 3.2.2 #2177

Merged
merged 5 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@ executors:
test-executor:
docker:
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
- image: circleci/ruby:2.7.3
- image: cimg/ruby:3.2.2
environment:
BUNDLER_VERSION: 2.1.4
BUNDLER_VERSION: 2.4.20
RAILS_ENV: test
RACK_ENV: test
DATABASE_URL: "postgres://postgres@localhost/hmpps-book-secure-move-api"
Expand Down Expand Up @@ -362,7 +362,7 @@ jobs:
- *rspec

linters:
resource_class: small
resource_class: medium
executor: test-executor
steps:
- checkout
Expand Down
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ GOVUK_NOTIFY_TEMPLATE_ID=8f2e5473-15f2-4db8-a2de-153f26a0524c

# Completely disable API authentication for local development if true.
DEV_DISABLE_AUTH=false

# Stop Postgres segfaulting on Ruby 3.x on Mac
PGGSSENCMODE="disable"
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.3
3.2.2
10 changes: 3 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:2.7.3-alpine as build-stage
FROM ruby:3.2.2-alpine as build-stage

ENV RAILS_ENV=production
ENV RACK_ENV=production
Expand All @@ -18,7 +18,7 @@ RUN bundle install --jobs 4 --retry 3 \
&& find /usr/local/bundle/gems/ -name "*.o" -delete

############### End of Build step ###############
FROM ruby:2.7.3-alpine as swagger-build
FROM ruby:3.2.2-alpine as swagger-build

WORKDIR /app
RUN apk --update --no-cache add git build-base postgresql-dev shared-mime-info gcompat tzdata
Expand All @@ -31,7 +31,7 @@ COPY . /app
RUN SKIP_MAINTAIN_TEST_SCHEMA=true rails rswag:specs:swaggerize

############### End of Build step ###############
FROM ruby:2.7.3-alpine
FROM ruby:3.2.2-alpine

ARG APP_BUILD_DATE
ENV APP_BUILD_DATE ${APP_BUILD_DATE}
Expand All @@ -56,10 +56,6 @@ RUN addgroup -g $APPUID -S appgroup && \

RUN apk add --update --no-cache git tzdata postgresql-dev shared-mime-info

# Fix incompatibility with slim tzdata from 2020b onwards
RUN wget https://data.iana.org/time-zones/tzdb/tzdata.zi -O /usr/share/zoneinfo/tzdata.zi && \
/usr/sbin/zic -b fat /usr/share/zoneinfo/tzdata.zi

WORKDIR /app
COPY --chown=appuser:appgroup --from=build-stage /usr/local/bundle /usr/local/bundle
COPY --chown=appuser:appgroup . /app
Expand Down
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ GEM
ffi (1.15.5)
fiber-annotation (0.2.0)
fiber-local (1.0.0)
finite_machine (0.14.0)
finite_machine (0.14.1)
concurrent-ruby (~> 1.0)
sync (~> 0.5)
flipper (0.28.3)
Expand Down Expand Up @@ -267,7 +267,7 @@ GEM
parallel (1.23.0)
parser (3.2.2.1)
ast (~> 2.4.1)
pg (1.5.3)
pg (1.5.4)
prometheus-client (4.2.1)
protocol-hpack (1.4.2)
protocol-http (0.24.4)
Expand Down Expand Up @@ -530,7 +530,7 @@ DEPENDENCIES
validate_url

RUBY VERSION
ruby 2.7.3p183
ruby 3.2.2p53

BUNDLED WITH
2.1.4
2.4.20
12 changes: 6 additions & 6 deletions app/controllers/api/allocations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def update
updater = Allocations::Updater.new(
allocation_params: update_allocation_params,
allocation_id: params.require(:id),
created_by: created_by,
doorkeeper_application_owner: doorkeeper_application_owner,
created_by:,
doorkeeper_application_owner:,
)
updater.call

Expand Down Expand Up @@ -89,23 +89,23 @@ def complex_case_params
end

def render_allocation(allocation, status)
render_json allocation, serializer: AllocationSerializer, include: included_relationships, status: status
render_json allocation, serializer: AllocationSerializer, include: included_relationships, status:
end

def allocations
Allocations::Finder.new(
filters: filter_params,
ordering: sort_params,
search: search_params,
active_record_relationships: active_record_relationships,
active_record_relationships:,
).call
end

def creator
@creator ||= Allocations::Creator.new(
doorkeeper_application_owner: doorkeeper_application_owner,
doorkeeper_application_owner:,
allocation_params: create_allocation_params,
complex_case_params: complex_case_params,
complex_case_params:,
)
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/court_hearings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def create
private

def court_hearings_attributes
court_hearings_params.merge(move: move)
court_hearings_params.merge(move:)
end

def court_hearings_params
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/framework_assessments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def confirm_assessment!(assessment)
end

def render_assessment(assessment, status)
render_json assessment, serializer: assessment_serializer, include: included_relationships, status: status
render_json assessment, serializer: assessment_serializer, include: included_relationships, status:
end

def assessment_class
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/api/framework_responses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def update

def bulk_update
FrameworkResponses::BulkUpdater.new(
assessment: assessment,
assessment:,
response_values_hash: bulk_update_framework_response_values,
responded_by: created_by,
responded_at: Time.zone.now.iso8601,
Expand Down Expand Up @@ -105,15 +105,15 @@ def render_value_type_error(exception)
def render_bulk_update_error(exception)
errors = exception.errors.map do |id, error_message|
{
id: id,
id:,
title: 'Invalid value',
detail: error_message,
source: { pointer: '/data/attributes/value' },
}
end

render(
json: { errors: errors },
json: { errors: },
status: :unprocessable_entity,
)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/generic_events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def show
private

def render_event(event, status)
render_json event, serializer: event.class.serializer, status: status
render_json event, serializer: event.class.serializer, status:
end

def event
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/api/journeys_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def update
private

def render_journey(journey, status)
render_json journey, serializer: JourneySerializer, include: included_relationships, status: status
render_json journey, serializer: JourneySerializer, include: included_relationships, status:
end

def supported_relationships
Expand Down Expand Up @@ -116,12 +116,12 @@ def new_journey_attributes
@new_journey_attributes ||= new_journey_params.to_h[:attributes].tap do |attribs|
timestamp = attribs.delete(:timestamp) # throw the timestamp away as we are using client_timestamp instead
attribs.merge!(
move: move,
move:,
client_timestamp: Time.zone.parse(timestamp),
date: attribs.delete(:date) || move.date,
from_location: find_location(new_journey_params.require(:relationships).require(:from_location).require(:data).require(:id)),
to_location: find_location(new_journey_params.require(:relationships).require(:to_location).require(:data).require(:id)),
supplier: supplier,
supplier:,
)
end
end
Expand Down Expand Up @@ -170,7 +170,7 @@ def create_journey_event
GenericEvent::JourneyCreate
end

create_automatic_event!(eventable: journey, event_class: event_class, supplier_id: supplier.id)
create_automatic_event!(eventable: journey, event_class:, supplier_id: supplier.id)
end
end
end
6 changes: 3 additions & 3 deletions app/controllers/api/moves_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ def filtered

def find_moves(active_record_relationships:)
Moves::Finder.new(
filter_params: filter_params,
filter_params:,
ability: current_ability,
order_params: params[:sort] || {},
active_record_relationships: active_record_relationships,
active_record_relationships:,
).call
end

def moves
@moves ||= find_moves(active_record_relationships: active_record_relationships)
@moves ||= find_moves(active_record_relationships:)
end

def validate_filter_params
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/api/populations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class PopulationsController < ApiController
rescue_from Date::Error, with: :render_invalid_date_error

def new
new_population = Population.new_with_defaults(location: location, date: date)
new_population = Population.new_with_defaults(location:, date:)

render_population(new_population, :ok)
end
Expand Down Expand Up @@ -84,9 +84,9 @@ def location

def locations
@locations ||= Locations::Finder.new(
filter_params: filter_params,
sort_params: sort_params,
active_record_relationships: active_record_relationships,
filter_params:,
sort_params:,
active_record_relationships:,
).call
end

Expand All @@ -109,7 +109,7 @@ def population
end

def render_population(population, status)
render_json population, serializer: PopulationSerializer, include: included_relationships, status: status
render_json population, serializer: PopulationSerializer, include: included_relationships, status:
end

def supported_relationships
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def supported_relationships
end

def render_profile(profile, status)
render_json profile, serializer: ProfileSerializer, include: included_relationships, status: status
render_json profile, serializer: ProfileSerializer, include: included_relationships, status:
end
end
end
4 changes: 2 additions & 2 deletions app/controllers/api/reference/locations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Api
module Reference
class LocationsController < ApiController
def index
locations = Locations::Finder.new(filter_params: filter_params, active_record_relationships: active_record_relationships).call
locations = Locations::Finder.new(filter_params:, active_record_relationships:).call
paginate locations, serializer: LocationSerializer, include: included_relationships
end

Expand All @@ -24,7 +24,7 @@ def find_location
end

def render_location(location, status)
render_json location, serializer: LocationSerializer, include: included_relationships, status: status
render_json location, serializer: LocationSerializer, include: included_relationships, status:
end

PERMITTED_FILTER_PARAMS = %i[location_type nomis_agency_id supplier_id location_id region_id young_offender_institution created_at].freeze
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/api/v1/moves_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def new_move_attributes

attributes.merge!(
profile: profile_or_person_latest_profile,
from_location: from_location,
from_location:,
to_location: Location.find_by(id: new_move_params.dig(:relationships, :to_location, :data, :id)),
court_hearings: CourtHearing.where(id: (new_move_params.dig(:relationships, :court_hearings, :data) || []).map { |court_hearing| court_hearing[:id] }),
prison_transfer_reason: PrisonTransferReason.find_by(id: new_move_params.dig(:relationships, :prison_transfer_reason, :data, :id)),
Expand All @@ -104,7 +104,7 @@ def new_move_attributes
def validate_move_status
status = update_move_params.fetch(:attributes, {})[:status]
if status.present?
validator = Moves::StatusValidator.new(status: status, cancellation_reason: update_move_params.fetch(:attributes, {})[:cancellation_reason], rejection_reason: update_move_params.fetch(:attributes, {})[:rejection_reason])
validator = Moves::StatusValidator.new(status:, cancellation_reason: update_move_params.fetch(:attributes, {})[:cancellation_reason], rejection_reason: update_move_params.fetch(:attributes, {})[:rejection_reason])
raise ActiveModel::ValidationError, validator unless validator.valid?
end
status
Expand All @@ -123,7 +123,7 @@ def update_move_params
end

def render_move(move, status)
render_json move, serializer: MoveSerializer, include: included_relationships, status: status
render_json move, serializer: MoveSerializer, include: included_relationships, status:
end

def move
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/people_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def update_and_render
private

def render_person(person, status)
render_json person, serializer: PersonSerializer, include: included_relationships, status: status
render_json person, serializer: PersonSerializer, include: included_relationships, status:
end

def creator
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/api/v2/moves_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def update_and_render
move.allocation&.refresh_status_and_moves_count!

Allocations::CreateInNomis.call(move) if create_in_nomis?
Notifier.prepare_notifications(topic: move, action_name: action_name)
Notifier.prepare_notifications(topic: move, action_name:)

render_move(move, :ok)
end
Expand Down Expand Up @@ -116,7 +116,7 @@ def validate_move_status
status = move_params.fetch(:attributes, {})[:status]
log_with_request(:debug, "Validating current status of move - [#{status}]")
if status.present?
validator = Moves::StatusValidator.new(status: status, cancellation_reason: move_params.fetch(:attributes, {})[:cancellation_reason], rejection_reason: move_params.fetch(:attributes, {})[:rejection_reason])
validator = Moves::StatusValidator.new(status:, cancellation_reason: move_params.fetch(:attributes, {})[:cancellation_reason], rejection_reason: move_params.fetch(:attributes, {})[:rejection_reason])
valid = validator.valid?
log_with_request(:debug, "Valid Move status: - [#{valid}]")
raise ActiveModel::ValidationError, validator unless valid
Expand Down Expand Up @@ -178,7 +178,7 @@ def prison_transfer_reason_attributes
end

def render_move(move, status)
render_json move, serializer: ::V2::MoveSerializer, include: included_relationships, fields: ::V2::MoveSerializer::INCLUDED_FIELDS, status: status
render_json move, serializer: ::V2::MoveSerializer, include: included_relationships, fields: ::V2::MoveSerializer::INCLUDED_FIELDS, status:
end

def move
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v2/people_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def gender
end

def render_person(person, status)
render_json person, serializer: ::V2::PersonWithCategorySerializer, include: included_relationships, status: status
render_json person, serializer: ::V2::PersonWithCategorySerializer, include: included_relationships, status:
end

def supported_relationships
Expand Down
Loading
Loading