Skip to content

Commit

Permalink
Do not exclude Ruby files from all Rubocop checks
Browse files Browse the repository at this point in the history
- Fixes deploy problem
- Minor style fixes to config/environments files
  • Loading branch information
maxkadel committed Nov 14, 2024
1 parent e177035 commit ad87b94
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 98 deletions.
6 changes: 3 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ AllCops:
- 'script/**/*'
- 'vendor/**/*'
- 'bin/*'
- 'config/deploy.rb'
- 'config/initializers/blacklight_url_helper_behavior.rb'
- 'config/environments/**/*'
- 'node_modules/**/*'

Layout/IndentationConsistency:
Expand All @@ -35,3 +32,6 @@ Metrics/BlockLength:
- 'spec/**/*'
- 'lib/tasks/approvals.rake'
- 'config/routes.rb'
- config/environments/development.rb
- config/environments/production.rb
- config/environments/staging.rb
121 changes: 46 additions & 75 deletions config/deploy.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# frozen_string_literal: true

# config valid only for Capistrano 3.1
lock '>=3.2.1'
lock ">=3.2.1"

set :application, 'approvals'
set :repo_url, 'https://github.com/pulibrary/approvals.git'
set :application, "approvals"
set :repo_url, "https://github.com/pulibrary/approvals.git"

# gets overriden to development on staging deploy
set :branch, 'main'
set :branch, "main"

# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call

# Default deploy_to directory is /var/www/my_app
set :deploy_to, '/opt/approvals'
set :deploy_to, "/opt/approvals"

# Install yarn devDependencies, not just the prod ones
set :yarn_flags, '--silent --no-progress'
set :yarn_flags, "--silent --no-progress"

# Default value for :format is :pretty
# set :format, :pretty
Expand All @@ -28,16 +28,14 @@
# set :pty, true
set :branch, ENV["BRANCH"] || "main"


shared_path = "#{:deploy_to}/shared"
# shared_path = "deploy_to/shared"
# set :assets_prefix, '#{shared_path}/public'

## removing the following from linked files for the time being
# config/redis.yml config/devise.yml config/resque_pool.yml, config/recipients_list.yml, log/resque-pool.stderr.log log/resque-pool.stdout.log

# set :linked_files, %w{config/database.yml}
set :linked_dirs, %w{tmp/pids tmp/sockets log}

set :linked_dirs, %w[tmp/pids tmp/sockets log]

# Default value for :linked_files is []
# set :linked_files, %w{config/database.yml}
Expand All @@ -53,85 +51,84 @@
# set :keep_releases, 5
set :passenger_restart_with_touch, true

# rubocop:disable Metrics/BlockLength
namespace :approvals do

desc 'reset the database and reseed'
desc "reset the database and reseed"
task :reset do
on roles(:app) do
within current_path do
with :rails_env => fetch(:rails_env) do
execute :sudo, '/usr/sbin/service nginx stop'
execute :rake, 'db:drop db:create db:migrate'
execute :sudo, '/usr/sbin/service nginx start'
with rails_env: fetch(:rails_env) do
execute :sudo, "/usr/sbin/service nginx stop"
execute :rake, "db:drop db:create db:migrate"
execute :sudo, "/usr/sbin/service nginx start"
# we process the locations twice when the database is empty, since there is a chicken and egg situation
# The location needs to exist to attche an AA to it, but the AA must exist to attach it to a location.
# The location processing just ignores an AA that does not exists, so if we run it once the locations
# The location processing just ignores an AA that does not exists, so if we run it once the locations
# exists to connect with the new people. If we run it again after the people exists it connects the AAs.
execute :rake, 'approvals:load_locations'
execute :rake, 'approvals:process_reports'
execute :rake, 'approvals:load_locations'
execute :rake, 'approvals:make_requests_for_everyone'
execute :rake, "approvals:load_locations"
execute :rake, "approvals:process_reports"
execute :rake, "approvals:load_locations"
execute :rake, "approvals:make_requests_for_everyone"
end
end
end
end
end

desc 'Process the staff report now'
desc "Process the staff report now"
task :process_reports do
on roles(:app) do
within current_path do
with :rails_env => fetch(:rails_env) do
execute :rake, 'approvals:process_reports'
with rails_env: fetch(:rails_env) do
execute :rake, "approvals:process_reports"
end
end
end
end
end

desc 'Make Requests for everyone this can take a very long time'
desc "Make Requests for everyone this can take a very long time"
task :make_requests_for_everyone do
on roles(:app) do
within current_path do
with :rails_env => fetch(:rails_env) do
execute :rake, 'approvals:make_requests_for_everyone'
end
end
end
with rails_env: fetch(:rails_env) do
execute :rake, "approvals:make_requests_for_everyone"
end
end
end
end

desc 'Make Requests for a specific user'
desc "Make Requests for a specific user"
task :make_requests_for_user, [:netid] do |_t, args|
netid = args[:netid]
on roles(:app) do
within current_path do
with :rails_env => fetch(:rails_env) do
with rails_env: fetch(:rails_env) do
execute :rake, "approvals:make_requests_for_user[#{netid}]"
end
end
end
end
end
end
end

desc 'Add fake users to give [:netid] someone to supervise'
desc "Add fake users to give [:netid] someone to supervise"
task :make_me_a_supervisor, [:netid, :number] do |_t, args|
netid = args[:netid]
number = args[:number]
on roles(:app) do
within current_path do
with :rails_env => fetch(:rails_env) do
with rails_env: fetch(:rails_env) do
execute :rake, "approvals:make_me_a_supervisor[#{netid},#{number}]"
end
end
end
end
end
end
end
end


# rubocop:enable Metrics/BlockLength

namespace :deploy do
desc 'Restart application'
desc "Restart application"
task :restart do
on roles(:app), in: :sequence, wait: 5 do
# Your restart mechanism here, for example:
execute :touch, release_path.join('tmp/restart.txt')
execute :touch, release_path.join("tmp/restart.txt")
end
end

Expand All @@ -144,18 +141,8 @@
end
end

# TODO - We likely need a robot.txt
# task :robots_txt do
# on roles(:app) do
# within release_path do
# execute :rake, 'pulsearch:robots_txt'
# end
# end
# end
# after :publishing, :restart
# after :publishing, :robots_txt

after :finishing, 'deploy:cleanup'
after :finishing, "deploy:cleanup"
end

namespace :application do
# You can/ should apply this command to a subset of hosts
Expand All @@ -166,9 +153,7 @@
on roles(:app) do
count += 1
end
if count > (roles(:app).length / 2)
raise "You must run this command on no more than half the servers utilizing the --hosts= switch"
end
raise "You must run this command on no more than half the servers utilizing the --hosts= switch" if count > (roles(:app).length / 2)
on roles(:app) do
within release_path do
execute :touch, "public/remove-from-nginx"
Expand All @@ -187,17 +172,3 @@
end
end
end

# before "deploy:reverted", "deploy:assets:precompile"
# # We shouldn't need this because it should be built in to Rails 5.1
# # see https://github.com/rails/webpacker/issues/1037
# desc 'Run yarn install'
# task :yarn_install do
# on roles(:web) do
# within release_path do
# execute("cd #{release_path} && yarn install")
# end
# end
# end
# before "deploy:assets:precompile", "deploy:yarn_install"
# end
15 changes: 8 additions & 7 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

Expand All @@ -14,12 +15,12 @@

# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
if Rails.root.join('tmp', 'caching-dev.txt').exist?
if Rails.root.join("tmp", "caching-dev.txt").exist?
config.action_controller.perform_caching = true

config.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{2.days.to_i}"
"Cache-Control" => "public, max-age=#{2.days.to_i}"
}
else
config.action_controller.perform_caching = false
Expand All @@ -36,8 +37,8 @@
config.action_mailer.perform_caching = false
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "localhost",
:port => 1025
address: "localhost",
port: 1025
}

# Print deprecation notices to the Rails logger.
Expand All @@ -53,8 +54,8 @@
# config.action_view.raise_on_missing_translations = true

# location of the staff report (assuming current directory)
config.staff_report_location = 'Active Library Staff - Scheduled-en.csv'
config.balance_report_location = 'Balances for Employees Enrolled in Absence Management - Library-en-us.csv'
config.staff_report_location = "Active Library Staff - Scheduled-en.csv"
config.balance_report_location = "Balances for Employees Enrolled in Absence Management - Library-en-us.csv"

Rails.application.routes.default_url_options[:host] = 'localhost:3000'
Rails.application.routes.default_url_options[:host] = "localhost:3000"
end
11 changes: 6 additions & 5 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

Expand All @@ -20,7 +21,7 @@

# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?

# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
Expand Down Expand Up @@ -61,7 +62,7 @@

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'lib-ponyexpr-prod.princeton.edu',
address: "lib-ponyexpr-prod.princeton.edu",
enable_starttls: false,
open_timeout: 10,
read_timeout: 10
Expand Down Expand Up @@ -91,8 +92,8 @@
config.active_record.dump_schema_after_migration = false

# location of the mounted staff report
config.staff_report_location = '/mnt/dms-smbserve/bi-library-hr/prod/Department Absence Manager Report - Library-en.csv'
config.balance_report_location = '/mnt/dms-smbserve/bi-library-hr/prod/Balances for Employees Enrolled in Absence Management - Library-en-us.csv'
config.staff_report_location = "/mnt/dms-smbserve/bi-library-hr/prod/Department Absence Manager Report - Library-en.csv"
config.balance_report_location = "/mnt/dms-smbserve/bi-library-hr/prod/Balances for Employees Enrolled in Absence Management - Library-en-us.csv"

Rails.application.routes.default_url_options[:host] = 'approvals.princeton.edu'
Rails.application.routes.default_url_options[:host] = "approvals.princeton.edu"
end
13 changes: 7 additions & 6 deletions config/environments/staging.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

Expand All @@ -20,7 +21,7 @@

# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?

# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
Expand Down Expand Up @@ -58,8 +59,8 @@

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "localhost",
:port => 1025
address: "localhost",
port: 1025
}

# Ignore bad email addresses and do not raise email delivery errors.
Expand Down Expand Up @@ -90,8 +91,8 @@
config.active_record.dump_schema_after_migration = false

# location of the mounted staff report
config.staff_report_location = '/mnt/dms-smbserve/bi-library-hr/prod/Department Absence Manager Report - Library-en.csv'
config.balance_report_location = '/mnt/dms-smbserve/bi-library-hr/prod/Balances for Employees Enrolled in Absence Management - Library-en-us.csv'
config.staff_report_location = "/mnt/dms-smbserve/bi-library-hr/prod/Department Absence Manager Report - Library-en.csv"
config.balance_report_location = "/mnt/dms-smbserve/bi-library-hr/prod/Balances for Employees Enrolled in Absence Management - Library-en-us.csv"

Rails.application.routes.default_url_options[:host] = 'approvals-staging.princeton.edu'
Rails.application.routes.default_url_options[:host] = "approvals-staging.princeton.edu"
end
5 changes: 3 additions & 2 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
Rails.application.configure do
config.hosts = []
# Settings specified here will take precedence over those in config/application.rb.
Expand All @@ -16,7 +17,7 @@
# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{1.hour.to_i}"
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
}

# Show full error reports and disable caching.
Expand Down Expand Up @@ -45,5 +46,5 @@
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true

Rails.application.routes.default_url_options[:host] = 'localhost:3000'
Rails.application.routes.default_url_options[:host] = "localhost:3000"
end

0 comments on commit ad87b94

Please sign in to comment.