From 58f6b73f0f1682309e248143ecdca8dc2d8b68d9 Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Fri, 25 Aug 2023 17:05:25 -0700 Subject: [PATCH] update capistrano deployment to work with ruby 3.0 - Mange ruby version with .ruby-version. This simplifies management of ruby versions across various github actions and capistrano scripts. - add capistrano-rbenv to simplify deployments to ubuntu system - remove capistrano-yarn, It is no longer in use. --- .github/workflows/brakeman-analysis.yml | 4 +- .github/workflows/deploy.yml | 3 +- .gitignore | 2 - .ruby-version | 1 + Capfile | 3 +- Gemfile | 4 +- Gemfile.lock | 129 +++++++++++++----------- config/deploy.rb | 6 +- 8 files changed, 81 insertions(+), 71 deletions(-) create mode 100644 .ruby-version diff --git a/.github/workflows/brakeman-analysis.yml b/.github/workflows/brakeman-analysis.yml index 6ad197b9b..007b47d01 100644 --- a/.github/workflows/brakeman-analysis.yml +++ b/.github/workflows/brakeman-analysis.yml @@ -22,12 +22,10 @@ jobs: # Customize the ruby version depending on your needs - name: Setup Ruby uses: ruby/setup-ruby@v1 - with: - ruby-version: '2.7' - name: Setup Brakeman env: - BRAKEMAN_VERSION: '5.4.0' # SARIF support is provided in Brakeman version 4.10+ + BRAKEMAN_VERSION: '6.0.1' # SARIF support is provided in Brakeman version 4.10+ run: | gem install brakeman --version $BRAKEMAN_VERSION diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2e6a91b0d..b72147a94 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -59,7 +59,6 @@ jobs: - uses: actions/checkout@v3 - uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7.7 # Not needed with a .ruby-version file bundler-cache: true # runs 'bundle install' and caches installed gems automatically - name: get-deployment-config uses: actions/checkout@v3 @@ -75,7 +74,7 @@ jobs: mkdir -p ~/.ssh ssh-keyscan -H ${{ secrets.SSH_JUMPHOST }} > ~/.ssh/known_hosts shell: bash - - uses: miloserdow/capistrano-deploy@master + - uses: miloserdow/capistrano-deploy@v3 with: target: ${{ env.TARGET }} # which environment to deploy deploy_key: ${{ secrets.DEPLOY_ENC_KEY }} # Name of the variable configured in Settings/Secrets of your github project diff --git a/.gitignore b/.gitignore index ff9d6919a..854ec059e 100644 --- a/.gitignore +++ b/.gitignore @@ -25,8 +25,6 @@ config/deploy/* /public/assets/ nohup.out -.ruby-version - # Ignore editor files .idea *.swp diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 000000000..6a81b4c83 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.7.8 diff --git a/Capfile b/Capfile index 8cbf6f87e..7f36a40d9 100644 --- a/Capfile +++ b/Capfile @@ -15,7 +15,7 @@ require 'capistrano/deploy' # https://github.com/capistrano/rails # # require 'capistrano/rvm' -# require 'capistrano/rbenv' +require 'capistrano/rbenv' # require 'capistrano/chruby' require 'capistrano/bundler' require "capistrano/scm/git" @@ -23,7 +23,6 @@ install_plugin Capistrano::SCM::Git #require 'capistrano/rails/assets' #require 'capistrano/rails/migrations' require 'capistrano/rails' -require 'capistrano/yarn' require 'capistrano/locally' # Loads custom tasks from `lib/capistrano/tasks' if you have any defined. diff --git a/Gemfile b/Gemfile index 19086b53d..34cc7620b 100644 --- a/Gemfile +++ b/Gemfile @@ -61,12 +61,12 @@ end group :development do # Capistrano Deployment gem 'bcrypt_pbkdf', '>= 1.0', '< 2.0', require: false # https://github.com/miloserdow/capistrano-deploy/issues/42 - gem 'capistrano', '~> 3.11', require: false + gem 'capistrano', '~> 3.17', require: false gem 'capistrano-bundler', require: false + gem 'capistrano-rbenv', require: false gem 'capistrano-locally', require: false gem 'capistrano-passenger', require: false gem 'capistrano-rails', '~> 1.4', require: false - gem 'capistrano-yarn', require: false gem 'ed25519', '>= 1.2', '< 2.0', require: false # https://github.com/miloserdow/capistrano-deploy/issues/42 gem 'html2haml' gem 'listen' diff --git a/Gemfile.lock b/Gemfile.lock index 9c2bab7ff..6708e63ac 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -77,21 +77,22 @@ GEM minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) - addressable (2.8.4) + addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) - airbrussh (1.4.1) + airbrussh (1.4.2) sshkit (>= 1.6.1, != 1.7.0) ast (2.4.2) autoprefixer-rails (10.4.13.0) execjs (~> 2) + base64 (0.1.1) bcrypt_pbkdf (1.1.0) bootstrap (4.1.3) autoprefixer-rails (>= 6.0.3) popper_js (>= 1.12.9, < 2) sass (>= 3.5.2) - brakeman (5.4.1) + brakeman (6.0.1) builder (3.2.4) - capistrano (3.17.2) + capistrano (3.17.3) airbrussh (>= 1.0.0) i18n rake (>= 10.0.0) @@ -102,12 +103,13 @@ GEM capistrano (~> 3.0) capistrano-passenger (0.2.1) capistrano (~> 3.0) - capistrano-rails (1.6.2) + capistrano-rails (1.6.3) capistrano (~> 3.1) capistrano-bundler (>= 1.1, < 3) - capistrano-yarn (2.0.2) - capistrano (~> 3.0) - capybara (3.39.0) + capistrano-rbenv (2.2.0) + capistrano (~> 3.1) + sshkit (~> 1.3) + capybara (3.39.2) addressable matrix mini_mime (>= 0.1.3) @@ -123,7 +125,7 @@ GEM crass (1.0.6) cube-ruby (0.0.3) daemons (1.4.1) - dalli (3.2.4) + dalli (3.2.5) date (3.3.3) diff-lcs (1.5.0) domain_name (0.5.20190701) @@ -132,7 +134,7 @@ GEM erubi (1.12.0) erubis (2.7.0) eventmachine (1.2.7) - excon (0.99.0) + excon (0.102.0) execjs (2.8.1) faraday (2.0.1) faraday-net_http (~> 2.0) @@ -147,7 +149,7 @@ GEM flamegraph (0.9.5) globalid (1.1.0) activesupport (>= 5.0) - graphql (2.0.21) + graphql (2.0.26) graphql-client (0.18.0) activesupport (>= 3.0) graphql @@ -162,22 +164,23 @@ GEM http-accept (1.7.0) http-cookie (1.0.5) domain_name (~> 0.5) - i18n (1.13.0) + i18n (1.14.1) concurrent-ruby (~> 1.0) iconv (1.0.8) - jquery-rails (4.5.1) + jquery-rails (4.6.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) jquery-ui-rails (6.0.1) railties (>= 3.2.16) json (2.6.3) + language_server-protocol (3.17.0.3) listen (3.8.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.20.0) + loofah (2.21.3) crass (~> 1.0.2) - nokogiri (>= 1.5.9) + nokogiri (>= 1.12.0) lz4-ruby (0.3.3) mail (2.8.1) mini_mime (>= 0.1.1) @@ -187,15 +190,15 @@ GEM marcel (1.0.2) matrix (0.4.2) method_source (1.0.0) - mime-types (3.4.1) + mime-types (3.5.1) mime-types-data (~> 3.2015) - mime-types-data (3.2023.0218.1) - mini_mime (1.1.2) - minitest (5.18.0) + mime-types-data (3.2023.0808) + mini_mime (1.1.5) + minitest (5.19.0) multi_json (1.15.0) multipart-post (2.3.0) mysql2 (0.5.5) - net-imap (0.3.4) + net-imap (0.3.7) date net-protocol net-pop (0.1.2) @@ -206,28 +209,31 @@ GEM net-ssh (>= 2.6.5, < 8.0.0) net-smtp (0.3.3) net-protocol - net-ssh (7.1.0) + net-ssh (7.2.0) netrc (0.11.0) - newrelic_rpm (9.2.0) + newrelic_rpm (9.4.2) nio4r (2.5.9) - nokogiri (1.14.3-x86_64-darwin) + nokogiri (1.15.4-arm64-darwin) + racc (~> 1.4) + nokogiri (1.15.4-x86_64-darwin) racc (~> 1.4) - nokogiri (1.14.3-x86_64-linux) + nokogiri (1.15.4-x86_64-linux) racc (~> 1.4) - oj (3.14.3) + oj (3.16.0) open_uri_redirections (0.2.1) parallel (1.23.0) - parser (3.2.2.1) + parser (3.2.2.3) ast (~> 2.4.1) + racc popper_js (1.16.1) pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) psych (3.3.4) - public_suffix (5.0.1) - racc (1.6.2) - rack (2.2.7) - rack-mini-profiler (3.1.0) + public_suffix (5.0.3) + racc (1.7.1) + rack (2.2.8) + rack-mini-profiler (3.1.1) rack (>= 1.2.0) rack-test (2.1.0) rack (>= 1.3) @@ -246,11 +252,13 @@ GEM bundler (>= 1.15.0) railties (= 6.1.5.1) sprockets-rails (>= 2.0.0) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.5.0) - loofah (~> 2.19, >= 2.19.1) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) rails_autolink (1.1.8) actionview (> 3.1) activesupport (> 3.1) @@ -269,45 +277,47 @@ GEM rdoc (6.3.3) recaptcha (5.9.0) json - regexp_parser (2.8.0) + regexp_parser (2.8.1) rest-client (2.1.0) http-accept (>= 1.7.0, < 2.0) http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rexml (3.2.5) + rexml (3.2.6) rspec-core (3.12.2) rspec-support (~> 3.12.0) rspec-expectations (3.12.3) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) - rspec-mocks (3.12.5) + rspec-mocks (3.12.6) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) - rspec-rails (6.0.1) + rspec-rails (6.0.3) actionpack (>= 6.1) activesupport (>= 6.1) railties (>= 6.1) - rspec-core (~> 3.11) - rspec-expectations (~> 3.11) - rspec-mocks (~> 3.11) - rspec-support (~> 3.11) - rspec-support (3.12.0) - rubocop (1.50.2) + rspec-core (~> 3.12) + rspec-expectations (~> 3.12) + rspec-mocks (~> 3.12) + rspec-support (~> 3.12) + rspec-support (3.12.1) + rubocop (1.56.1) + base64 (~> 0.1.1) json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.0.0) + parser (>= 3.2.2.3) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.0, < 2.0) + rubocop-ast (>= 1.28.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.28.0) + rubocop-ast (1.29.0) parser (>= 3.2.1.0) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) - ruby_parser (3.20.0) + ruby_parser (3.20.3) sexp_processor (~> 4.16) sass (3.7.4) sass-listen (~> 4.0.0) @@ -321,7 +331,7 @@ GEM sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) select2-rails (4.0.13) - sexp_processor (4.16.1) + sexp_processor (4.17.0) spawnling (2.1.5) sprockets (3.7.2) concurrent-ruby (~> 1.0) @@ -330,18 +340,18 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - sshkit (1.21.4) + sshkit (1.21.5) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) stackprof (0.2.25) - temple (0.10.0) + temple (0.10.2) thin (1.8.2) daemons (~> 1.0, >= 1.0.9) eventmachine (~> 1.0, >= 1.0.4) rack (>= 1, < 3) - thor (1.2.1) - tilt (2.1.0) - timeout (0.3.2) + thor (1.2.2) + tilt (2.2.0) + timeout (0.4.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) uglifier (4.2.0) @@ -350,15 +360,16 @@ GEM unf_ext unf_ext (0.0.8.2) unicode-display_width (2.4.2) - websocket-driver (0.7.5) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) will_paginate (3.3.1) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.7) + zeitwerk (2.6.11) PLATFORMS + arm64-darwin-22 x86_64-darwin-21 x86_64-linux @@ -366,12 +377,12 @@ DEPENDENCIES bcrypt_pbkdf (>= 1.0, < 2.0) bootstrap (~> 4.1.0) brakeman - capistrano (~> 3.11) + capistrano (~> 3.17) capistrano-bundler capistrano-locally capistrano-passenger capistrano-rails (~> 1.4) - capistrano-yarn + capistrano-rbenv capybara chart-js-rails cube-ruby @@ -410,4 +421,4 @@ DEPENDENCIES will_paginate (~> 3.0) BUNDLED WITH - 2.3.22 + 2.4.18 diff --git a/config/deploy.rb b/config/deploy.rb index 4079eca0c..e7ad6276b 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -23,7 +23,7 @@ # set :format, :pretty # Default value for :log_level is :debug -set :log_level, :error +# set :log_level, :error # Default value for :pty is false # set :pty, true @@ -55,6 +55,10 @@ # If you don't set `:passenger_restart_with_touch`, capistrano-passenger will check what version of passenger you are running # and use `passenger-config restart-app` if it is available in that version. +# rbenv ruby version +set :rbenv_type, :system +set :rbenv_ruby, File.read('.ruby-version').strip + desc "Check if agent forwarding is working" task :forwarding do on roles(:all) do |h|