Skip to content

Commit

Permalink
Merge pull request #1002 from thecartercenter/infrastructure/upgrades…
Browse files Browse the repository at this point in the history
…-specs-sprockets

upgrades, specs, and sprockets
  • Loading branch information
cooperka authored Jul 24, 2024
2 parents eb80900 + 65efad7 commit d9c0dad
Show file tree
Hide file tree
Showing 71 changed files with 158 additions and 172 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ jobs:
- name: Setup test database
run: |
cp config/database.yml.ci config/database.yml
bin/rails db:drop
bin/rails db:setup
bin/rails db:test:prepare
- name: Install Chromedriver
uses: nanasess/setup-chromedriver@master
- name: Configure Chromedriver
Expand Down
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ Metrics/PerceivedComplexity:
Exclude:
- db/migrate/*

Metrics/ModuleLength:
Exclude:
- spec/**/*

Metrics/ParameterLists:
CountKeywordArgs: false

Expand Down
13 changes: 5 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ gem "spreadsheet" # For XLSForm export
gem "term-ansicolor", "~> 1.3"
gem "terrapin", "~> 0.6.0"
gem "thor", "~> 1.0"
gem "twilio-ruby", "~> 6.9.0" # Does not use semver after v5, watch out!
gem "twilio-ruby", "~> 7.2.0" # Does not use semver after v5, watch out!

# JS/CSS
gem "bootstrap", "~> 4.3"
Expand Down Expand Up @@ -88,7 +88,7 @@ gem "acts_as_list"

# Caching
gem "actionpack-page_caching", "~> 1.1"
gem "bootsnap", "~> 1.4", require: false, group: [:production]
gem "bootsnap", "~> 1.4", require: false
gem "dalli", "~> 3.2"

# DB
Expand Down Expand Up @@ -116,8 +116,7 @@ gem "scout_apm", "~> 5.0"
gem "sentry-ruby", "~> 5.0"
gem "sentry-rails", "~> 5.0" # rubocop:disable Bundler/OrderedGems

# Force Sprockets to stay on v3 for now.
gem "sprockets", "~> 3"
gem "sprockets"

# The below are used for building load test plans.
# Needed in prod because test plans are built on prod instances.
Expand Down Expand Up @@ -155,9 +154,8 @@ group :development, :test do
gem "factory_bot_rails", "~> 4.11"
gem "mocha", "~> 1.1"

# Feature specs
# system specs
gem "capybara", "~> 3.30"
gem "capybara-screenshot", "~> 1.0"
gem "launchy", "~> 2.5" # For auto-opening capybara html file
gem "puma", "~> 5.6"
gem "selenium-webdriver", "~> 4.15.0" # TODO: Can't upgrade to 4.17 until Rails 7 + Ruby 3.3
Expand All @@ -177,9 +175,8 @@ group :development, :test do
gem "annotate", "~> 3.1"
gem "assert_difference", "~> 1.0" # Deprecated: Barely used, convert usage to something else.
gem "awesome_print", "~> 1.6"
gem "database_cleaner", "~> 2.0"
gem "db-query-matchers", "~> 0.10"
gem "rubocop", "1.22.3" # Hound supported versions: http://help.houndci.com/en/articles/2461415-supported-linters
gem "rubocop"
gem "rubocop-rails", "~> 2.8"
gem "rubocop-rake", "~> 0.6.0"
gem "rubocop-rspec", "~> 2.0"
Expand Down
43 changes: 17 additions & 26 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,6 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
capybara-screenshot (1.0.26)
capybara (>= 1.0, < 4)
launchy
choice (0.2.0)
chronic (0.10.2)
chunky_png (1.4.0)
Expand All @@ -216,12 +213,6 @@ GEM
csv (3.3.0)
daemons (1.4.1)
dalli (3.2.8)
database_cleaner (2.0.2)
database_cleaner-active_record (>= 2, < 3)
database_cleaner-active_record (2.1.0)
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
date (3.3.4)
db-query-matchers (0.12.0)
activesupport (>= 4.0, < 7.2)
Expand Down Expand Up @@ -339,6 +330,7 @@ GEM
json (2.7.2)
jwt (2.8.2)
base64
language_server-protocol (3.17.0.3)
launchy (2.5.2)
addressable (~> 2.8)
letter_opener (1.10.0)
Expand Down Expand Up @@ -532,15 +524,17 @@ GEM
rspec-mocks (~> 3.13)
rspec-support (~> 3.13)
rspec-support (3.13.1)
rubocop (1.22.3)
rubocop (1.64.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.12.0, < 2.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.3)
parser (>= 3.3.1.0)
rubocop-rails (2.15.2)
Expand Down Expand Up @@ -599,13 +593,12 @@ GEM
spreadsheet (1.3.1)
bigdecimal
ruby-ole
sprockets (3.7.3)
base64
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.5.1)
actionpack (>= 6.1)
activesupport (>= 6.1)
rack (>= 2.2.4, < 4)
sprockets-rails (3.4.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
stringio (3.1.1)
strscan (3.1.0)
Expand All @@ -624,7 +617,7 @@ GEM
tins (1.33.0)
bigdecimal
sync
twilio-ruby (6.9.1)
twilio-ruby (7.2.2)
faraday (>= 0.9, < 3.0)
jwt (>= 1.5, < 3.0)
nokogiri (>= 1.6, < 2.0)
Expand Down Expand Up @@ -695,13 +688,11 @@ DEPENDENCIES
bullet (~> 7.1)
cancancan (~> 3.1)
capybara (~> 3.30)
capybara-screenshot (~> 1.0)
clipboard-rails (~> 1.7)
closure_tree!
csv
daemons (~> 1.2)
dalli (~> 3.2)
database_cleaner (~> 2.0)
db-query-matchers (~> 0.10)
delayed_job_active_record (~> 4.1)
descriptive_statistics (~> 2.5)
Expand Down Expand Up @@ -758,7 +749,7 @@ DEPENDENCIES
rspec-collection_matchers (~> 1.1)
rspec-github (~> 2.4)
rspec-rails (~> 6.0)
rubocop (= 1.22.3)
rubocop
rubocop-rails (~> 2.8)
rubocop-rake (~> 0.6.0)
rubocop-rspec (~> 2.0)
Expand All @@ -772,13 +763,13 @@ DEPENDENCIES
sentry-ruby (~> 5.0)
spinjs-rails (~> 1.3.0)
spreadsheet
sprockets (~> 3)
sprockets
sys-filesystem (~> 1.4)
term-ansicolor (~> 1.3)
terrapin (~> 0.6.0)
thor (~> 1.0)
timecop (= 0.9.6)
twilio-ruby (~> 6.9.0)
twilio-ruby (~> 7.2.0)
uglifier (~> 4.2)
vcr (~> 6.0)
versionist (~> 2.0)
Expand Down
3 changes: 3 additions & 0 deletions app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//= link_tree ../images
//= link_tree ../../../vendor/assets
//= link application.js
3 changes: 2 additions & 1 deletion app/controllers/ping_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ class PingController < ApplicationController

# Used by uptime checker
def show
@site_name = current_mission_config.site_name
@tests = {}
@tests[:dj_running] = Utils::DelayedJobChecker.instance.ok?
@ok = @tests.values.all?
@version = Cnfg.system_version
@version = Cnfg.system_version(detailed: true)
render(layout: nil, formats: :text, status: @ok ? :ok : :service_unavailable)
end
end
2 changes: 1 addition & 1 deletion app/views/ping/show.text.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% @title = "Ping" -%>
ELMO - <%= @ok ? "OK" : "NOT OK" %>
<%= @site_name %> - <%= @ok ? "OK" : "NOT OK" %>
App is running.
Version is <%= @version %>.
Delayed Job is <%= @tests[:dj_running] ? "" : "NOT " %>ok.
49 changes: 37 additions & 12 deletions lib/config_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,33 @@ def offline_mode?
end

# read system version from file
def system_version
@system_version ||= File.read(Rails.root.join("VERSION")).strip
def system_version(detailed: false)
return @system_version if @system_version.present? && !detailed
return @detailed_system_version if @detailed_system_version.present?

case Rails.env
when "development"
git_describe_tags = `git describe --tags`
git_branch = `git rev-parse --abbrev-ref HEAD`
@system_version = "#{git_describe_tags.strip} (#{git_branch.strip})"
@detailed_system_version = @system_version
else
version_file = File.read(Rails.root.join("VERSION")).strip if File.exist?(Rails.root.join("VERSION"))
version = version_file

@system_version = version
return @system_version unless detailed

revision_file = File.read(Rails.root.join("REVISION")) if File.exist?(Rails.root.join("REVISION"))
branch_file = File.read(Rails.root.join("BRANCH")) if File.exist?(Rails.root.join("BRANCH"))

revision = revision_file&.strip&.slice(0..8)&.then { |rev| "(#{rev})" }.presence
branch = branch_file&.strip&.then { |br| "[#{br}]" }.presence

@detailed_system_version = [version, revision, branch].compact.join(" ")
end

detailed ? @detailed_system_version : @system_version
end

# Locales we support that are displayed right-to-left.
Expand Down Expand Up @@ -59,7 +84,7 @@ def url_port
# Returns a hash of url options (port, protocol, host). Omits port if it's default for protocol.
def url_options
options = {protocol: url_protocol, host: url_host}
return options if url_protocol == "http" && url_port == 80 || url_protocol == "https" && url_port == 443
return options if (url_protocol == "http" && url_port == 80) || (url_protocol == "https" && url_port == 443)
options[:port] = url_port
options
end
Expand All @@ -73,19 +98,19 @@ def smtp_port
end

def smtp_domain
ENV["NEMO_SMTP_DOMAIN"]
ENV.fetch("NEMO_SMTP_DOMAIN", nil)
end

def smtp_authentication
ENV["NEMO_SMTP_AUTHENTICATION"]&.to_sym
end

def smtp_user_name
ENV["NEMO_SMTP_USER_NAME"]
ENV.fetch("NEMO_SMTP_USER_NAME", nil)
end

def smtp_password
ENV["NEMO_SMTP_PASSWORD"]
ENV.fetch("NEMO_SMTP_PASSWORD", nil)
end

# Returns a hash of SMTP options, omitting anything that's blank
Expand All @@ -102,31 +127,31 @@ def smtp_options
end

def google_maps_key
ENV["NEMO_GOOGLE_MAPS_API_KEY"]
ENV.fetch("NEMO_GOOGLE_MAPS_API_KEY", nil)
end

def scout_key
ENV["NEMO_SCOUT_KEY"]
ENV.fetch("NEMO_SCOUT_KEY", nil)
end

def sentry_dsn
ENV["NEMO_SENTRY_DSN"]
ENV.fetch("NEMO_SENTRY_DSN", nil)
end

def allow_missionless_sms?
ENV["NEMO_ALLOW_MISSIONLESS_SMS"] == "true"
end

def universal_sms_token
allow_missionless_sms? ? ENV["NEMO_UNIVERSAL_SMS_TOKEN"] : nil
allow_missionless_sms? ? ENV.fetch("NEMO_UNIVERSAL_SMS_TOKEN", nil) : nil
end

def recaptcha_public_key
ENV["NEMO_RECAPTCHA_PUBLIC_KEY"]
ENV.fetch("NEMO_RECAPTCHA_PUBLIC_KEY", nil)
end

def recaptcha_private_key
ENV["NEMO_RECAPTCHA_PRIVATE_KEY"]
ENV.fetch("NEMO_RECAPTCHA_PRIVATE_KEY", nil)
end

def storage_service
Expand Down
2 changes: 1 addition & 1 deletion spec/decorators/odk/condition_group_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "rails_helper"

module ODK
describe ConditionGroupDecorator, :odk, :reset_factory_sequences, database_cleaner: :truncate do
describe ConditionGroupDecorator, :odk, :reset_factory_sequences do
include_context "odk rendering"

let(:result) { decorate(condition_group).to_odk }
Expand Down
2 changes: 1 addition & 1 deletion spec/decorators/odk/form_item_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "rails_helper"

module ODK
describe FormItemDecorator, :odk, :reset_factory_sequences, database_cleaner: :truncate do
describe FormItemDecorator, :odk, :reset_factory_sequences do
include_context "odk rendering"

describe "xpath methods" do
Expand Down
2 changes: 1 addition & 1 deletion spec/jobs/dedupe_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
)
end

it "should dedupe correctly", database_cleaner: :truncate do
it "should dedupe correctly" do
# Start with two existing dupes, but are clean
described_class.perform_now
expect(Response.all.count).to eq(2)
Expand Down
2 changes: 1 addition & 1 deletion spec/models/sms/decoder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@
end
end

describe "complex hierarchy construction", database_cleaner: :truncate do
describe "complex hierarchy construction" do
it "builds response tree for nested groups with repeat" do
# QingGroup (root)
# QingGroup
Expand Down
Loading

0 comments on commit d9c0dad

Please sign in to comment.