Skip to content

Commit

Permalink
Merge branch 'rails-upgrades' into develop: 2024 Q1 Rails Upgrade
Browse files Browse the repository at this point in the history
#974

Upgrades:

- Rails 4.0 to 6.1
- Ruby 2.3 to 3.0
- Many other dependencies, and associated fixes
- See notes in #969 for most of the changes
- Also includes feature change to checklist #972
  • Loading branch information
pdl committed Apr 10, 2024
2 parents 839d153 + 30bd9ab commit 3bc9fdd
Show file tree
Hide file tree
Showing 1,153 changed files with 171,008 additions and 7,552 deletions.
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# See https://git-scm.com/docs/gitattributes for more about git attribute files.

# Mark the database schema as having been generated.
db/schema.rb linguist-generated

# Mark the yarn lockfile as having been generated.
yarn.lock linguist-generated

# Mark any vendored files as having been vendored.
vendor/* linguist-vendored
22 changes: 20 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,28 @@
/.bundle

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

# Ignore pidfiles, but keep the directory.
/tmp/pids/*
!/tmp/pids/
!/tmp/pids/.keep

# Ignore uploaded files in development.
/storage/*
!/storage/.keep

/public/assets
.byebug_history

# Ignore master key for decrypting credentials and more.
/config/master.key

/coverage
/rdoc
/log/*.log
/tmp
/private
/public/system
/public/downloads/*.pdf
Expand Down
41 changes: 18 additions & 23 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
inherit_from: .rubocop_todo.yml
# inherit_from: .rubocop_todo.yml
require:
- rubocop-rails
- rubocop-rspec

Rails:
Enabled: true
AllCops:
TargetRubyVersion: 2.2
TargetRubyVersion: 3.0.6
TargetRailsVersion: 6.0
Exclude:
- 'lib/tasks/bbgem.rake'
- 'db/schema.rb'
Expand All @@ -12,35 +18,24 @@ Style/StringLiterals:

# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: outdent, indent
Style/AccessModifierIndentation:
Layout/AccessModifierIndentation:
EnforcedStyle: indent

# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_brackets
Style/IndentArray:
EnforcedStyle: consistent

# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_braces
Style/IndentHash:
EnforcedStyle: consistent

# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: normal, rails
Style/IndentationConsistency:
Layout/IndentationConsistency:
EnforcedStyle: normal
Exclude:
- 'db/migrate/*'
- 'config/initializers/normalise_blank_values.rb'

# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: symmetrical, new_line, same_line
Style/MultilineArrayBraceLayout:
Layout/MultilineArrayBraceLayout:
EnforcedStyle: symmetrical

# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: symmetrical, new_line, same_line
Style/MultilineHashBraceLayout:
Layout/MultilineHashBraceLayout:
EnforcedStyle: symmetrical

# Configuration parameters: EnforcedStyle, SupportedStyles.
Expand All @@ -53,33 +48,33 @@ Style/AndOr:
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: leading, trailing
Style/DotPosition:
Layout/DotPosition:
EnforcedStyle: trailing

# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
Style/ExtraSpacing:
Layout/ExtraSpacing:
AllowForAlignment: true
Exclude:
- 'db/migrate/*'

# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
Style/FirstParameterIndentation:
Layout/FirstParameterIndentation:
Enabled: true

# Configuration parameters: Width.
Style/IndentationWidth:
Layout/IndentationWidth:
Exclude:
- 'db/migrate/*'

# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceInsideHashLiteralBraces:
Layout/SpaceInsideHashLiteralBraces:
EnforcedStyle: space
EnforcedStyleForEmptyBraces: no_space

# Configuration parameters: AllowForAlignment.
Style/SpaceAroundOperators:
Layout/SpaceAroundOperators:
AllowForAlignment: true

# Configuration parameters: AllowIfMethodIsEmpty.
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.1
3.0.6
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cache: bundler
bundler_args: --without development production staging
sudo: false
rvm:
- 2.3.1
- 3.0.6
addons:
postgresql: 9.4
code_climate:
Expand Down
7 changes: 3 additions & 4 deletions Capfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require 'capistrano/setup'
require 'capistrano/deploy'


require "capistrano/scm/git"
require 'capistrano/scm/git'
install_plugin Capistrano::SCM::Git


Expand All @@ -34,10 +34,9 @@ require 'capistrano/rails/migrations'
require 'capistrano/passenger'
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
require 'capistrano/maintenance'
require 'whenever/capistrano'
require 'capistrano/local_precompile'
require 'capistrano/sidekiq'


install_plugin Capistrano::Sidekiq
install_plugin Capistrano::Sidekiq::Systemd

Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
30 changes: 0 additions & 30 deletions Capfile.old

This file was deleted.

22 changes: 6 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
# Dockerfile
FROM ruby:2.3.1

# The ruby:2.3.1 image is ancient, based of debian jessie which no longer
# receives active security updates. Therefore we must declare the debian
# archive as a source instead.
RUN rm /etc/apt/sources.list && \
echo "deb http://archive.debian.org/debian-security jessie/updates main" \
>> /etc/apt/sources.list.d/jessie.list && \
echo "deb http://archive.debian.org/debian jessie main" \
>> /etc/apt/sources.list.d/jessie.list \
;
FROM ruby:3.0.6

# Rails and SAPI has some additional dependencies, e.g. rake requires a JS
# runtime, so attempt to get these from apt, where possible
Expand All @@ -24,12 +14,12 @@ RUN apt-get update && apt-get install -y --force-yes \
RUN mkdir /SAPI
WORKDIR /SAPI

COPY Gemfile /SAPI/Gemfile
COPY Gemfile.lock /SAPI/Gemfile.lock
RUN gem install bundler -v 1.17.3
RUN bundle install
# COPY Gemfile /SAPI/Gemfile
# COPY Gemfile.lock /SAPI/Gemfile.lock
RUN gem install bundler -v 2.2.33
# RUN bundle install

COPY . /SAPI
# COPY . /SAPI

EXPOSE 3000
CMD ["rails", "server", "-b", "0.0.0.0"]
50 changes: 50 additions & 0 deletions Dockerfile.cap-deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Dockerfile
FROM ruby:3.0.6

ENV DEBIAN_FRONTEND=noninteractive
# Rails and SAPI has some additional dependencies, e.g. rake requires a JS
# runtime, so attempt to get these from apt, where possible
RUN apt-get update && apt-get install -y --force-yes \
# For ruby?
libsodium-dev libgmp3-dev \
# For RVM
gnupg procps curl libssl-dev \
# For assets local_precompile (cap deploy)
rsync nodejs \
# gems
libpq-dev postgresql-client

RUN mkdir /SAPI
WORKDIR /SAPI

# https://stackoverflow.com/questions/43612927/how-to-correctly-install-rvm-in-docker
RUN gpg --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
RUN curl -sSL https://get.rvm.io | bash -s
RUN /bin/bash -l -c ". /etc/profile.d/rvm.sh && rvm install 3.0.6"
# RVM installed in multi-user mode. However cap assume rvm is installed in single user mode.
# Create a soft link to fake it.
RUN mkdir -p ~/.rvm/bin && ln -s /usr/local/rvm/bin/rvm ~/.rvm/bin/rvm

COPY Gemfile /SAPI/Gemfile
COPY Gemfile.lock /SAPI/Gemfile.lock

ENV BUNDLE_SILENCE_ROOT_WARNING=1
RUN /bin/bash -c "source /etc/profile.d/rvm.sh \
&& gem install bundler:2.2.33 \
&& bundle"

ENTRYPOINT ["/bin/bash", "-l"]

##########################################
## Run the following in container
##########################################
# /bin/bash --rcfile cap-deploy-shell.sh
# [Enter your passphrase]
# root@commit:/SAPI$ CAP_BRANCH=<branch> cap staging deploy
#
##########################################
# Alternatively, from outside docker
##########################################
# docker exec -it sapi-cap-deploy /bin/bash --rcfile cap-deploy-shell.sh
# [Enter your passphrase]
# root@commit:/SAPI# CAP_BRANCH=<branch> cap staging deploy
Loading

0 comments on commit 3bc9fdd

Please sign in to comment.