From de871186046cb956d2405c95f6a06b491e8c4509 Mon Sep 17 00:00:00 2001 From: Priya Rani Date: Wed, 15 Nov 2023 20:40:37 +0530 Subject: [PATCH 1/2] OTWO-7142 Remove unused gem --- Gemfile | 7 ------- Gemfile.lock | 37 ------------------------------------- 2 files changed, 44 deletions(-) diff --git a/Gemfile b/Gemfile index e6bb3c40d..d0394ff5a 100644 --- a/Gemfile +++ b/Gemfile @@ -53,13 +53,6 @@ gem 'will_paginate-bootstrap' group :development do gem 'better_errors' gem 'bootsnap', '~> 1.10.3', require: false - gem 'capistrano' - gem 'capistrano-faster-assets' - gem 'capistrano-passenger' - gem 'capistrano-rails' - gem 'capistrano-rbenv', '~> 2.0' - gem 'capistrano-sidekiq' - gem 'ed25519' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 806e5e116..8c62a41b9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -67,8 +67,6 @@ GEM airbrake (5.8.1) airbrake-ruby (~> 1.8) airbrake-ruby (1.8.0) - airbrussh (1.4.0) - sshkit (>= 1.6.1, != 1.7.0) amq-protocol (2.3.2) arbre (1.5.0) activesupport (>= 3.0.0, < 7.1) @@ -108,27 +106,6 @@ GEM bunny-mock (1.7.0) bunny (>= 1.7) byebug (11.1.3) - capistrano (3.16.0) - airbrussh (>= 1.0.0) - i18n - rake (>= 10.0.0) - sshkit (>= 1.9.0) - capistrano-bundler (2.0.1) - capistrano (~> 3.1) - capistrano-faster-assets (1.1.0) - capistrano (>= 3.1) - capistrano-passenger (0.2.1) - capistrano (~> 3.0) - capistrano-rails (1.6.1) - capistrano (~> 3.1) - capistrano-bundler (>= 1.1, < 3) - capistrano-rbenv (2.2.0) - capistrano (~> 3.1) - sshkit (~> 1.3) - capistrano-sidekiq (2.0.0) - capistrano (>= 3.9.0) - capistrano-bundler - sidekiq (>= 6.0) chronic (0.10.2) clearance (2.5.0) actionmailer (>= 5.0) @@ -172,7 +149,6 @@ GEM dotenv-rails (2.7.6) dotenv (= 2.7.6) railties (>= 3.2) - ed25519 (1.2.4) email_validator (2.2.3) activemodel erubi (1.10.0) @@ -298,9 +274,6 @@ GEM railties (>= 4.1) mocha (1.13.0) msgpack (1.7.1) - net-scp (3.0.0) - net-ssh (>= 2.6.5, < 7.0.0) - net-ssh (6.1.0) nio4r (2.5.8) nokogiri (1.13.10) mini_portile2 (~> 2.8.0) @@ -444,9 +417,6 @@ GEM activesupport (>= 5.2) sprockets (>= 3.0.0) sql_tracker (1.3.2) - sshkit (1.21.2) - net-scp (>= 1.1.2) - net-ssh (>= 2.8.0) statsd-instrument (3.1.2) sysexits (1.2.0) temple (0.8.2) @@ -499,12 +469,6 @@ DEPENDENCIES bunny bunny-mock byebug - capistrano - capistrano-faster-assets - capistrano-passenger - capistrano-rails - capistrano-rbenv (~> 2.0) - capistrano-sidekiq clearance coffee-rails coffee-script-source (~> 1.8.0) @@ -512,7 +476,6 @@ DEPENDENCIES ddtrace doorkeeper (~> 4.4.0) dotenv-rails - ed25519 factory_bot_rails faker feedjira From 54391efdc952434529f92905937bbb01a1bf8a07 Mon Sep 17 00:00:00 2001 From: Priya Rani Date: Wed, 15 Nov 2023 22:14:09 +0530 Subject: [PATCH 2/2] Remove unused files --- .env | 6 --- Capfile | 22 -------- Gemfile | 1 - Gemfile.lock | 4 -- config/deploy.rb | 32 ------------ config/deploy/production.rb | 14 ------ config/deploy/staging.rb | 31 ------------ config/schedule.rb | 36 ------------- lib/capistrano/tasks/docker_deploy.rake | 50 ------------------- .../tasks/update_configuration.rake | 20 -------- 10 files changed, 216 deletions(-) delete mode 100644 Capfile delete mode 100644 config/deploy.rb delete mode 100644 config/deploy/production.rb delete mode 100644 config/deploy/staging.rb delete mode 100644 config/schedule.rb delete mode 100644 lib/capistrano/tasks/docker_deploy.rake delete mode 100644 lib/capistrano/tasks/update_configuration.rake diff --git a/.env b/.env index 60d3410cf..2f841cdf2 100644 --- a/.env +++ b/.env @@ -81,12 +81,6 @@ KB_EXCHANGE_NAME = KB_EXCHANGE_KEY = KB_CONNECTION_TIMEOUT = -HC_CHECK_BROKEN_LINKS_URL = 'http://example.com' -HC_HOME_PAGE_STATS_URL = 'http://example.com' -HC_RSS_FEEDS_SYNC_URL = 'http://example.com' -HC_CLEANUP_VULNERABILITIES_URL = 'http://example.com' -HC_KB_SEND_UPDATES_URL = 'http://example.com' - SQL_TRACKER='enabled' OHLOH_ANALYTICS_API_URL= OHLOH_ANALYTICS_CLIENT_REGISTRATION_ID= diff --git a/Capfile b/Capfile deleted file mode 100644 index 9cdccb449..000000000 --- a/Capfile +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Load DSL and set up stages -require 'capistrano/setup' - -# Include default deployment tasks -require 'capistrano/deploy' -require 'capistrano/scm/git' -install_plugin Capistrano::SCM::Git - -require 'capistrano/rails' -require 'capistrano/faster_assets' -require 'capistrano/passenger' - -require 'whenever/capistrano' -require 'capistrano/sidekiq' -# Load custom tasks from `lib/capistrano/tasks' if you have any defined -Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } - -require 'capistrano/rbenv' -set :rbenv_type, :user -set :rbenv_ruby, '2.6.9' diff --git a/Gemfile b/Gemfile index d0394ff5a..07f9887a2 100644 --- a/Gemfile +++ b/Gemfile @@ -46,7 +46,6 @@ gem 'thor' gem 'twitter-bootstrap-rails', '~> 3.2' gem 'tzinfo', '~> 1.2.10' gem 'uglifier', '>= 2.7.2' -gem 'whenever', require: false gem 'will_paginate' gem 'will_paginate-bootstrap' diff --git a/Gemfile.lock b/Gemfile.lock index 8c62a41b9..130a3f436 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -106,7 +106,6 @@ GEM bunny-mock (1.7.0) bunny (>= 1.7) byebug (11.1.3) - chronic (0.10.2) clearance (2.5.0) actionmailer (>= 5.0) activemodel (>= 5.0) @@ -444,8 +443,6 @@ GEM websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - whenever (1.0.0) - chronic (>= 0.6.3) will_paginate (3.3.1) will_paginate-bootstrap (1.0.2) will_paginate (>= 3.0.3) @@ -524,7 +521,6 @@ DEPENDENCIES uglifier (>= 2.7.2) vcr webmock - whenever will_paginate will_paginate-bootstrap diff --git a/config/deploy.rb b/config/deploy.rb deleted file mode 100644 index 5240e4c05..000000000 --- a/config/deploy.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -lock '3.16.0' - -set :whoami, `whoami`.strip -set :default_env, 'PATH' => '/home/serv-deployer/.rbenv/shims:$PATH', - 'BASH_ENV' => '/home/serv-deployer/.production_vars' - -set :application, ENV['APP'] || 'openhub' -set :repo_url, 'https://github.com/blackducksoftware/ohloh-ui.git' -set :user, 'serv-deployer' -set :use_sudo, false -set :passenger_restart_with_sudo, false -set :branch, ENV['branch'] || :main -# role :reverification_server, ['deployer@prd-oh-web02.dc2.lan'] - -set :deploy_to, "/var/local/#{fetch(:application)}" - -# Use remote cache for deployment -set :deploy_via, :remote_cache -set :copy_exclude, ['.git'] - -# Defaults to false. If true, it's skip migration if files in db/migrate not modified -set :conditionally_migrate, true - -set :pty, false - -set :sidekiq_log, File.join(shared_path, 'log', 'sidekiq.log') -set :sidekiq_config, nil -set :sidekiq_default_hooks, true - -set :whenever_roles, :sidekiq diff --git a/config/deploy/production.rb b/config/deploy/production.rb deleted file mode 100644 index b82d33503..000000000 --- a/config/deploy/production.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -set :web_heads, ['serv-deployer@sdc-oh-web04.prd.sig.synopsys.com', - 'serv-deployer@sdc-oh-web05.prd.sig.synopsys.com', - 'serv-deployer@sdc-oh-web06.prd.sig.synopsys.com'] - -set :utility, 'serv-deployer@sdc-oh-utility01.prd.sig.synopsys.com' - -namespace :deploy do - task started: 'docker:deploy' - task offline: 'docker:offline' - task online: 'docker:online' - task utility: 'docker:utility' -end diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb deleted file mode 100644 index bfd0e9823..000000000 --- a/config/deploy/staging.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -role :web_1, %w[serv-deployer@us1a-oh-web01.nprd.sig.synopsys.com] -# role :web_2, %w[serv-deployer@oh-web02.dc1.lan] -role :web_3, %w[serv-deployer@us1a-oh-web03.nprd.sig.synopsys.com] - -role :web, ['serv-deployer@us1a-oh-web01.nprd.sig.synopsys.com', 'serv-deployer@us1a-oh-web03.nprd.sig.synopsys.com'] - -role :selenium, %w[serv-deployer@us1a-oh-web03.nprd.sig.synopsys.com] - -# role :db, %w[serv-deployer@oh-utility02.dc1.lan], primary: true - -# role :utility, %w[serv-deployer@oh-utility02.dc1.lan] - -set :user, 'serv-deployer' -set :default_env, 'PATH' => '/home/serv-deployer/.rbenv/shims:$PATH', - 'BASH_ENV' => '/home/serv-deployer/.production_vars' - -# All passenger_roles get a deploy:restart after deploy:publishing. -set :passenger_roles, %i[web web_1 web_2 web_3 web_4 web_5 web_7 web_8] -set :sidekiq_role, [:utility] -set :rails_env, 'staging' - -# shared/.env.staging contains environment specific dotenv overrides. -set :linked_files, %w[.env.staging] - -set sidekiq_env: fetch(:rails_env) -set :assets_roles, %i[web_1 web_2 web_3 web_4 web_5 web_6 web_7 web_8] -set :passenger_restart_with_touch, true - -before 'deploy:check:linked_files', 'deploy:update_configuration' diff --git a/config/schedule.rb b/config/schedule.rb deleted file mode 100644 index 73ad584b1..000000000 --- a/config/schedule.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -require 'dotenv' -Dotenv.load('.env.production', '.env') - -env :PATH, ENV['PATH'] -set :environment, 'production' -set :output, error: 'log/cron_error.log', standard: 'log/cron.log' - -bash_cmd = "/bin/bash -l -c ':job'" -curl_cmd = 'curl -fsS --retry 5 -o /dev/null' - -set :job_template, "#{bash_cmd} && #{curl_cmd} #{ENV['HC_CHECK_BROKEN_LINKS_URL']}" -every 2.weeks, at: '11.00 am', roles: [:sidekiq] do - rake 'check_broken_links' -end - -set :job_template, "#{bash_cmd} && #{curl_cmd} #{ENV['HC_HOME_PAGE_STATS_URL']}" -every 1.day, at: '04.00 am', roles: [:sidekiq] do - rake 'home_page_stats' -end - -set :job_template, "#{bash_cmd} && #{curl_cmd} #{ENV['HC_RSS_FEEDS_SYNC_URL']}" -every 1.day, at: '4:30 am', roles: [:sidekiq] do - rake 'rss:feeds:sync' -end - -set :job_template, "#{bash_cmd} && #{curl_cmd} #{ENV['HC_CLEANUP_VULNERABILITIES_URL']}" -every 1.day, at: '12:00 am', roles: [:sidekiq] do - rake 'cleanup_vulnerabilities' -end - -set :job_template, "#{bash_cmd} && #{curl_cmd} #{ENV['HC_KB_SEND_UPDATES_URL']}" -every 30.minutes, roles: [:sidekiq] do - rake 'kb_updater:send_updates', output: { error: '/tmp/kb_updater.err', standard: '/tmp/kb_updater.out' } -end diff --git a/lib/capistrano/tasks/docker_deploy.rake b/lib/capistrano/tasks/docker_deploy.rake deleted file mode 100644 index ffd165e87..000000000 --- a/lib/capistrano/tasks/docker_deploy.rake +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: true - -namespace :docker do - task :deploy do - on fetch(:web_heads), in: :parallel do - execute('wget -O docker-compose.yml https://raw.githubusercontent.com/blackducksoftware/ohloh-ui/main/docker-compose.yml') - execute('docker pull sigost/ohloh-ui:latest') - end - - # Run the bundle install, assets on one of the web host - on fetch(:web_heads).last do - execute('docker-compose run --rm web bundle install') - execute('docker-compose run --rm web bundle exec rake assets:precompile RAILS_ENV=production') - end - - # Rebuild the container with the latest changes (code, assets) - on fetch(:web_heads), in: :parallel do - execute('docker-compose up -d --build') - end - end -end - -namespace :docker do - task :offline do - ask(:input, 'Are you sure you want to put the site in MAINTENANCE mode? (y/n)') - if fetch(:input).to_s.downcase == 'y' - on fetch(:web_heads), in: :parallel do - execute('docker pull sigost/openhub:offline') - execute('docker stop $DOCKER_HOST_NAME') - execute('docker run --name=offline --rm -d -p 443:443 sigost/openhub:offline') - end - puts 'Please run cap production deploy:online to bring the site back online.' - end - end - - task :online do - on fetch(:web_heads), in: :parallel do - execute('docker stop offline') - execute('docker start $DOCKER_HOST_NAME') - end - end - - task :utility do - on fetch(:utility) do - execute('wget -O docker-compose.yml https://raw.githubusercontent.com/blackducksoftware/ohloh-ui/main/docker-compose-utility.yml') - execute('docker pull sigost/ohloh-ui:latest') - execute('docker-compose up -d --build') - end - end -end diff --git a/lib/capistrano/tasks/update_configuration.rake b/lib/capistrano/tasks/update_configuration.rake deleted file mode 100644 index cface02bb..000000000 --- a/lib/capistrano/tasks/update_configuration.rake +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -namespace :deploy do - desc 'Sync openhub-config data in shared/openhub-config' - task :update_configuration do - on roles(:all) do - config_dir_path = shared_path.join('openhub-config') - - if test "[ -e #{config_dir_path}/.git ]" - execute :git, '-C', config_dir_path, :pull - else - execute(:git, :clone, 'https://github.com:blackducksoftware/openhub-config', config_dir_path) - end - - config_path = config_dir_path.join('.env.*.openhub') - execute(:cp, config_path, shared_path) - execute :rename, '-f', "'s/\\.openhub//'", shared_path.join('.env.*.openhub') - end - end -end