From 0060c679d15f187ad45b3d432f5a2398ff19d0a2 Mon Sep 17 00:00:00 2001 From: Kartiki Sharma Date: Thu, 18 Jan 2024 15:52:28 -0500 Subject: [PATCH 01/23] Update dev.yml --- dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev.yml b/dev.yml index 3327f5df7..6d9736d38 100644 --- a/dev.yml +++ b/dev.yml @@ -5,7 +5,7 @@ name: shipit-engine type: rails up: - - homebrew: + - packages: - sqlite - ruby: version: 2.7.5 From 39f9eae8ec2b6e9497bf20cfa095d90dbc185d4d Mon Sep 17 00:00:00 2001 From: Kartiki Sharma Date: Thu, 18 Jan 2024 15:39:17 -0500 Subject: [PATCH 02/23] Rails 7.1.1 upgrade Update CHANGELOG.md --- .github/workflows/main.yml | 2 +- CHANGELOG.md | 2 ++ docs/setup.md | 2 +- script/cibuild | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6994a87c8..6efee0c9f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -150,7 +150,7 @@ jobs: export SHIPIT_GEM_PATH="${PWD}" mkdir /tmp/new-app cd /tmp/new-app - gem install rails -v '~> 7.0.2' --no-document + gem install rails -v '~> 7.1.1' --no-document rails new shipit --skip-action-cable --skip-turbolinks --skip-action-mailer --skip-active-storage --skip-webpack-install --skip-action-mailbox --skip-action-text -m "${SHIPIT_GEM_PATH}/template.rb" env: SHIPIT_EDGE: "1" diff --git a/CHANGELOG.md b/CHANGELOG.md index cc7f00316..53f3ea8e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Unreleased +* Upgraded to Rails 7.1.1 + # 0.38.0 * Convert `commit_deployment_statuses.github_id` to bigint (#1312) diff --git a/docs/setup.md b/docs/setup.md index 4bf035fda..fbcf710f6 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -14,7 +14,7 @@ In the future we'd like to provide it fully packaged inside a Docker container, Shipit provides you with a Rails template. To bootstrap your Shipit installation: -1. If you don't have Rails installed, run this command: `gem install rails -v 7.0` +1. If you don't have Rails installed, run this command: `gem install rails -v 7.1.1` 2. Run this command: `rails _7.0_ new shipit --skip-action-cable --skip-turbolinks --skip-action-mailer --skip-active-storage --skip-webpack-install --skip-action-mailbox --skip-action-text -m https://raw.githubusercontent.com/Shopify/shipit-engine/main/template.rb` ## Creating the GitHub App diff --git a/script/cibuild b/script/cibuild index 3ed1e1a50..12d7377ac 100755 --- a/script/cibuild +++ b/script/cibuild @@ -38,8 +38,8 @@ case $SUITE in git config --global user.email "anonymous@example.com" git config --global user.name "Anonymous" - gem install rails -v 7.0 - rails _7.0_ new shipit -m "${TEMPLATE}" \ + gem install rails -v 7.1.1 + rails _7.1.1_ new shipit -m "${TEMPLATE}" \ --skip-action-cable \ --skip-turbolinks \ --skip-action-mailer \ From 649662b95eee29d0c51b1f31096523a672660605 Mon Sep 17 00:00:00 2001 From: Kartiki Sharma Date: Fri, 19 Jan 2024 15:53:58 -0500 Subject: [PATCH 03/23] Update Gemfile.lock --- Gemfile.lock | 215 ++++++++++++++++++++++++++------------------------- 1 file changed, 109 insertions(+), 106 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2b125cfb3..76ed508f6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -33,47 +33,47 @@ PATH GEM remote: https://rubygems.org/ specs: - actioncable (7.0.7.2) - actionpack (= 7.0.7.2) - activesupport (= 7.0.7.2) + actioncable (7.0.8) + actionpack (= 7.0.8) + activesupport (= 7.0.8) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.7.2) - actionpack (= 7.0.7.2) - activejob (= 7.0.7.2) - activerecord (= 7.0.7.2) - activestorage (= 7.0.7.2) - activesupport (= 7.0.7.2) + actionmailbox (7.0.8) + actionpack (= 7.0.8) + activejob (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.7.2) - actionpack (= 7.0.7.2) - actionview (= 7.0.7.2) - activejob (= 7.0.7.2) - activesupport (= 7.0.7.2) + actionmailer (7.0.8) + actionpack (= 7.0.8) + actionview (= 7.0.8) + activejob (= 7.0.8) + activesupport (= 7.0.8) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.7.2) - actionview (= 7.0.7.2) - activesupport (= 7.0.7.2) + actionpack (7.0.8) + actionview (= 7.0.8) + activesupport (= 7.0.8) rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.7.2) - actionpack (= 7.0.7.2) - activerecord (= 7.0.7.2) - activestorage (= 7.0.7.2) - activesupport (= 7.0.7.2) + actiontext (7.0.8) + actionpack (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.7.2) - activesupport (= 7.0.7.2) + actionview (7.0.8) + activesupport (= 7.0.8) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -81,28 +81,28 @@ GEM active_model_serializers (0.9.9) activemodel (>= 3.2) concurrent-ruby (~> 1.0) - activejob (7.0.7.2) - activesupport (= 7.0.7.2) + activejob (7.0.8) + activesupport (= 7.0.8) globalid (>= 0.3.6) - activemodel (7.0.7.2) - activesupport (= 7.0.7.2) - activerecord (7.0.7.2) - activemodel (= 7.0.7.2) - activesupport (= 7.0.7.2) - activestorage (7.0.7.2) - actionpack (= 7.0.7.2) - activejob (= 7.0.7.2) - activerecord (= 7.0.7.2) - activesupport (= 7.0.7.2) + activemodel (7.0.8) + activesupport (= 7.0.8) + activerecord (7.0.8) + activemodel (= 7.0.8) + activesupport (= 7.0.8) + activestorage (7.0.8) + actionpack (= 7.0.8) + activejob (= 7.0.8) + activerecord (= 7.0.8) + activesupport (= 7.0.8) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.7.2) + activesupport (7.0.8) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) + addressable (2.8.6) + public_suffix (>= 2.0.2, < 6.0) ansi_stream (0.0.6) ast (2.4.2) autoprefixer-rails (6.4.1.1) @@ -123,22 +123,22 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.2.2) + concurrent-ruby (1.2.3) crack (0.4.5) rexml crass (1.0.6) - date (3.3.3) + date (3.3.4) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) docile (1.4.0) equalizer (0.0.11) erubi (1.12.0) - execjs (2.8.1) + execjs (2.9.1) explicit-parameters (0.4.1) actionpack (>= 6.0) activemodel (>= 6.0) virtus (~> 1.0) - faker (2.20.0) + faker (3.2.3) i18n (>= 1.8.11, < 2) faraday (1.10.3) faraday-em_http (~> 1.0) @@ -155,7 +155,7 @@ GEM faraday-em_http (1.0.0) faraday-em_synchrony (1.0.0) faraday-excon (1.1.0) - faraday-http-cache (2.5.0) + faraday-http-cache (2.5.1) faraday (>= 0.8) faraday-httpclient (1.0.1) faraday-multipart (1.0.4) @@ -165,11 +165,11 @@ GEM faraday-patron (1.0.0) faraday-rack (1.0.0) faraday-retry (1.0.3) - ffi (1.15.5) + ffi (1.16.3) gemoji (2.1.0) - globalid (1.1.0) - activesupport (>= 5.0) - hashdiff (1.0.1) + globalid (1.2.1) + activesupport (>= 6.1) + hashdiff (1.1.0) hashie (5.0.0) i18n (1.14.1) concurrent-ruby (~> 1.0) @@ -179,12 +179,12 @@ GEM railties (>= 4.2.0) thor (>= 0.14, < 2.0) jwt (2.7.1) - libv8-node (16.10.0.0-arm64-darwin) - libv8-node (16.10.0.0-x86_64-darwin) - libv8-node (16.10.0.0-x86_64-linux) + libv8-node (16.19.0.1-arm64-darwin) + libv8-node (16.19.0.1-x86_64-darwin) + libv8-node (16.19.0.1-x86_64-linux) lodash-rails (4.17.21) railties (>= 3.1) - loofah (2.21.3) + loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -194,31 +194,32 @@ GEM net-smtp marcel (1.0.2) method_source (1.0.0) - mini_mime (1.1.2) - mini_racer (0.6.2) - libv8-node (~> 16.10.0.0) - minitest (5.19.0) + mini_mime (1.1.5) + mini_portile2 (2.8.5) + mini_racer (0.6.4) + libv8-node (~> 16.19.0.0) + minitest (5.21.2) mocha (2.1.0) ruby2_keywords (>= 0.0.5) - msgpack (1.7.1) + msgpack (1.7.2) multi_xml (0.6.0) multipart-post (2.3.0) - mysql2 (0.5.3) - net-imap (0.3.6) + mysql2 (0.5.5) + net-imap (0.4.9.1) date net-protocol net-pop (0.1.2) net-protocol - net-protocol (0.2.1) + net-protocol (0.2.2) timeout - net-smtp (0.3.3) + net-smtp (0.4.0.1) net-protocol - nio4r (2.5.9) - nokogiri (1.15.2-arm64-darwin) + nio4r (2.7.0) + nokogiri (1.15.5-arm64-darwin) racc (~> 1.4) - nokogiri (1.15.2-x86_64-darwin) + nokogiri (1.15.5-x86_64-darwin) racc (~> 1.4) - nokogiri (1.15.2-x86_64-linux) + nokogiri (1.15.5-x86_64-linux) racc (~> 1.4) oauth2 (2.0.9) faraday (>= 0.17.3, < 3.0) @@ -239,38 +240,39 @@ GEM omniauth-oauth2 (1.7.3) oauth2 (>= 1.4, < 3) omniauth (>= 1.9, < 3) - paquito (0.10.0) + paquito (0.11.0) msgpack (>= 1.5.2) - parallel (1.21.0) - parser (3.1.1.0) + parallel (1.24.0) + parser (3.3.0.4) ast (~> 2.4.1) pg (1.3.3) - pry (0.14.1) + racc + pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - public_suffix (4.0.6) + public_suffix (5.0.4) pubsubstub (0.2.2) rack redis (~> 4.0) - racc (1.7.1) - rack (2.2.7) + racc (1.7.3) + rack (2.2.8) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.7.2) - actioncable (= 7.0.7.2) - actionmailbox (= 7.0.7.2) - actionmailer (= 7.0.7.2) - actionpack (= 7.0.7.2) - actiontext (= 7.0.7.2) - actionview (= 7.0.7.2) - activejob (= 7.0.7.2) - activemodel (= 7.0.7.2) - activerecord (= 7.0.7.2) - activestorage (= 7.0.7.2) - activesupport (= 7.0.7.2) + rails (7.0.8) + actioncable (= 7.0.8) + actionmailbox (= 7.0.8) + actionmailer (= 7.0.8) + actionpack (= 7.0.8) + actiontext (= 7.0.8) + actionview (= 7.0.8) + activejob (= 7.0.8) + activemodel (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) bundler (>= 1.15.0) - railties (= 7.0.7.2) - rails-dom-testing (2.1.1) + railties (= 7.0.8) + rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) @@ -284,23 +286,23 @@ GEM actionview (> 3.1) activesupport (> 3.1) railties (> 3.1) - railties (7.0.7.2) - actionpack (= 7.0.7.2) - activesupport (= 7.0.7.2) + railties (7.0.8) + actionpack (= 7.0.8) + activesupport (= 7.0.8) method_source rake (>= 12.2) thor (~> 1.0) zeitwerk (~> 2.5) rainbow (3.1.1) - rake (13.0.6) + rake (13.1.0) redis (4.8.1) redis-objects (1.7.0) redis - regexp_parser (2.2.1) - responders (3.1.0) + regexp_parser (2.9.0) + responders (3.1.1) actionpack (>= 5.2) railties (>= 5.2) - rexml (3.2.5) + rexml (3.2.6) rubocop (1.18.3) parallel (~> 1.10) parser (>= 3.0.0.0) @@ -310,11 +312,11 @@ GEM rubocop-ast (>= 1.7.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.16.0) - parser (>= 3.1.1.0) + rubocop-ast (1.30.0) + parser (>= 3.2.1.0) rubocop-shopify (2.2.0) rubocop (~> 1.18) - ruby-progressbar (1.11.0) + ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) safe_yaml (1.0.5) sass-rails (6.0.0) @@ -331,7 +333,7 @@ GEM addressable (>= 2.3.5) faraday (>= 0.17.3, < 3) securecompare (1.0.0) - simplecov (0.21.2) + simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) @@ -347,8 +349,9 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - spy (1.0.2) - sqlite3 (1.4.2) + spy (1.0.5) + sqlite3 (1.7.0) + mini_portile2 (~> 2.8.0) state_machines (0.5.0) state_machines-activemodel (0.8.0) activemodel (>= 5.1) @@ -356,13 +359,13 @@ GEM state_machines-activerecord (0.8.0) activerecord (>= 5.1) state_machines-activemodel (>= 0.8.0) - thor (1.2.2) + thor (1.3.0) thread_safe (0.3.6) - tilt (2.2.0) - timeout (0.4.0) + tilt (2.3.0) + timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (2.1.0) + unicode-display_width (2.5.0) validate_url (1.0.15) activemodel (>= 3.0.0) public_suffix @@ -372,14 +375,14 @@ GEM coercible (~> 1.0) descendants_tracker (~> 0.0, >= 0.0.3) equalizer (~> 0.0, >= 0.0.9) - webmock (3.14.0) + webmock (3.19.1) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - websocket-driver (0.7.5) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.8) + zeitwerk (2.6.12) PLATFORMS arm64-darwin-21 From ef30c57b97a5a9ffa4853ace8e1dbe957600c0e3 Mon Sep 17 00:00:00 2001 From: Kartiki Sharma Date: Fri, 19 Jan 2024 16:14:26 -0500 Subject: [PATCH 04/23] wip --- shipit-engine.gemspec | 2 +- template.rb | 6 +++--- test/dummy/config/application.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/shipit-engine.gemspec b/shipit-engine.gemspec index 3ede910da..99ae08cea 100644 --- a/shipit-engine.gemspec +++ b/shipit-engine.gemspec @@ -30,7 +30,7 @@ Gem::Specification.new do |s| s.add_dependency('octokit', '~> 4.20') s.add_dependency('omniauth-github', '~> 1.4') s.add_dependency('pubsubstub', '~> 0.2.0') - s.add_dependency('rails', '~> 7.0.0') + s.add_dependency('rails', '~> 7.1.1') s.add_dependency('rails-timeago', '~> 2.13.0') s.add_dependency('rails_autolink', '~> 1.1.6') s.add_dependency('rake') diff --git a/template.rb b/template.rb index 560d8f8de..7e2f24a10 100644 --- a/template.rb +++ b/template.rb @@ -3,8 +3,8 @@ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7') raise Thor::Error, "You need at least Ruby 2.7 to install shipit" end -if Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new('7.0') - raise Thor::Error, "You need Rails 7.0 to install shipit" +if Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new('7.1.1') + raise Thor::Error, "You need Rails 7.1.1 to install shipit" end route %(mount Shipit::Engine, at: '/') @@ -124,7 +124,7 @@ end CODE -inject_into_file 'config/application.rb', after: "load_defaults 7.0\n" do +inject_into_file 'config/application.rb', after: "load_defaults 7.1\n" do "\n config.active_job.queue_adapter = :sidekiq\n" end diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index 99c43aac8..fe54eff24 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -17,6 +17,6 @@ module Shipit class Application < Rails::Application - config.load_defaults 7.0 + config.load_defaults 7.1 end end From a06cedd754d7c4b55e6b82846c1967e24e633ad8 Mon Sep 17 00:00:00 2001 From: Kartiki Sharma Date: Fri, 19 Jan 2024 16:21:16 -0500 Subject: [PATCH 05/23] Update Gemfile.lock --- Gemfile.lock | 165 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 99 insertions(+), 66 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 76ed508f6..e95814080 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -16,7 +16,7 @@ PATH omniauth-github (~> 1.4) paquito pubsubstub (~> 0.2.0) - rails (~> 7.0.0) + rails (~> 7.1.1) rails-timeago (~> 2.13.0) rails_autolink (~> 1.1.6) rake @@ -33,73 +33,82 @@ PATH GEM remote: https://rubygems.org/ specs: - actioncable (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) + actioncable (7.1.3) + actionpack (= 7.1.3) + activesupport (= 7.1.3) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8) - actionpack (= 7.0.8) - activejob (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + zeitwerk (~> 2.6) + actionmailbox (7.1.3) + actionpack (= 7.1.3) + activejob (= 7.1.3) + activerecord (= 7.1.3) + activestorage (= 7.1.3) + activesupport (= 7.1.3) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8) - actionpack (= 7.0.8) - actionview (= 7.0.8) - activejob (= 7.0.8) - activesupport (= 7.0.8) + actionmailer (7.1.3) + actionpack (= 7.1.3) + actionview (= 7.1.3) + activejob (= 7.1.3) + activesupport (= 7.1.3) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.8) - actionview (= 7.0.8) - activesupport (= 7.0.8) - rack (~> 2.0, >= 2.2.4) + rails-dom-testing (~> 2.2) + actionpack (7.1.3) + actionview (= 7.1.3) + activesupport (= 7.1.3) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.8) - actionpack (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.3) + actionpack (= 7.1.3) + activerecord (= 7.1.3) + activestorage (= 7.1.3) + activesupport (= 7.1.3) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8) - activesupport (= 7.0.8) + actionview (7.1.3) + activesupport (= 7.1.3) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) active_model_serializers (0.9.9) activemodel (>= 3.2) concurrent-ruby (~> 1.0) - activejob (7.0.8) - activesupport (= 7.0.8) + activejob (7.1.3) + activesupport (= 7.1.3) globalid (>= 0.3.6) - activemodel (7.0.8) - activesupport (= 7.0.8) - activerecord (7.0.8) - activemodel (= 7.0.8) - activesupport (= 7.0.8) - activestorage (7.0.8) - actionpack (= 7.0.8) - activejob (= 7.0.8) - activerecord (= 7.0.8) - activesupport (= 7.0.8) + activemodel (7.1.3) + activesupport (= 7.1.3) + activerecord (7.1.3) + activemodel (= 7.1.3) + activesupport (= 7.1.3) + timeout (>= 0.4.0) + activestorage (7.1.3) + actionpack (= 7.1.3) + activejob (= 7.1.3) + activerecord (= 7.1.3) + activesupport (= 7.1.3) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.8) + activesupport (7.1.3) + base64 + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) minitest (>= 5.1) + mutex_m tzinfo (~> 2.0) addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) @@ -111,6 +120,8 @@ GEM descendants_tracker (~> 0.0.4) ice_nine (~> 0.11.0) thread_safe (~> 0.3, >= 0.3.1) + base64 (0.2.0) + bigdecimal (3.1.6) builder (3.2.4) byebug (11.1.3) coderay (1.1.3) @@ -124,6 +135,7 @@ GEM execjs coffee-script-source (1.12.2) concurrent-ruby (1.2.3) + connection_pool (2.4.1) crack (0.4.5) rexml crass (1.0.6) @@ -131,6 +143,8 @@ GEM descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) docile (1.4.0) + drb (2.2.0) + ruby2_keywords equalizer (0.0.11) erubi (1.12.0) execjs (2.9.1) @@ -174,6 +188,10 @@ GEM i18n (1.14.1) concurrent-ruby (~> 1.0) ice_nine (0.11.2) + io-console (0.7.2) + irb (1.11.1) + rdoc + reline (>= 0.4.2) jquery-rails (4.6.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -204,6 +222,7 @@ GEM msgpack (1.7.2) multi_xml (0.6.0) multipart-post (2.3.0) + mutex_m (0.2.0) mysql2 (0.5.5) net-imap (0.4.9.1) date @@ -245,33 +264,40 @@ GEM parallel (1.24.0) parser (3.3.0.4) ast (~> 2.4.1) - pg (1.3.3) racc + pg (1.3.3) pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) + psych (5.1.2) + stringio public_suffix (5.0.4) pubsubstub (0.2.2) rack redis (~> 4.0) racc (1.7.3) rack (2.2.8) + rack-session (1.0.2) + rack (< 3) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.8) - actioncable (= 7.0.8) - actionmailbox (= 7.0.8) - actionmailer (= 7.0.8) - actionpack (= 7.0.8) - actiontext (= 7.0.8) - actionview (= 7.0.8) - activejob (= 7.0.8) - activemodel (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + rackup (1.0.0) + rack (< 3) + webrick + rails (7.1.3) + actioncable (= 7.1.3) + actionmailbox (= 7.1.3) + actionmailer (= 7.1.3) + actionpack (= 7.1.3) + actiontext (= 7.1.3) + actionview (= 7.1.3) + activejob (= 7.1.3) + activemodel (= 7.1.3) + activerecord (= 7.1.3) + activestorage (= 7.1.3) + activesupport (= 7.1.3) bundler (>= 1.15.0) - railties (= 7.0.8) + railties (= 7.1.3) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -286,19 +312,24 @@ GEM actionview (> 3.1) activesupport (> 3.1) railties (> 3.1) - railties (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) - method_source + railties (7.1.3) + actionpack (= 7.1.3) + activesupport (= 7.1.3) + irb + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.1.0) + rdoc (6.6.2) + psych (>= 4.0.0) redis (4.8.1) redis-objects (1.7.0) redis regexp_parser (2.9.0) + reline (0.4.2) + io-console (~> 0.5) responders (3.1.1) actionpack (>= 5.2) railties (>= 5.2) @@ -359,6 +390,7 @@ GEM state_machines-activerecord (0.8.0) activerecord (>= 5.1) state_machines-activemodel (>= 0.8.0) + stringio (3.1.0) thor (1.3.0) thread_safe (0.3.6) tilt (2.3.0) @@ -379,6 +411,7 @@ GEM addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) + webrick (1.8.1) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) From c5a89b83902cdac764b46be7fb9fe40d210bed86 Mon Sep 17 00:00:00 2001 From: Kartiki Sharma Date: Fri, 19 Jan 2024 17:16:14 -0500 Subject: [PATCH 06/23] Swap from Ruby 2.7.5 to 3.2.0 --- dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev.yml b/dev.yml index 6d9736d38..71f1e355d 100644 --- a/dev.yml +++ b/dev.yml @@ -8,7 +8,7 @@ up: - packages: - sqlite - ruby: - version: 2.7.5 + version: 3.2.0 - isogun - bundler: without: ci From 57f88e430e6fb53b2e0532cfd60398524e58be7f Mon Sep 17 00:00:00 2001 From: Kartiki Sharma Date: Fri, 19 Jan 2024 17:26:01 -0500 Subject: [PATCH 07/23] Update main.yml --- .github/workflows/main.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6efee0c9f..44b3b3d77 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,10 +9,10 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Set up Ruby 2.7 + - name: Set up Ruby 3.2 uses: ruby/setup-ruby@v1 with: - ruby-version: '2.7' + ruby-version: '3.2' bundler-cache: true - name: rubocop run: | @@ -25,7 +25,7 @@ jobs: fail-fast: false matrix: ruby_version: - - '2.7' + - '3.2' services: db: @@ -68,7 +68,7 @@ jobs: fail-fast: false matrix: ruby_version: - - '2.7' + - '3.2' services: db: @@ -107,9 +107,6 @@ jobs: fail-fast: false matrix: ruby_version: - - '2.7' - - '3.0' - - '3.1' - '3.2' services: @@ -141,7 +138,7 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: '3.0' + ruby-version: '3.2' - name: Run setup script run: | git config --global user.email "you@example.com" From 87623159bddc52c06bd7a733cd256c930855a68b Mon Sep 17 00:00:00 2001 From: Kartiki Sharma Date: Fri, 19 Jan 2024 17:29:57 -0500 Subject: [PATCH 08/23] Fix Rubocop errors --- Rakefile | 1 + .../shipit/active_model_serializers_patch.rb | 1 + .../concerns/shipit/api/cacheable.rb | 1 + .../concerns/shipit/api/paginable.rb | 1 + .../concerns/shipit/api/rendering.rb | 1 + .../concerns/shipit/authentication.rb | 1 + app/controllers/concerns/shipit/pagination.rb | 1 + app/controllers/shipit/api/base_controller.rb | 2 + .../shipit/api/ccmenu_controller.rb | 1 + .../shipit/api/commits_controller.rb | 1 + .../shipit/api/deploys_controller.rb | 1 + .../shipit/api/hooks_controller.rb | 1 + .../shipit/api/locks_controller.rb | 1 + .../shipit/api/merge_requests_controller.rb | 1 + .../shipit/api/outputs_controller.rb | 1 + .../shipit/api/release_statuses_controller.rb | 1 + .../shipit/api/rollbacks_controller.rb | 1 + .../shipit/api/stacks_controller.rb | 1 + .../shipit/api/tasks_controller.rb | 1 + .../shipit/api_clients_controller.rb | 1 + .../shipit/ccmenu_url_controller.rb | 1 + .../shipit/commit_checks_controller.rb | 1 + app/controllers/shipit/commits_controller.rb | 1 + app/controllers/shipit/deploys_controller.rb | 1 + .../github_authentication_controller.rb | 1 + .../shipit/merge_requests_controller.rb | 1 + .../shipit/merge_status_controller.rb | 4 ++ .../shipit/release_statuses_controller.rb | 1 + .../shipit/rollbacks_controller.rb | 1 + app/controllers/shipit/shipit_controller.rb | 1 + app/controllers/shipit/stacks_controller.rb | 1 + app/controllers/shipit/status_controller.rb | 1 + app/controllers/shipit/tasks_controller.rb | 2 + app/controllers/shipit/webhooks_controller.rb | 3 +- app/helpers/shipit/api_clients_helper.rb | 1 + app/helpers/shipit/chunks_helper.rb | 2 + app/helpers/shipit/deploys_helper.rb | 4 ++ app/helpers/shipit/github_url_helper.rb | 1 + app/helpers/shipit/merge_status_helper.rb | 1 + app/helpers/shipit/shipit_helper.rb | 1 + app/helpers/shipit/stacks_helper.rb | 1 + app/helpers/shipit/tasks_helper.rb | 1 + app/jobs/shipit/background_job.rb | 2 + app/jobs/shipit/background_job/unique.rb | 1 + app/jobs/shipit/cache_deploy_spec_job.rb | 1 + app/jobs/shipit/chunk_rollup_job.rb | 1 + app/jobs/shipit/clear_git_cache_job.rb | 1 + app/jobs/shipit/continuous_delivery_job.rb | 1 + app/jobs/shipit/create_on_github_job.rb | 1 + .../shipit/create_release_statuses_job.rb | 1 + app/jobs/shipit/deferred_touch_job.rb | 1 + app/jobs/shipit/deliver_hook_job.rb | 1 + app/jobs/shipit/destroy_job.rb | 1 + app/jobs/shipit/destroy_repository_job.rb | 1 + app/jobs/shipit/destroy_stack_job.rb | 1 + app/jobs/shipit/emit_event_job.rb | 1 + app/jobs/shipit/fetch_commit_stats_job.rb | 1 + .../shipit/fetch_deployed_revision_job.rb | 1 + app/jobs/shipit/github_sync_job.rb | 2 + app/jobs/shipit/mark_deploy_healthy_job.rb | 1 + app/jobs/shipit/perform_commit_checks_job.rb | 1 + app/jobs/shipit/perform_task_job.rb | 1 + app/jobs/shipit/process_merge_requests_job.rb | 2 + app/jobs/shipit/purge_old_deliveries_job.rb | 1 + app/jobs/shipit/reap_dead_tasks_job.rb | 1 + app/jobs/shipit/refresh_check_runs_job.rb | 1 + app/jobs/shipit/refresh_github_user_job.rb | 1 + app/jobs/shipit/refresh_merge_request_job.rb | 1 + app/jobs/shipit/refresh_statuses_job.rb | 1 + app/jobs/shipit/setup_github_hook_job.rb | 1 + .../update_estimated_deploy_duration_job.rb | 1 + .../update_github_last_deployed_ref_job.rb | 1 + app/models/concerns/shipit/deferred_touch.rb | 3 + app/models/shipit/anonymous_user.rb | 1 + app/models/shipit/api_client.rb | 2 + app/models/shipit/application_record.rb | 1 + app/models/shipit/check_run.rb | 3 +- app/models/shipit/command_line_user.rb | 1 + app/models/shipit/commit.rb | 24 ++++++-- app/models/shipit/commit_checks.rb | 2 + app/models/shipit/commit_deployment.rb | 2 + app/models/shipit/commit_deployment_status.rb | 3 + app/models/shipit/commit_message.rb | 2 + app/models/shipit/delivery.rb | 1 + app/models/shipit/deploy.rb | 28 ++++++--- app/models/shipit/deploy_spec.rb | 2 + .../shipit/deploy_spec/bundler_discovery.rb | 2 + .../deploy_spec/capistrano_discovery.rb | 1 + app/models/shipit/deploy_spec/file_system.rb | 5 +- .../deploy_spec/kubernetes_discovery.rb | 1 + .../shipit/deploy_spec/lerna_discovery.rb | 17 ++++-- .../shipit/deploy_spec/npm_discovery.rb | 7 +++ .../shipit/deploy_spec/pypi_discovery.rb | 1 + .../shipit/deploy_spec/rubygems_discovery.rb | 1 + app/models/shipit/deploy_stats.rb | 5 ++ app/models/shipit/duration.rb | 2 + app/models/shipit/ephemeral_commit_checks.rb | 1 + app/models/shipit/github_hook.rb | 1 + app/models/shipit/github_status.rb | 1 + app/models/shipit/hook.rb | 2 + app/models/shipit/membership.rb | 1 + app/models/shipit/merge_request.rb | 9 +++ app/models/shipit/output_chunk.rb | 1 + app/models/shipit/provisioning_handler.rb | 1 + .../unregistered_provisioning_handler.rb | 4 +- app/models/shipit/record.rb | 1 + app/models/shipit/release_status.rb | 1 + app/models/shipit/repository.rb | 8 ++- app/models/shipit/review_stack.rb | 8 ++- .../shipit/review_stack_provisioning_queue.rb | 2 +- app/models/shipit/rollback.rb | 2 + app/models/shipit/stack.rb | 26 ++++++-- app/models/shipit/status.rb | 1 + app/models/shipit/status/common.rb | 1 + app/models/shipit/status/group.rb | 12 +++- app/models/shipit/status/missing.rb | 1 + app/models/shipit/status/unknown.rb | 1 + app/models/shipit/task.rb | 11 +++- app/models/shipit/task_definition.rb | 3 + .../shipit/task_execution_strategy/base.rb | 2 +- app/models/shipit/team.rb | 1 + app/models/shipit/undeployed_commit.rb | 2 + app/models/shipit/unlimited_api_client.rb | 1 + app/models/shipit/user.rb | 5 ++ app/models/shipit/variable_definition.rb | 1 + app/models/shipit/webhooks.rb | 1 + .../webhooks/handlers/check_suite_handler.rb | 1 + .../shipit/webhooks/handlers/handler.rb | 1 + .../webhooks/handlers/membership_handler.rb | 1 + .../handlers/pull_request/assigned_handler.rb | 2 +- .../handlers/pull_request/edited_handler.rb | 2 +- .../pull_request/review_stack_adapter.rb | 6 +- .../shipit/webhooks/handlers/push_handler.rb | 1 + .../webhooks/handlers/status_handler.rb | 1 + .../concerns/shipit/conditional_attributes.rb | 1 + .../shipit/anonymous_user_serializer.rb | 1 + .../shipit/command_line_user_serializer.rb | 1 + app/serializers/shipit/commit_serializer.rb | 1 + app/serializers/shipit/deploy_serializer.rb | 1 + app/serializers/shipit/hook_serializer.rb | 1 + .../shipit/merge_request_serializer.rb | 17 +++++- app/serializers/shipit/rollback_serializer.rb | 1 + .../shipit/short_commit_serializer.rb | 1 + app/serializers/shipit/stack_serializer.rb | 28 +++++++-- .../shipit/tail_task_serializer.rb | 3 + app/serializers/shipit/task_serializer.rb | 1 + app/serializers/shipit/user_serializer.rb | 1 + app/validators/ascii_only_validator.rb | 1 + app/validators/subset_validator.rb | 1 + app/views/shipit/ccmenu/project.xml.builder | 1 + config/initializers/inflections.rb | 1 + config/routes.rb | 1 + lib/shipit.rb | 10 +++- lib/shipit/cast_value.rb | 1 + lib/shipit/command.rb | 5 ++ lib/shipit/commands.rb | 2 + lib/shipit/csv_serializer.rb | 3 + lib/shipit/deploy_commands.rb | 1 + lib/shipit/engine.rb | 1 + lib/shipit/environment_variables.rb | 2 + lib/shipit/first_parent_commits_iterator.rb | 1 + lib/shipit/flock.rb | 2 + lib/shipit/github_app.rb | 2 + lib/shipit/github_http_cache_middleware.rb | 1 + lib/shipit/null_serializer.rb | 1 + lib/shipit/octokit_check_runs.rb | 1 + lib/shipit/octokit_iterator.rb | 2 + lib/shipit/paginator.rb | 1 + lib/shipit/rollback_commands.rb | 1 + lib/shipit/same_site_cookie_middleware.rb | 3 +- lib/shipit/simple_message_verifier.rb | 1 + lib/shipit/stack_commands.rb | 17 ++++-- lib/shipit/stat.rb | 1 + lib/shipit/task_commands.rb | 9 +-- lib/shipit/version.rb | 1 + lib/tasks/cron.rake | 1 + lib/tasks/dev.rake | 1 + lib/tasks/shipit.rake | 1 + lib/tasks/teams.rake | 1 + shipit-engine.gemspec | 8 +-- test/controllers/api/base_controller_test.rb | 1 + .../controllers/api/ccmenu_controller_test.rb | 1 + .../api/commits_controller_test.rb | 1 + .../api/deploys_controller_test.rb | 1 + test/controllers/api/hooks_controller_test.rb | 1 + test/controllers/api/locks_controller_test.rb | 1 + .../api/merge_requests_controller_test.rb | 1 + .../api/outputs_controller_test.rb | 1 + .../api/release_statuses_controller_test.rb | 1 + .../api/rollback_controller_test.rb | 1 + .../controllers/api/stacks_controller_test.rb | 1 + test/controllers/api/tasks_controller_test.rb | 1 + test/controllers/ccmenu_controller_test.rb | 1 + .../commit_checks_controller_test.rb | 1 + test/controllers/commits_controller_test.rb | 1 + test/controllers/deploys_controller_test.rb | 1 + .../github_authentication_controller_test.rb | 1 + .../merge_requests_controller_test.rb | 1 + .../merge_status_controller_test.rb | 1 + .../release_statuses_controller_test.rb | 1 + .../repositories_controller_test.rb | 1 + test/controllers/rollbacks_controller_test.rb | 1 + test/controllers/stacks_controller_test.rb | 1 + test/controllers/status_controller_test.rb | 1 + test/controllers/tasks_controller_test.rb | 1 + test/controllers/webhooks_controller_test.rb | 1 + test/helpers/api_helper.rb | 1 + test/helpers/fixture_aliases_helper.rb | 1 + test/helpers/hooks_helper.rb | 1 + test/helpers/json_helper.rb | 1 + test/helpers/links_helper.rb | 1 + test/helpers/payloads_helper.rb | 1 + test/helpers/queries_helper.rb | 2 + test/jobs/cache_deploy_spec_job_test.rb | 1 + test/jobs/chunk_rollup_job_test.rb | 1 + test/jobs/deliver_hook_job_test.rb | 1 + test/jobs/destroy_repository_job_test.rb | 1 + test/jobs/destroy_stack_job_test.rb | 1 + test/jobs/emit_event_job_test.rb | 1 + test/jobs/fetch_commit_stats_job_test.rb | 1 + test/jobs/fetch_deployed_revision_job_test.rb | 1 + test/jobs/github_sync_job_test.rb | 1 + test/jobs/mark_deploy_healthy_job_test.rb | 1 + test/jobs/perform_task_job_test.rb | 1 + test/jobs/process_merge_requests_job_test.rb | 1 + test/jobs/purge_old_deliveries_job_test.rb | 1 + test/jobs/reap_dead_tasks_job_test.rb | 1 + test/jobs/refresh_github_user_job_test.rb | 1 + test/jobs/refresh_status_job_test.rb | 1 + test/jobs/unique_job_test.rb | 1 + ...pdate_github_last_deployed_ref_job_test.rb | 1 + .../same_site_cookie_middleware_test.rb | 1 + test/models/api_client_test.rb | 1 + test/models/commit_checks_test.rb | 1 + test/models/commit_deployment_status_test.rb | 1 + test/models/commit_deployment_test.rb | 1 + test/models/commits_test.rb | 11 ++-- test/models/delivery_test.rb | 1 + test/models/deploy_spec_test.rb | 60 +++++++++++-------- test/models/deploy_stats_test.rb | 1 + test/models/deploys_test.rb | 1 + test/models/duration_test.rb | 1 + test/models/github_hook_test.rb | 1 + test/models/hook_test.rb | 1 + test/models/membership_test.rb | 1 + test/models/merge_request_test.rb | 3 +- test/models/release_statuses_test.rb | 1 + test/models/rollbacks_test.rb | 1 + test/models/shipit/check_run_test.rb | 17 +++--- .../shipit/deploy_spec/file_system_test.rb | 1 + .../shipit/provisioning_handler/base_test.rb | 4 +- .../shipit/provisioning_handler_test.rb | 6 +- test/models/shipit/pull_request_test.rb | 2 +- test/models/shipit/repository_test.rb | 1 + test/models/shipit/stack_test.rb | 3 +- .../pull_request/closed_handler_test.rb | 14 ++--- .../label_capturing_handler_test.rb | 4 +- .../pull_request/labeled_handler_test.rb | 32 +++++----- .../pull_request/opened_handler_test.rb | 18 +++--- .../pull_request/reopened_handler_test.rb | 22 +++---- .../pull_request/review_stack_adapter_test.rb | 12 ++-- .../pull_request/unlabeled_handler_test.rb | 30 +++++----- test/models/shipit/webhooks/handlers_test.rb | 1 + test/models/status/group_test.rb | 1 + test/models/status/missing_test.rb | 1 + test/models/status_test.rb | 1 + test/models/task_definitions_test.rb | 1 + test/models/tasks_test.rb | 1 + test/models/team_test.rb | 1 + test/models/undeployed_commits_test.rb | 1 + test/models/users_test.rb | 1 + test/test_helper.rb | 2 + test/unit/anonymous_user_serializer_test.rb | 1 + test/unit/command_test.rb | 1 + test/unit/commands_test.rb | 1 + test/unit/commit_serializer_test.rb | 1 + test/unit/csv_serializer_test.rb | 1 + test/unit/deploy_commands_test.rb | 18 ++++-- test/unit/deploy_serializer_test.rb | 1 + test/unit/environment_variables_test.rb | 1 + test/unit/github_app_test.rb | 1 + test/unit/github_apps_test.rb | 1 + test/unit/github_url_helper_test.rb | 1 + test/unit/rollback_commands_test.rb | 1 + test/unit/shipit_deployment_checks_test.rb | 2 +- test/unit/shipit_helper_test.rb | 1 + .../shipit_task_execution_strategy_test.rb | 2 +- test/unit/shipit_test.rb | 1 + test/unit/user_serializer_test.rb | 1 + test/unit/variable_definition_test.rb | 1 + 290 files changed, 645 insertions(+), 183 deletions(-) diff --git a/Rakefile b/Rakefile index 01a482cb1..3d40762dd 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. diff --git a/app/controllers/concerns/shipit/active_model_serializers_patch.rb b/app/controllers/concerns/shipit/active_model_serializers_patch.rb index e4e5c625b..81db56dd5 100644 --- a/app/controllers/concerns/shipit/active_model_serializers_patch.rb +++ b/app/controllers/concerns/shipit/active_model_serializers_patch.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module ActiveModelSerializersPatch private diff --git a/app/controllers/concerns/shipit/api/cacheable.rb b/app/controllers/concerns/shipit/api/cacheable.rb index 963f82071..549a9a7b3 100644 --- a/app/controllers/concerns/shipit/api/cacheable.rb +++ b/app/controllers/concerns/shipit/api/cacheable.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Api module Cacheable diff --git a/app/controllers/concerns/shipit/api/paginable.rb b/app/controllers/concerns/shipit/api/paginable.rb index a77a795b5..73c2d9a22 100644 --- a/app/controllers/concerns/shipit/api/paginable.rb +++ b/app/controllers/concerns/shipit/api/paginable.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Api module Paginable diff --git a/app/controllers/concerns/shipit/api/rendering.rb b/app/controllers/concerns/shipit/api/rendering.rb index 137e0b4d6..b7f28a5c7 100644 --- a/app/controllers/concerns/shipit/api/rendering.rb +++ b/app/controllers/concerns/shipit/api/rendering.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Api module Rendering diff --git a/app/controllers/concerns/shipit/authentication.rb b/app/controllers/concerns/shipit/authentication.rb index cc53e5860..e3bdf3469 100644 --- a/app/controllers/concerns/shipit/authentication.rb +++ b/app/controllers/concerns/shipit/authentication.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Authentication extend ActiveSupport::Concern diff --git a/app/controllers/concerns/shipit/pagination.rb b/app/controllers/concerns/shipit/pagination.rb index 937ecc571..dbce8919e 100644 --- a/app/controllers/concerns/shipit/pagination.rb +++ b/app/controllers/concerns/shipit/pagination.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Pagination extend ActiveSupport::Concern diff --git a/app/controllers/shipit/api/base_controller.rb b/app/controllers/shipit/api/base_controller.rb index d7df8157a..8e21c55cb 100644 --- a/app/controllers/shipit/api/base_controller.rb +++ b/app/controllers/shipit/api/base_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Api class BaseController < ActionController::Base @@ -54,6 +55,7 @@ def authenticate_api_client end end return if @current_api_client + headers['WWW-Authenticate'] = 'Basic realm="Authentication token"' render(status: :unauthorized, json: { message: 'Bad credentials' }) end diff --git a/app/controllers/shipit/api/ccmenu_controller.rb b/app/controllers/shipit/api/ccmenu_controller.rb index c42bb48cf..6c91596c0 100644 --- a/app/controllers/shipit/api/ccmenu_controller.rb +++ b/app/controllers/shipit/api/ccmenu_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Api class CCMenuController < BaseController diff --git a/app/controllers/shipit/api/commits_controller.rb b/app/controllers/shipit/api/commits_controller.rb index b35e05dc7..d70113896 100644 --- a/app/controllers/shipit/api/commits_controller.rb +++ b/app/controllers/shipit/api/commits_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Api class CommitsController < BaseController diff --git a/app/controllers/shipit/api/deploys_controller.rb b/app/controllers/shipit/api/deploys_controller.rb index d80dedbfb..282294cbb 100644 --- a/app/controllers/shipit/api/deploys_controller.rb +++ b/app/controllers/shipit/api/deploys_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Api class DeploysController < BaseController diff --git a/app/controllers/shipit/api/hooks_controller.rb b/app/controllers/shipit/api/hooks_controller.rb index 033615052..1ffd63c21 100644 --- a/app/controllers/shipit/api/hooks_controller.rb +++ b/app/controllers/shipit/api/hooks_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Api class HooksController < BaseController diff --git a/app/controllers/shipit/api/locks_controller.rb b/app/controllers/shipit/api/locks_controller.rb index 29668a414..f04010c13 100644 --- a/app/controllers/shipit/api/locks_controller.rb +++ b/app/controllers/shipit/api/locks_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Api class LocksController < BaseController diff --git a/app/controllers/shipit/api/merge_requests_controller.rb b/app/controllers/shipit/api/merge_requests_controller.rb index b676db243..d14fb3997 100644 --- a/app/controllers/shipit/api/merge_requests_controller.rb +++ b/app/controllers/shipit/api/merge_requests_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Api class MergeRequestsController < BaseController diff --git a/app/controllers/shipit/api/outputs_controller.rb b/app/controllers/shipit/api/outputs_controller.rb index 041e7c716..851f380ec 100644 --- a/app/controllers/shipit/api/outputs_controller.rb +++ b/app/controllers/shipit/api/outputs_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Api class OutputsController < BaseController diff --git a/app/controllers/shipit/api/release_statuses_controller.rb b/app/controllers/shipit/api/release_statuses_controller.rb index 7a10c381d..8171dd647 100644 --- a/app/controllers/shipit/api/release_statuses_controller.rb +++ b/app/controllers/shipit/api/release_statuses_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Api class ReleaseStatusesController < BaseController diff --git a/app/controllers/shipit/api/rollbacks_controller.rb b/app/controllers/shipit/api/rollbacks_controller.rb index 0c954bd23..94bcffc9b 100644 --- a/app/controllers/shipit/api/rollbacks_controller.rb +++ b/app/controllers/shipit/api/rollbacks_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Api class RollbacksController < BaseController diff --git a/app/controllers/shipit/api/stacks_controller.rb b/app/controllers/shipit/api/stacks_controller.rb index ffcec1215..eae87a8c6 100644 --- a/app/controllers/shipit/api/stacks_controller.rb +++ b/app/controllers/shipit/api/stacks_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Api class StacksController < BaseController diff --git a/app/controllers/shipit/api/tasks_controller.rb b/app/controllers/shipit/api/tasks_controller.rb index 345e9d1b5..8c3302734 100644 --- a/app/controllers/shipit/api/tasks_controller.rb +++ b/app/controllers/shipit/api/tasks_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Api class TasksController < BaseController diff --git a/app/controllers/shipit/api_clients_controller.rb b/app/controllers/shipit/api_clients_controller.rb index efa503ee3..0dcf383c5 100644 --- a/app/controllers/shipit/api_clients_controller.rb +++ b/app/controllers/shipit/api_clients_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class ApiClientsController < ShipitController include Pagination diff --git a/app/controllers/shipit/ccmenu_url_controller.rb b/app/controllers/shipit/ccmenu_url_controller.rb index aedc32283..ed020068b 100644 --- a/app/controllers/shipit/ccmenu_url_controller.rb +++ b/app/controllers/shipit/ccmenu_url_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'uri' module Shipit diff --git a/app/controllers/shipit/commit_checks_controller.rb b/app/controllers/shipit/commit_checks_controller.rb index f8cce55de..012193b5a 100644 --- a/app/controllers/shipit/commit_checks_controller.rb +++ b/app/controllers/shipit/commit_checks_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class CommitChecksController < ShipitController def show diff --git a/app/controllers/shipit/commits_controller.rb b/app/controllers/shipit/commits_controller.rb index 716f33523..e9358573b 100644 --- a/app/controllers/shipit/commits_controller.rb +++ b/app/controllers/shipit/commits_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class CommitsController < ShipitController def update diff --git a/app/controllers/shipit/deploys_controller.rb b/app/controllers/shipit/deploys_controller.rb index 730c5d6c3..62df2d87f 100644 --- a/app/controllers/shipit/deploys_controller.rb +++ b/app/controllers/shipit/deploys_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class DeploysController < ShipitController include ChunksHelper diff --git a/app/controllers/shipit/github_authentication_controller.rb b/app/controllers/shipit/github_authentication_controller.rb index d263db525..0d5345c95 100644 --- a/app/controllers/shipit/github_authentication_controller.rb +++ b/app/controllers/shipit/github_authentication_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class GithubAuthenticationController < ActionController::Base include Shipit::Engine.routes.url_helpers diff --git a/app/controllers/shipit/merge_requests_controller.rb b/app/controllers/shipit/merge_requests_controller.rb index c0ff7801f..a6a3f8f15 100644 --- a/app/controllers/shipit/merge_requests_controller.rb +++ b/app/controllers/shipit/merge_requests_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class MergeRequestsController < ShipitController def index diff --git a/app/controllers/shipit/merge_status_controller.rb b/app/controllers/shipit/merge_status_controller.rb index 9e07b15db..fb4a51e65 100644 --- a/app/controllers/shipit/merge_status_controller.rb +++ b/app/controllers/shipit/merge_status_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class MergeStatusController < ShipitController skip_authentication only: %i(check show) @@ -12,6 +13,7 @@ def show if stack return render('logged_out') unless current_user.logged_in? + if stale?(last_modified: [stack.updated_at, merge_request.updated_at].max, template: false) render(stack_status, layout: !request.xhr?) end @@ -84,12 +86,14 @@ def referrer_parser def merge_request return @merge_request if defined?(@merge_request) + @merge_request = pull_request_number && stack.merge_requests.find_by_number(pull_request_number) @merge_request ||= UnknownMergeRequest.new end def pull_request_number return @pull_request_number if defined?(@pull_request_number) + @pull_request_number = referrer_parser.pull_request_number end diff --git a/app/controllers/shipit/release_statuses_controller.rb b/app/controllers/shipit/release_statuses_controller.rb index ecf94f406..d84e119d1 100644 --- a/app/controllers/shipit/release_statuses_controller.rb +++ b/app/controllers/shipit/release_statuses_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class ReleaseStatusesController < ShipitController before_action :load_stack diff --git a/app/controllers/shipit/rollbacks_controller.rb b/app/controllers/shipit/rollbacks_controller.rb index 62b33df7d..a02218a9e 100644 --- a/app/controllers/shipit/rollbacks_controller.rb +++ b/app/controllers/shipit/rollbacks_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class RollbacksController < ShipitController before_action :load_stack diff --git a/app/controllers/shipit/shipit_controller.rb b/app/controllers/shipit/shipit_controller.rb index c80655123..88237ef53 100644 --- a/app/controllers/shipit/shipit_controller.rb +++ b/app/controllers/shipit/shipit_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class ShipitController < ApplicationController layout 'shipit' diff --git a/app/controllers/shipit/stacks_controller.rb b/app/controllers/shipit/stacks_controller.rb index f2cc2ebcb..3bfa19c4a 100644 --- a/app/controllers/shipit/stacks_controller.rb +++ b/app/controllers/shipit/stacks_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class StacksController < ShipitController before_action :load_stack, only: %i(update destroy settings statistics clear_git_cache refresh) diff --git a/app/controllers/shipit/status_controller.rb b/app/controllers/shipit/status_controller.rb index a8b46dc1b..c626bdbd6 100644 --- a/app/controllers/shipit/status_controller.rb +++ b/app/controllers/shipit/status_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class StatusController < ActionController::Base def version diff --git a/app/controllers/shipit/tasks_controller.rb b/app/controllers/shipit/tasks_controller.rb index 6a95d84b7..204c6c646 100644 --- a/app/controllers/shipit/tasks_controller.rb +++ b/app/controllers/shipit/tasks_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class TasksController < ShipitController include Pagination @@ -75,6 +76,7 @@ def stack def task_params return {} unless params[:task] + @definition = stack.find_task_definition(params[:definition_id]) @task_params ||= params.require(:task).permit(env: @definition.variables.map(&:name)) end diff --git a/app/controllers/shipit/webhooks_controller.rb b/app/controllers/shipit/webhooks_controller.rb index eb2a152cb..f17afa226 100644 --- a/app/controllers/shipit/webhooks_controller.rb +++ b/app/controllers/shipit/webhooks_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class WebhooksController < ActionController::Base skip_before_action :verify_authenticity_token, raise: false @@ -24,7 +25,7 @@ def verify_signature github_app = Shipit.github(organization: repository_owner) verified = github_app.verify_webhook_signature( request.headers['X-Hub-Signature'], - request.raw_post + request.raw_post, ) head(422) unless verified diff --git a/app/helpers/shipit/api_clients_helper.rb b/app/helpers/shipit/api_clients_helper.rb index 1b55fc169..d0e0a94ae 100644 --- a/app/helpers/shipit/api_clients_helper.rb +++ b/app/helpers/shipit/api_clients_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module ApiClientsHelper def api_client_token(api_client) diff --git a/app/helpers/shipit/chunks_helper.rb b/app/helpers/shipit/chunks_helper.rb index a37f1db31..e8b9912db 100644 --- a/app/helpers/shipit/chunks_helper.rb +++ b/app/helpers/shipit/chunks_helper.rb @@ -1,8 +1,10 @@ # frozen_string_literal: true + module Shipit module ChunksHelper def next_chunks_url(task, last_byte: 0) return if task.finished? + tail_stack_task_path(task.stack, task, last_byte: last_byte) end end diff --git a/app/helpers/shipit/deploys_helper.rb b/app/helpers/shipit/deploys_helper.rb index 8a525c72a..0dbbdedf7 100644 --- a/app/helpers/shipit/deploys_helper.rb +++ b/app/helpers/shipit/deploys_helper.rb @@ -1,18 +1,22 @@ # frozen_string_literal: true + module Shipit module DeploysHelper def render_checklist(checklist) return if checklist.blank? + render('shipit/deploys/checklist', checklist: checklist) end def render_monitoring(stack) return unless stack.monitoring? + render('shipit/deploys/monitoring', stack: stack) end def render_checks(commit) return unless commit.stack.checks? + render('shipit/commit_checks/checks', commit: commit) end diff --git a/app/helpers/shipit/github_url_helper.rb b/app/helpers/shipit/github_url_helper.rb index 9dadcbd77..44dc47614 100644 --- a/app/helpers/shipit/github_url_helper.rb +++ b/app/helpers/shipit/github_url_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module GithubUrlHelper private diff --git a/app/helpers/shipit/merge_status_helper.rb b/app/helpers/shipit/merge_status_helper.rb index c55f0f19a..1830d30dc 100644 --- a/app/helpers/shipit/merge_status_helper.rb +++ b/app/helpers/shipit/merge_status_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module MergeStatusHelper def display_commit_count_warning?(commits) diff --git a/app/helpers/shipit/shipit_helper.rb b/app/helpers/shipit/shipit_helper.rb index 03df4bd0e..ed4a55959 100644 --- a/app/helpers/shipit/shipit_helper.rb +++ b/app/helpers/shipit/shipit_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module ShipitHelper def subscribe(url, *selectors) diff --git a/app/helpers/shipit/stacks_helper.rb b/app/helpers/shipit/stacks_helper.rb index a44c6bb0e..55069c8a6 100644 --- a/app/helpers/shipit/stacks_helper.rb +++ b/app/helpers/shipit/stacks_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module StacksHelper def redeploy_button(deployed_commit) diff --git a/app/helpers/shipit/tasks_helper.rb b/app/helpers/shipit/tasks_helper.rb index 358a4abcb..8d6691a4d 100644 --- a/app/helpers/shipit/tasks_helper.rb +++ b/app/helpers/shipit/tasks_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module TasksHelper def task_description(task) diff --git a/app/jobs/shipit/background_job.rb b/app/jobs/shipit/background_job.rb index ee7d69e91..8457e99ec 100644 --- a/app/jobs/shipit/background_job.rb +++ b/app/jobs/shipit/background_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class BackgroundJob < ActiveJob::Base class << self @@ -18,6 +19,7 @@ def perform(*) def with_timeout(&block) return yield unless timeout + Timeout.timeout(timeout, &block) end diff --git a/app/jobs/shipit/background_job/unique.rb b/app/jobs/shipit/background_job/unique.rb index 3d334cda8..9678fe22d 100644 --- a/app/jobs/shipit/background_job/unique.rb +++ b/app/jobs/shipit/background_job/unique.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class BackgroundJob module Unique diff --git a/app/jobs/shipit/cache_deploy_spec_job.rb b/app/jobs/shipit/cache_deploy_spec_job.rb index 12163c10e..fc29dd828 100644 --- a/app/jobs/shipit/cache_deploy_spec_job.rb +++ b/app/jobs/shipit/cache_deploy_spec_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class CacheDeploySpecJob < BackgroundJob include BackgroundJob::Unique diff --git a/app/jobs/shipit/chunk_rollup_job.rb b/app/jobs/shipit/chunk_rollup_job.rb index 5bfe6500b..2aec61ea4 100644 --- a/app/jobs/shipit/chunk_rollup_job.rb +++ b/app/jobs/shipit/chunk_rollup_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class ChunkRollupJob < BackgroundJob include BackgroundJob::Unique diff --git a/app/jobs/shipit/clear_git_cache_job.rb b/app/jobs/shipit/clear_git_cache_job.rb index e3ea4e2c2..dd5aeeae0 100644 --- a/app/jobs/shipit/clear_git_cache_job.rb +++ b/app/jobs/shipit/clear_git_cache_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class ClearGitCacheJob < BackgroundJob queue_as :deploys diff --git a/app/jobs/shipit/continuous_delivery_job.rb b/app/jobs/shipit/continuous_delivery_job.rb index 46a292f01..34f77a21f 100644 --- a/app/jobs/shipit/continuous_delivery_job.rb +++ b/app/jobs/shipit/continuous_delivery_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class ContinuousDeliveryJob < BackgroundJob include BackgroundJob::Unique diff --git a/app/jobs/shipit/create_on_github_job.rb b/app/jobs/shipit/create_on_github_job.rb index 6f6b74f40..2d75616e6 100644 --- a/app/jobs/shipit/create_on_github_job.rb +++ b/app/jobs/shipit/create_on_github_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class CreateOnGithubJob < BackgroundJob include BackgroundJob::Unique diff --git a/app/jobs/shipit/create_release_statuses_job.rb b/app/jobs/shipit/create_release_statuses_job.rb index dbd3a681f..6bf433ef4 100644 --- a/app/jobs/shipit/create_release_statuses_job.rb +++ b/app/jobs/shipit/create_release_statuses_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class CreateReleaseStatusesJob < BackgroundJob include BackgroundJob::Unique diff --git a/app/jobs/shipit/deferred_touch_job.rb b/app/jobs/shipit/deferred_touch_job.rb index e36bafa50..fe3db9889 100644 --- a/app/jobs/shipit/deferred_touch_job.rb +++ b/app/jobs/shipit/deferred_touch_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class DeferredTouchJob < BackgroundJob include BackgroundJob::Unique diff --git a/app/jobs/shipit/deliver_hook_job.rb b/app/jobs/shipit/deliver_hook_job.rb index 4f6bfe974..c4a52dc4e 100644 --- a/app/jobs/shipit/deliver_hook_job.rb +++ b/app/jobs/shipit/deliver_hook_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class DeliverHookJob < BackgroundJob queue_as :hooks diff --git a/app/jobs/shipit/destroy_job.rb b/app/jobs/shipit/destroy_job.rb index 43d8e2020..6d0d997aa 100644 --- a/app/jobs/shipit/destroy_job.rb +++ b/app/jobs/shipit/destroy_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class DestroyJob < BackgroundJob queue_as :default diff --git a/app/jobs/shipit/destroy_repository_job.rb b/app/jobs/shipit/destroy_repository_job.rb index 07aea7fc5..ef5cacb6a 100644 --- a/app/jobs/shipit/destroy_repository_job.rb +++ b/app/jobs/shipit/destroy_repository_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class DestroyRepositoryJob < BackgroundJob queue_as :default diff --git a/app/jobs/shipit/destroy_stack_job.rb b/app/jobs/shipit/destroy_stack_job.rb index a82a6dafd..7d94c4e72 100644 --- a/app/jobs/shipit/destroy_stack_job.rb +++ b/app/jobs/shipit/destroy_stack_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class DestroyStackJob < BackgroundJob queue_as :default diff --git a/app/jobs/shipit/emit_event_job.rb b/app/jobs/shipit/emit_event_job.rb index 88e14615f..15c0b37f6 100644 --- a/app/jobs/shipit/emit_event_job.rb +++ b/app/jobs/shipit/emit_event_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class EmitEventJob < BackgroundJob queue_as :hooks diff --git a/app/jobs/shipit/fetch_commit_stats_job.rb b/app/jobs/shipit/fetch_commit_stats_job.rb index 868c18960..4970aa4f7 100644 --- a/app/jobs/shipit/fetch_commit_stats_job.rb +++ b/app/jobs/shipit/fetch_commit_stats_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class FetchCommitStatsJob < BackgroundJob queue_as :default diff --git a/app/jobs/shipit/fetch_deployed_revision_job.rb b/app/jobs/shipit/fetch_deployed_revision_job.rb index 072bb73be..0909e6bb6 100644 --- a/app/jobs/shipit/fetch_deployed_revision_job.rb +++ b/app/jobs/shipit/fetch_deployed_revision_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class FetchDeployedRevisionJob < BackgroundJob queue_as :deploys diff --git a/app/jobs/shipit/github_sync_job.rb b/app/jobs/shipit/github_sync_job.rb index 0cb6abd45..f4158ddcb 100644 --- a/app/jobs/shipit/github_sync_job.rb +++ b/app/jobs/shipit/github_sync_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class GithubSyncJob < BackgroundJob include BackgroundJob::Unique @@ -43,6 +44,7 @@ def fetch_missing_commits(&block) if shared_parent = lookup_commit(commit.sha) return commits, shared_parent end + commits.unshift(commit) end [commits, nil] diff --git a/app/jobs/shipit/mark_deploy_healthy_job.rb b/app/jobs/shipit/mark_deploy_healthy_job.rb index 6e2ac3e72..d483a5c3a 100644 --- a/app/jobs/shipit/mark_deploy_healthy_job.rb +++ b/app/jobs/shipit/mark_deploy_healthy_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class MarkDeployHealthyJob < BackgroundJob include BackgroundJob::Unique diff --git a/app/jobs/shipit/perform_commit_checks_job.rb b/app/jobs/shipit/perform_commit_checks_job.rb index 540819dbb..502989c15 100644 --- a/app/jobs/shipit/perform_commit_checks_job.rb +++ b/app/jobs/shipit/perform_commit_checks_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class PerformCommitChecksJob < BackgroundJob include BackgroundJob::Unique diff --git a/app/jobs/shipit/perform_task_job.rb b/app/jobs/shipit/perform_task_job.rb index 090c587f1..709d6ed27 100644 --- a/app/jobs/shipit/perform_task_job.rb +++ b/app/jobs/shipit/perform_task_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class PerformTaskJob < BackgroundJob queue_as :deploys diff --git a/app/jobs/shipit/process_merge_requests_job.rb b/app/jobs/shipit/process_merge_requests_job.rb index ba0009ca8..fb3864e22 100644 --- a/app/jobs/shipit/process_merge_requests_job.rb +++ b/app/jobs/shipit/process_merge_requests_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class ProcessMergeRequestsJob < BackgroundJob include BackgroundJob::Unique @@ -20,6 +21,7 @@ def perform(stack) merge_requests.select(&:pending?).each do |merge_request| merge_request.refresh! next unless merge_request.all_status_checks_passed? + begin merge_request.merge! rescue MergeRequest::NotReady diff --git a/app/jobs/shipit/purge_old_deliveries_job.rb b/app/jobs/shipit/purge_old_deliveries_job.rb index 6e7c1719e..93682ff53 100644 --- a/app/jobs/shipit/purge_old_deliveries_job.rb +++ b/app/jobs/shipit/purge_old_deliveries_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class PurgeOldDeliveriesJob < BackgroundJob include BackgroundJob::Unique diff --git a/app/jobs/shipit/reap_dead_tasks_job.rb b/app/jobs/shipit/reap_dead_tasks_job.rb index 648314e0a..f15b6d2b0 100644 --- a/app/jobs/shipit/reap_dead_tasks_job.rb +++ b/app/jobs/shipit/reap_dead_tasks_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class ReapDeadTasksJob < BackgroundJob include BackgroundJob::Unique diff --git a/app/jobs/shipit/refresh_check_runs_job.rb b/app/jobs/shipit/refresh_check_runs_job.rb index 885783112..f34580c0f 100644 --- a/app/jobs/shipit/refresh_check_runs_job.rb +++ b/app/jobs/shipit/refresh_check_runs_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class RefreshCheckRunsJob < BackgroundJob queue_as :default diff --git a/app/jobs/shipit/refresh_github_user_job.rb b/app/jobs/shipit/refresh_github_user_job.rb index 4f817e6a5..c88b367b1 100644 --- a/app/jobs/shipit/refresh_github_user_job.rb +++ b/app/jobs/shipit/refresh_github_user_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class RefreshGithubUserJob < BackgroundJob queue_as :default diff --git a/app/jobs/shipit/refresh_merge_request_job.rb b/app/jobs/shipit/refresh_merge_request_job.rb index ef5ee3951..94d3939e7 100644 --- a/app/jobs/shipit/refresh_merge_request_job.rb +++ b/app/jobs/shipit/refresh_merge_request_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class RefreshMergeRequestJob < BackgroundJob queue_as :default diff --git a/app/jobs/shipit/refresh_statuses_job.rb b/app/jobs/shipit/refresh_statuses_job.rb index 0a94b5733..0cb439ac3 100644 --- a/app/jobs/shipit/refresh_statuses_job.rb +++ b/app/jobs/shipit/refresh_statuses_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class RefreshStatusesJob < BackgroundJob queue_as :default diff --git a/app/jobs/shipit/setup_github_hook_job.rb b/app/jobs/shipit/setup_github_hook_job.rb index e4accd56a..c6f34cb14 100644 --- a/app/jobs/shipit/setup_github_hook_job.rb +++ b/app/jobs/shipit/setup_github_hook_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class SetupGithubHookJob < BackgroundJob queue_as :default diff --git a/app/jobs/shipit/update_estimated_deploy_duration_job.rb b/app/jobs/shipit/update_estimated_deploy_duration_job.rb index 6d4fe2951..04845df19 100644 --- a/app/jobs/shipit/update_estimated_deploy_duration_job.rb +++ b/app/jobs/shipit/update_estimated_deploy_duration_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class UpdateEstimatedDeployDurationJob < BackgroundJob queue_as :default diff --git a/app/jobs/shipit/update_github_last_deployed_ref_job.rb b/app/jobs/shipit/update_github_last_deployed_ref_job.rb index 66a601694..ea9be27da 100644 --- a/app/jobs/shipit/update_github_last_deployed_ref_job.rb +++ b/app/jobs/shipit/update_github_last_deployed_ref_job.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class UpdateGithubLastDeployedRefJob < BackgroundJob queue_as :default diff --git a/app/models/concerns/shipit/deferred_touch.rb b/app/models/concerns/shipit/deferred_touch.rb index 2117a5f74..b9c377e53 100644 --- a/app/models/concerns/shipit/deferred_touch.rb +++ b/app/models/concerns/shipit/deferred_touch.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module DeferredTouch extend ActiveSupport::Concern @@ -39,6 +40,7 @@ def touch_now! def fetch fetch_members do |records| return if records.empty? + records = records.each_with_object({}) do |(model, id, attribute), hash| attributes = (hash[model] ||= {}) ids = (attributes[attribute] ||= []) @@ -78,6 +80,7 @@ def deferred_touch(touches) def schedule_touches return unless self.class.deferred_touches + deferred_touches = self.class.deferred_touches.reject do |m, _fk, _a| ActiveRecord::NoTouching.applied_to?(m.constantize) end diff --git a/app/models/shipit/anonymous_user.rb b/app/models/shipit/anonymous_user.rb index c6c9d206e..edc52abb4 100644 --- a/app/models/shipit/anonymous_user.rb +++ b/app/models/shipit/anonymous_user.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class AnonymousUser def blank? diff --git a/app/models/shipit/api_client.rb b/app/models/shipit/api_client.rb index 27459c3ec..ca1c8803f 100644 --- a/app/models/shipit/api_client.rb +++ b/app/models/shipit/api_client.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class ApiClient < Record InsufficientPermission = Class.new(StandardError) @@ -39,6 +40,7 @@ def check_permissions!(operation, scope) unless permissions.include?(required_permission) raise InsufficientPermission, "This operation requires the `#{required_permission}` permission" end + true end end diff --git a/app/models/shipit/application_record.rb b/app/models/shipit/application_record.rb index 3e8a6ee54..5198356ea 100644 --- a/app/models/shipit/application_record.rb +++ b/app/models/shipit/application_record.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class ApplicationRecord < Record self.abstract_class = true diff --git a/app/models/shipit/check_run.rb b/app/models/shipit/check_run.rb index d0b27d926..d0631f3c2 100644 --- a/app/models/shipit/check_run.rb +++ b/app/models/shipit/check_run.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class CheckRun < ApplicationRecord CONCLUSIONS = %w(success failure neutral cancelled timed_out action_required stale skipped).freeze @@ -27,7 +28,7 @@ def create_or_update_by!(selector:, attributes: {}) # Persist the received data anyways, in case it is now the canonical data on GitHub despite the timestamp. if attributes[:conclusion] != record.conclusion && record.newer_than_webhook?(attributes) Rails.logger.warn( - "Conflicting stale checkrun received. Checkrun id: #{selector[:github_id]}, Details: #{attributes}" + "Conflicting stale checkrun received. Checkrun id: #{selector[:github_id]}, Details: #{attributes}", ) RefreshCheckRunsJob.set(wait: CHECK_RUN_REFRESH_DELAY).perform_later(commit_id: record.commit_id) end diff --git a/app/models/shipit/command_line_user.rb b/app/models/shipit/command_line_user.rb index 9cac72196..fa5979d33 100644 --- a/app/models/shipit/command_line_user.rb +++ b/app/models/shipit/command_line_user.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class CommandLineUser def present? diff --git a/app/models/shipit/commit.rb b/app/models/shipit/commit.rb index a1417cc5b..f234af3df 100644 --- a/app/models/shipit/commit.rb +++ b/app/models/shipit/commit.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class Commit < Record include DeferredTouch @@ -20,8 +21,11 @@ class Commit < Record after_commit { broadcast_update } after_create { stack.update_undeployed_commits_count } - after_commit :schedule_refresh_statuses!, :schedule_refresh_check_runs!, :schedule_fetch_stats!, - :schedule_continuous_delivery, on: :create + after_commit :schedule_refresh_statuses!, + :schedule_refresh_check_runs!, + :schedule_fetch_stats!, + :schedule_continuous_delivery, + on: :create belongs_to :author, class_name: 'User', optional: true, inverse_of: :authored_commits belongs_to :committer, class_name: 'User', optional: true, inverse_of: :commits @@ -53,26 +57,35 @@ def lock_author=(user) scope :reachable, -> { where(detached: false) } - delegate :broadcast_update, :github_repo_name, :hidden_statuses, :required_statuses, :blocking_statuses, - :soft_failing_statuses, to: :stack + delegate :broadcast_update, + :github_repo_name, + :hidden_statuses, + :required_statuses, + :blocking_statuses, + :soft_failing_statuses, + to: :stack def self.newer_than(commit) return all unless commit + where('id > ?', commit.try(:id) || commit) end def self.older_than(commit) return all unless commit + where('id < ?', commit.try(:id) || commit) end def self.since(commit) return all unless commit + where('id >= ?', commit.try(:id) || commit) end def self.until(commit) return all unless commit + where('id <= ?', commit.try(:id) || commit) end @@ -91,6 +104,7 @@ def self.by_sha(sha) commits = where('sha like ?', "#{sha}%").take(2) raise AmbiguousRevision, "Short SHA1 #{sha} is ambiguous (matches multiple commits)" if commits.size > 1 + commits.first end @@ -266,6 +280,7 @@ def short_sha def schedule_continuous_delivery return unless deployable? && stack.continuous_deployment? && stack.deployable? + # This buffer is to allow for statuses and checks to be refreshed before evaluating if the commit is deployable # - e.g. if the commit was fast-forwarded with already passing CI. ContinuousDeliveryJob.set(wait: RECENT_COMMIT_THRESHOLD).perform_later(stack) @@ -300,6 +315,7 @@ def deploy_failed? def identify_merge_request return unless message_parser.pull_request? + if merge_request = stack.merge_requests.find_by(number: message_parser.pull_request_number) self.merge_request = merge_request self.pull_request_number = merge_request.number diff --git a/app/models/shipit/commit_checks.rb b/app/models/shipit/commit_checks.rb index 70eeba8a1..7b56bc95b 100644 --- a/app/models/shipit/commit_checks.rb +++ b/app/models/shipit/commit_checks.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class CommitChecks < EphemeralCommitChecks OUTPUT_TTL = 10.minutes.to_i @@ -16,6 +17,7 @@ def synchronize(&block) def schedule return false if Shipit.redis.get(key('status')).present? + synchronize do return false if Shipit.redis.get(key('status')).present? diff --git a/app/models/shipit/commit_deployment.rb b/app/models/shipit/commit_deployment.rb index 08bc30542..e6fbdf239 100644 --- a/app/models/shipit/commit_deployment.rb +++ b/app/models/shipit/commit_deployment.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class CommitDeployment < Record belongs_to :task @@ -23,6 +24,7 @@ def create_deployment_on_github! create_deployment_on_github(stack.github_api) rescue Octokit::ClientError raise if Shipit.github(organization: stack.repository.owner).api == stack.github_api + # If the deploy author didn't gave us the permission to create the deployment we falback the the main shipit # user. # diff --git a/app/models/shipit/commit_deployment_status.rb b/app/models/shipit/commit_deployment_status.rb index 85bde2b35..35f3d30bc 100644 --- a/app/models/shipit/commit_deployment_status.rb +++ b/app/models/shipit/commit_deployment_status.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class CommitDeploymentStatus < Record DESCRIPTION_CHARACTER_LIMIT_ON_GITHUB = 140 @@ -11,10 +12,12 @@ class CommitDeploymentStatus < Record def create_on_github! return if github_id? + response = begin create_status_on_github(stack.github_api) rescue Octokit::ClientError raise if Shipit.github(organization: stack.repository.owner).api == stack.github_api + # If the deploy author didn't gave us the permission to create the deployment we falback the the main shipit # user. # diff --git a/app/models/shipit/commit_message.rb b/app/models/shipit/commit_message.rb index 337b053be..fb00022cd 100644 --- a/app/models/shipit/commit_message.rb +++ b/app/models/shipit/commit_message.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class CommitMessage GITHUB_MERGE_COMMIT_PATTERN = /\AMerge pull request #(?\d+) from \S+\n\n(?.*)/ @@ -27,6 +28,7 @@ def to_s def parsed return @parsed if defined?(@parsed) + @parsed = to_s.match(GITHUB_MERGE_COMMIT_PATTERN) end end diff --git a/app/models/shipit/delivery.rb b/app/models/shipit/delivery.rb index 141c87f8b..e5c25dc44 100644 --- a/app/models/shipit/delivery.rb +++ b/app/models/shipit/delivery.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class Delivery < Record STATUSES = %w(pending scheduled sent).freeze diff --git a/app/models/shipit/deploy.rb b/app/models/shipit/deploy.rb index 52c9bdf12..536a4ad4f 100644 --- a/app/models/shipit/deploy.rb +++ b/app/models/shipit/deploy.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'fileutils' module Shipit @@ -35,9 +36,9 @@ def append_status(task_status) reload.each do |deployment| Rails.logger.info( "Creating #{github_status} deploy status for deployment #{deployment.id}. "\ - "Commit: #{deployment.sha}, Github id: #{deployment.github_id}, "\ - "Repo: #{deployment.stack.repo_name}, Environment: #{deployment.stack.environment}, "\ - "API Url: #{deployment.api_url}.", + "Commit: #{deployment.sha}, Github id: #{deployment.github_id}, "\ + "Repo: #{deployment.stack.repo_name}, Environment: #{deployment.stack.environment}, "\ + "API Url: #{deployment.api_url}.", ) deployment.statuses.create!(status: github_status) end @@ -45,9 +46,9 @@ def append_status(task_status) each do |deployment| Rails.logger.warn( "No GitHub status for task status #{task_status}. "\ - "Commit: #{deployment.sha}, Github id: #{deployment.github_id}, "\ - "Repo: #{deployment.stack.repo_name}, Environment: #{deployment.stack.environment}, "\ - "API Url: #{deployment.api_url}.", + "Commit: #{deployment.sha}, Github id: #{deployment.github_id}, "\ + "Repo: #{deployment.stack.repo_name}, Environment: #{deployment.stack.environment}, "\ + "API Url: #{deployment.api_url}.", ) end end @@ -64,21 +65,25 @@ def append_status(task_status) def self.newer_than(deploy) return all unless deploy + where('id > ?', deploy.try(:id) || deploy) end def self.older_than(deploy) return all unless deploy + where('id < ?', deploy.try(:id) || deploy) end def self.since(deploy) return all unless deploy + where('id >= ?', deploy.try(:id) || deploy) end def self.until(deploy) return all unless deploy + where('id <= ?', deploy.try(:id) || deploy) end @@ -176,6 +181,7 @@ def variables def reject! return if failed? || aborted? + transaction do flap! unless flapping? update!(confirmations: [confirmations - 1, -1].min) @@ -185,6 +191,7 @@ def reject! def accept! return if success? + transaction do flap! unless flapping? update!(confirmations: [confirmations + 1, 1].max) @@ -254,6 +261,7 @@ def create_commit_deployments # Create one for each pull request in the batch, to give feedback on the PR timeline commits.select(&:pull_request?).each do |commit| next if commit.pull_request_head_sha.blank? # This attribute was not always populated + commit_deployments.create!(sha: commit.pull_request_head_sha) end @@ -274,8 +282,8 @@ def update_release_status when 'validating' append_release_status( 'pending', - "The deploy on #{stack.environment} succeeded" - ) unless stack.release_status_delay.zero? + "The deploy on #{stack.environment} succeeded", + ) if stack.release_status_delay.nonzero? MarkDeployHealthyJob.set(wait: stack.release_status_delay) .perform_later(self) if stack.release_status_delay.positive? @@ -289,11 +297,13 @@ def update_release_status def trigger_revert_if_required return unless rollback_once_aborted? return unless supports_rollback? + trigger_revert(rollback_to: rollback_once_aborted_to) end def default_since_commit_id return unless stack + @default_since_commit_id ||= stack.last_completed_deploy&.until_commit_id end @@ -308,6 +318,7 @@ def schedule_merges def schedule_continuous_delivery return unless stack.continuous_deployment? + ContinuousDeliveryJob.perform_later(stack) end @@ -321,6 +332,7 @@ def update_last_deploy_time def update_latest_deployed_ref return unless previous_changes.include?(:status) + stack.update_latest_deployed_ref if previous_changes[:status].last == 'success' end end diff --git a/app/models/shipit/deploy_spec.rb b/app/models/shipit/deploy_spec.rb index 0d10da807..a3002ba35 100644 --- a/app/models/shipit/deploy_spec.rb +++ b/app/models/shipit/deploy_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'pathname' module Shipit @@ -255,6 +256,7 @@ def links def around_steps(section) steps = yield return unless steps + config(section, 'pre') { [] } + steps + config(section, 'post') { [] } end diff --git a/app/models/shipit/deploy_spec/bundler_discovery.rb b/app/models/shipit/deploy_spec/bundler_discovery.rb index cbd59fe66..a836b9f26 100644 --- a/app/models/shipit/deploy_spec/bundler_discovery.rb +++ b/app/models/shipit/deploy_spec/bundler_discovery.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class DeploySpec module BundlerDiscovery @@ -43,6 +44,7 @@ def remove_ruby_version_from_gemfile def frozen_flag return unless gemfile_lock_exists? return if config('dependencies', 'bundler', 'frozen') == false + '--frozen' end diff --git a/app/models/shipit/deploy_spec/capistrano_discovery.rb b/app/models/shipit/deploy_spec/capistrano_discovery.rb index ff6522254..0f1759bb7 100644 --- a/app/models/shipit/deploy_spec/capistrano_discovery.rb +++ b/app/models/shipit/deploy_spec/capistrano_discovery.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class DeploySpec module CapistranoDiscovery diff --git a/app/models/shipit/deploy_spec/file_system.rb b/app/models/shipit/deploy_spec/file_system.rb index 3708b9df3..0eed92ff6 100644 --- a/app/models/shipit/deploy_spec/file_system.rb +++ b/app/models/shipit/deploy_spec/file_system.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class DeploySpec class FileSystem < DeploySpec @@ -139,9 +140,9 @@ def read_config(path) def shipit_not_obeying_bare_file_echo_command <<~EOM - echo \"\e[1;31mShipit is configured to ignore the bare '#{app_name}.yml' file. + echo "\e[1;31mShipit is configured to ignore the bare '#{app_name}.yml' file. Please rename this file to more specifically include the environment name. - Deployments will fail until a valid '#{app_name}.#{@env}.yml' file is found.\e[0m\" + Deployments will fail until a valid '#{app_name}.#{@env}.yml' file is found.\e[0m" EOM end end diff --git a/app/models/shipit/deploy_spec/kubernetes_discovery.rb b/app/models/shipit/deploy_spec/kubernetes_discovery.rb index b41c10968..4fbeb5903 100644 --- a/app/models/shipit/deploy_spec/kubernetes_discovery.rb +++ b/app/models/shipit/deploy_spec/kubernetes_discovery.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class DeploySpec module KubernetesDiscovery diff --git a/app/models/shipit/deploy_spec/lerna_discovery.rb b/app/models/shipit/deploy_spec/lerna_discovery.rb index 5a60a6e7d..9d42da152 100644 --- a/app/models/shipit/deploy_spec/lerna_discovery.rb +++ b/app/models/shipit/deploy_spec/lerna_discovery.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'json' module Shipit @@ -72,6 +73,7 @@ def discover_deploy_steps def publish_lerna_packages return publish_independent_packages if lerna_version == 'independent' + publish_fixed_version_packages end @@ -95,20 +97,25 @@ def publish_fixed_version_packages version = lerna_version publish = if lerna_lerna >= LATEST_MAJOR_VERSION %W( - node_modules/.bin/lerna publish + node_modules/.bin/lerna + publish from-git --yes - --dist-tag #{dist_tag(version)} + --dist-tag + #{dist_tag(version)} ).join(" ") else # `yarn publish` requires user input, so always use npm. %W( - node_modules/.bin/lerna publish + node_modules/.bin/lerna + publish --yes --skip-git - --repo-version #{version} + --repo-version + #{version} --force-publish=* - --npm-tag #{dist_tag(version)} + --npm-tag + #{dist_tag(version)} --npm-client=npm --skip-npm=false ).join(" ") diff --git a/app/models/shipit/deploy_spec/npm_discovery.rb b/app/models/shipit/deploy_spec/npm_discovery.rb index 714d7416e..99eb00afe 100644 --- a/app/models/shipit/deploy_spec/npm_discovery.rb +++ b/app/models/shipit/deploy_spec/npm_discovery.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'json' module Shipit @@ -59,6 +60,7 @@ def dist_tag(version) # An 1.0.0-beta.1 would be installable using both: # `yarn add package@1.0.0-beta.1` and `yarn add package@next` return 'next' if ['-beta', '-alpha', '-rc', '-next'].any? { |tag| version.include?(tag) } + 'latest' end @@ -104,21 +106,25 @@ def publish_config_access # default to private deploy when we enforce a publishConfig if enforce_publish_config? return PRIVATE if config.blank? + config['access'] || PRIVATE end return PUBLIC if config.blank? + config['access'] || PUBLIC end def scoped_package? return false if Shipit.npm_org_scope.nil? + package_name.start_with?(Shipit.npm_org_scope) end def enforce_publish_config? enforce = Shipit.enforce_publish_config return false if enforce.nil? || enforce.to_s == "0" + true end @@ -164,6 +170,7 @@ def publish_npm_package publish = "npm publish --tag #{dist_tag(package_version)} --access #{publish_config_access}" return [check_tags, generate_npmrc, publish] if enforce_publish_config? + [check_tags, publish] end diff --git a/app/models/shipit/deploy_spec/pypi_discovery.rb b/app/models/shipit/deploy_spec/pypi_discovery.rb index 93a0645a9..57376de53 100644 --- a/app/models/shipit/deploy_spec/pypi_discovery.rb +++ b/app/models/shipit/deploy_spec/pypi_discovery.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class DeploySpec module PypiDiscovery diff --git a/app/models/shipit/deploy_spec/rubygems_discovery.rb b/app/models/shipit/deploy_spec/rubygems_discovery.rb index 8eb2ab3c5..c7fabd58f 100644 --- a/app/models/shipit/deploy_spec/rubygems_discovery.rb +++ b/app/models/shipit/deploy_spec/rubygems_discovery.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class DeploySpec module RubygemsDiscovery diff --git a/app/models/shipit/deploy_stats.rb b/app/models/shipit/deploy_stats.rb index 1f4d94848..b2ec3ca7d 100644 --- a/app/models/shipit/deploy_stats.rb +++ b/app/models/shipit/deploy_stats.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class DeployStats delegate :empty?, to: :@deploys @@ -14,6 +15,7 @@ def count def average_duration return if empty? + @durations.sum / @durations.length.to_f end @@ -27,11 +29,13 @@ def min_duration def median_duration return if @durations.empty? + (sorted_durations[(@durations.length - 1) / 2] + sorted_durations[@durations.length / 2]) / 2.0 end def success_rate return if empty? + (@deploys.count(&:success?) / @deploys.length.to_f) * 100 end @@ -52,6 +56,7 @@ def sorted_durations def percent_change(from, to) return if to.nil? || from.nil? return to * 100 if from.zero? + ((to - from) / from.to_f) * 100 end end diff --git a/app/models/shipit/duration.rb b/app/models/shipit/duration.rb index 51856909c..9015a86b6 100644 --- a/app/models/shipit/duration.rb +++ b/app/models/shipit/duration.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class Duration < ActiveSupport::Duration ParseError = Class.new(ArgumentError) @@ -25,6 +26,7 @@ def parse(value) unless match = FORMAT.match(value.to_s) raise ParseError, "not a duration: #{value.inspect}" end + parts = [] UNITS.each_value do |unit| if value = match[unit] diff --git a/app/models/shipit/ephemeral_commit_checks.rb b/app/models/shipit/ephemeral_commit_checks.rb index 14000a822..38f191171 100644 --- a/app/models/shipit/ephemeral_commit_checks.rb +++ b/app/models/shipit/ephemeral_commit_checks.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class EphemeralCommitChecks FINAL_STATUSES = %w(failed error success).freeze diff --git a/app/models/shipit/github_hook.rb b/app/models/shipit/github_hook.rb index e3dac614f..69228e091 100644 --- a/app/models/shipit/github_hook.rb +++ b/app/models/shipit/github_hook.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class GithubHook < Record # TODO: app-migration, delete class diff --git a/app/models/shipit/github_status.rb b/app/models/shipit/github_status.rb index 339941e66..713eead4c 100644 --- a/app/models/shipit/github_status.rb +++ b/app/models/shipit/github_status.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module GithubStatus CACHE_KEY = 'github::status' diff --git a/app/models/shipit/hook.rb b/app/models/shipit/hook.rb index 9aa6a4e1f..8c7ae695c 100644 --- a/app/models/shipit/hook.rb +++ b/app/models/shipit/hook.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class Hook < Record class DeliverySigner @@ -96,6 +97,7 @@ def signature class << self def emit(event, stack, payload) raise "#{event} is not declared in Shipit::Hook::EVENTS" unless EVENTS.include?(event.to_s) + Shipit::EmitEventJob.perform_later( event: event.to_s, stack_id: stack&.id, diff --git a/app/models/shipit/membership.rb b/app/models/shipit/membership.rb index fa2907761..22948bf92 100644 --- a/app/models/shipit/membership.rb +++ b/app/models/shipit/membership.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class Membership < Record belongs_to :team, required: true diff --git a/app/models/shipit/merge_request.rb b/app/models/shipit/merge_request.rb index 3ce283311..c5ce9a6a4 100644 --- a/app/models/shipit/merge_request.rb +++ b/app/models/shipit/merge_request.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class MergeRequest < ApplicationRecord include DeferredTouch @@ -117,6 +118,7 @@ def self.extract_number(stack, number_or_url) when %r{\Ahttps://#{Regexp.escape(Shipit.github(organization: org).domain)}/([^/]+)/([^/]+)/pull/(\d+)} return unless $1.downcase == stack.repo_owner.downcase return unless $2.downcase == stack.repo_name.downcase + $3.to_i end end @@ -144,6 +146,7 @@ def reject!(reason) unless REJECTION_REASONS.include?(reason) raise ArgumentError, "invalid reason: #{reason.inspect}, must be one of: #{REJECTION_REASONS.inspect}" end + self.rejection_reason = reason.presence super() true @@ -154,6 +157,7 @@ def reject_unless_mergeable! return reject!('ci_missing') if any_status_checks_missing? return reject!('ci_failing') if any_status_checks_failed? return reject!('requires_rebase') if stale? + false end @@ -188,6 +192,7 @@ def merge! def all_status_checks_passed? return false unless head + StatusChecker.new(head, head.statuses_and_check_runs, stack.cached_deploy_spec).success? end @@ -207,6 +212,7 @@ def waiting? def need_revalidation? timeout = stack.cached_deploy_spec&.revalidate_merge_requests_after return false unless timeout + (revalidated_at + timeout).past? end @@ -255,11 +261,13 @@ def github_pull_request=(github_pull_request) def merge_message return title unless merge_requested_by + "#{title}\n\n#{MERGE_REQUEST_FIELD}: #{merge_requested_by.login}\n" end def stale? return false unless base_commit + spec = stack.cached_deploy_spec if max_branch_age = spec.max_divergence_age return true if Time.now.utc - head.committed_at > max_branch_age @@ -286,6 +294,7 @@ def record_merge_status_change def emit_hooks return unless @merge_status_changed + @merge_status_changed = nil Hook.emit('merge', stack, merge_request: self, status: merge_status, stack: stack) end diff --git a/app/models/shipit/output_chunk.rb b/app/models/shipit/output_chunk.rb index 1e673006b..3070fb7df 100644 --- a/app/models/shipit/output_chunk.rb +++ b/app/models/shipit/output_chunk.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class OutputChunk < Record belongs_to :task diff --git a/app/models/shipit/provisioning_handler.rb b/app/models/shipit/provisioning_handler.rb index c6255cbc3..05bbba35b 100644 --- a/app/models/shipit/provisioning_handler.rb +++ b/app/models/shipit/provisioning_handler.rb @@ -17,6 +17,7 @@ def register(handler_class) def fetch(name) return default if name.blank? + registry.fetch(name) { ProvisioningHandler::UnregisteredProvisioningHandler } end diff --git a/app/models/shipit/provisioning_handler/unregistered_provisioning_handler.rb b/app/models/shipit/provisioning_handler/unregistered_provisioning_handler.rb index bd2e8838b..ac4683e01 100644 --- a/app/models/shipit/provisioning_handler/unregistered_provisioning_handler.rb +++ b/app/models/shipit/provisioning_handler/unregistered_provisioning_handler.rb @@ -16,8 +16,8 @@ def down def lock_and_prevent_transition stack.lock( "Failed to find a provisioning handler named '#{stack.provisioning_handler_name}' in the " \ - "ProvisioningHandler registry. Have you registered it via Provisioning::Handler.register?", - Shipit::AnonymousUser.new + "ProvisioningHandler registry. Have you registered it via Provisioning::Handler.register?", + Shipit::AnonymousUser.new, ) # Prevent transition of the ReviewStack 'provision_status' diff --git a/app/models/shipit/record.rb b/app/models/shipit/record.rb index 4b98b9909..9cb1ba3a4 100644 --- a/app/models/shipit/record.rb +++ b/app/models/shipit/record.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class Record < ActiveRecord::Base self.abstract_class = true diff --git a/app/models/shipit/release_status.rb b/app/models/shipit/release_status.rb index 3bbd38130..314b24b91 100644 --- a/app/models/shipit/release_status.rb +++ b/app/models/shipit/release_status.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class ReleaseStatus < Record MAX_DESCRIPTION_LENGTH = 140 diff --git a/app/models/shipit/repository.rb b/app/models/shipit/repository.rb index 737a858b5..a763a60d2 100644 --- a/app/models/shipit/repository.rb +++ b/app/models/shipit/repository.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class NullRepository def id @@ -37,8 +38,11 @@ class Repository < ApplicationRecord NAME_MAX_SIZE = 100 private_constant :NAME_MAX_SIZE - validates :name, uniqueness: { scope: %i(owner), case_sensitive: false, - message: 'cannot be used more than once', } + validates :name, uniqueness: { + scope: %i(owner), + case_sensitive: false, + message: 'cannot be used more than once', + } validates :owner, :name, presence: true, ascii_only: true validates :owner, format: { with: /\A[a-z0-9_\-\.]+\z/ }, length: { maximum: OWNER_MAX_SIZE } validates :name, format: { with: /\A[a-z0-9_\-\.]+\z/ }, length: { maximum: NAME_MAX_SIZE } diff --git a/app/models/shipit/review_stack.rb b/app/models/shipit/review_stack.rb index 758ab54c0..9383268ef 100644 --- a/app/models/shipit/review_stack.rb +++ b/app/models/shipit/review_stack.rb @@ -6,7 +6,7 @@ def self.clear_stale_caches Shipit::ReviewStack.where( "archived_since > :earliest AND archived_since < :latest", earliest: 1.day.ago, - latest: 1.hour.ago + latest: 1.hour.ago, ).find_each do |review_stack| review_stack.clear_local_files end @@ -16,7 +16,7 @@ def self.delete_old_deployment_directories Shipit::Deploy.not_active.where( "created_at > :earliest AND updated_at < :latest", earliest: 1.day.ago, - latest: 1.hour.ago + latest: 1.hour.ago, ).find_each do |deploy| Shipit::Commands.for(deploy).clear_working_directory end @@ -88,7 +88,7 @@ def env .merge( pull_request .labels - .each_with_object({}) { |label_name, labels| labels[label_name.upcase] = "true" } + .each_with_object({}) { |label_name, labels| labels[label_name.upcase] = "true" }, ) end @@ -102,11 +102,13 @@ def provisioner_class def enqueue_for_provisioning return if awaiting_provision + update!(awaiting_provision: true) end def remove_from_provisioning_queue return unless awaiting_provision + update!(awaiting_provision: false) end diff --git a/app/models/shipit/review_stack_provisioning_queue.rb b/app/models/shipit/review_stack_provisioning_queue.rb index 23121da34..1f63a900f 100644 --- a/app/models/shipit/review_stack_provisioning_queue.rb +++ b/app/models/shipit/review_stack_provisioning_queue.rb @@ -31,7 +31,7 @@ def provision(stack) stack.provision else Rails.logger.info( - "Putting review ReviewStack<#{stack.id}> back into the provisioning queue - #provision? was falsey." + "Putting review ReviewStack<#{stack.id}> back into the provisioning queue - #provision? was falsey.", ) end end diff --git a/app/models/shipit/rollback.rb b/app/models/shipit/rollback.rb index 261858bd2..dfa1f76e6 100644 --- a/app/models/shipit/rollback.rb +++ b/app/models/shipit/rollback.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class Rollback < Deploy belongs_to :deploy, foreign_key: :parent_id, inverse_of: false @@ -45,6 +46,7 @@ def update_release_status # When we rollback to a certain revision, assume that all later deploys were faulty stack.deploys.newer_than(deploy.id).until(stack.last_completed_deploy.id).to_a.each do |deploy| next if deploy.id == id + deploy.report_faulty!(description: "A rollback of #{stack.to_param} was triggered") end end diff --git a/app/models/shipit/stack.rb b/app/models/shipit/stack.rb index 403f7ff82..7ef2bf4b1 100644 --- a/app/models/shipit/stack.rb +++ b/app/models/shipit/stack.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'fileutils' module Shipit @@ -92,7 +93,8 @@ def sync_github_if_necessary end validates :repository, uniqueness: { - scope: %i(environment), case_sensitive: false, + scope: %i(environment), + case_sensitive: false, message: 'cannot be used more than once with this environment. Check archived stacks.', } validates :environment, format: { with: /\A[a-z0-9\-_\:]+\z/ }, length: { maximum: ENVIRONMENT_MAX_SIZE } @@ -111,7 +113,7 @@ def sync_github_if_necessary :supports_fetch_deployed_revision?, :supports_rollback?, to: :cached_deploy_spec, - allow_nil: true + allow_nil: true, ) def self.refresh_deployed_revisions @@ -280,6 +282,7 @@ def merge_status(backlog_leniency_factor: 2.0) return 'locked' if locked? return 'failure' if %w(failure error).freeze.include?(branch_status) return 'backlogged' if backlogged?(backlog_leniency_factor: backlog_leniency_factor) + 'success' end @@ -297,6 +300,7 @@ def branch_status def status return :deploying if active_task? + :default end @@ -403,6 +407,7 @@ def acquire_git_cache_lock(timeout: 15, &block) def clear_git_cache! tmp_path = "#{git_path}-#{SecureRandom.hex}" return unless git_path.exist? + acquire_git_cache_lock do git_path.rename(tmp_path) end @@ -454,6 +459,7 @@ def active_task? def active_task return @active_task if defined?(@active_task) + @active_task ||= tasks.current end @@ -515,9 +521,19 @@ def self.from_param!(param) ).first! end - delegate :plugins, :task_definitions, :hidden_statuses, :required_statuses, :soft_failing_statuses, - :blocking_statuses, :deploy_variables, :filter_task_envs, :filter_deploy_envs, - :maximum_commits_per_deploy, :pause_between_deploys, :retries_on_deploy, :retries_on_rollback, + delegate :plugins, + :task_definitions, + :hidden_statuses, + :required_statuses, + :soft_failing_statuses, + :blocking_statuses, + :deploy_variables, + :filter_task_envs, + :filter_deploy_envs, + :maximum_commits_per_deploy, + :pause_between_deploys, + :retries_on_deploy, + :retries_on_rollback, to: :cached_deploy_spec def monitoring? diff --git a/app/models/shipit/status.rb b/app/models/shipit/status.rb index 1461b3ba4..050ddeb93 100644 --- a/app/models/shipit/status.rb +++ b/app/models/shipit/status.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class Status < Record include Common diff --git a/app/models/shipit/status/common.rb b/app/models/shipit/status/common.rb index 5f1951e86..d7f926fff 100644 --- a/app/models/shipit/status/common.rb +++ b/app/models/shipit/status/common.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class Status module Common diff --git a/app/models/shipit/status/group.rb b/app/models/shipit/status/group.rb index b057a445b..65e29a05c 100644 --- a/app/models/shipit/status/group.rb +++ b/app/models/shipit/status/group.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class Status class Group @@ -30,7 +31,14 @@ def initialize(commit, statuses) @statuses = visible_statuses.sort_by!(&:context) end - delegate :pending?, :success?, :error?, :failure?, :unknown?, :missing?, :state, :simple_state, + delegate :pending?, + :success?, + :error?, + :failure?, + :unknown?, + :missing?, + :state, + :simple_state, to: :significant_status delegate :each, :size, :map, to: :statuses delegate :required_statuses, to: :commit @@ -75,8 +83,10 @@ def significant_status def select_significant_status(statuses) statuses = reject_allowed_to_fail(statuses) return Status::Unknown.new(commit) if statuses.empty? + non_success_statuses = statuses.reject(&:success?) return statuses.first if non_success_statuses.empty? + non_success_statuses.reject(&:pending?).first || non_success_statuses.first || Status::Unknown.new(commit) end diff --git a/app/models/shipit/status/missing.rb b/app/models/shipit/status/missing.rb index e6a2ab183..128fb7163 100644 --- a/app/models/shipit/status/missing.rb +++ b/app/models/shipit/status/missing.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class Status class Missing diff --git a/app/models/shipit/status/unknown.rb b/app/models/shipit/status/unknown.rb index 9cea9089a..94165c241 100644 --- a/app/models/shipit/status/unknown.rb +++ b/app/models/shipit/status/unknown.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class Status class Unknown diff --git a/app/models/shipit/task.rb b/app/models/shipit/task.rb index 9db5e1155..e0af5e0fc 100644 --- a/app/models/shipit/task.rb +++ b/app/models/shipit/task.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class Task < Record include DeferredTouch @@ -35,6 +36,7 @@ module EnvHash class << self def dump(hash) raise TypeError, "Task#env should be a Hash[String => String]" unless hash.is_a?(Hash) + hash = hash.to_h.stringify_keys hash.transform_values! do |value| case value @@ -205,7 +207,9 @@ def report_error!(error) error! end - delegate :acquire_git_cache_lock, :async_refresh_deployed_revision, :async_update_estimated_deploy_duration, + delegate :acquire_git_cache_lock, + :async_refresh_deployed_revision, + :async_update_estimated_deploy_duration, to: :stack delegate :checklist, to: :definition @@ -224,11 +228,13 @@ def spec def enqueue raise "only persisted jobs can be enqueued" unless persisted? + PerformTaskJob.perform_later(self) end def run_now! raise "only persisted jobs can be run" unless persisted? + PerformTaskJob.perform_now(self) end @@ -354,7 +360,7 @@ def abort!(rollback_once_aborted: false, rollback_once_aborted_to: nil, aborted_ update!( rollback_once_aborted: rollback_once_aborted, rollback_once_aborted_to: rollback_once_aborted_to, - aborted_by_id: aborted_by.id + aborted_by_id: aborted_by.id, ) if alive? @@ -383,6 +389,7 @@ def record_status_change def emit_hooks_if_status_changed return unless @status_changed + @status_changed = nil emit_hooks end diff --git a/app/models/shipit/task_definition.rb b/app/models/shipit/task_definition.rb index bc814709b..950baa035 100644 --- a/app/models/shipit/task_definition.rb +++ b/app/models/shipit/task_definition.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class TaskDefinition NotFound = Class.new(StandardError) @@ -6,12 +7,14 @@ class TaskDefinition class << self def load(payload) return if payload.blank? + json = JSON.parse(payload) new(json.delete('id'), json) end def dump(definition) return if definition.blank? + JSON.dump(definition.as_json) end end diff --git a/app/models/shipit/task_execution_strategy/base.rb b/app/models/shipit/task_execution_strategy/base.rb index 50a0b1e9f..16e2e2ff8 100644 --- a/app/models/shipit/task_execution_strategy/base.rb +++ b/app/models/shipit/task_execution_strategy/base.rb @@ -10,7 +10,7 @@ def initialize(task) def execute raise( NotImplmentedError, - "subclasses of TaskExectuionStrategy::Base must implement the #execute method" + "subclasses of TaskExectuionStrategy::Base must implement the #execute method", ) end diff --git a/app/models/shipit/team.rb b/app/models/shipit/team.rb index bcdaee20c..73664bcf6 100644 --- a/app/models/shipit/team.rb +++ b/app/models/shipit/team.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class Team < Record REQUIRED_HOOKS = %i(membership).freeze diff --git a/app/models/shipit/undeployed_commit.rb b/app/models/shipit/undeployed_commit.rb index d499c00f6..c33cf3848 100644 --- a/app/models/shipit/undeployed_commit.rb +++ b/app/models/shipit/undeployed_commit.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class UndeployedCommit < DelegateClass(Commit) attr_reader :index @@ -50,6 +51,7 @@ def expected_to_be_deployed? def blocked? return @blocked if defined?(@blocked) + @blocked = super end end diff --git a/app/models/shipit/unlimited_api_client.rb b/app/models/shipit/unlimited_api_client.rb index 495625873..aad9df62c 100644 --- a/app/models/shipit/unlimited_api_client.rb +++ b/app/models/shipit/unlimited_api_client.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class UnlimitedApiClient def stack_id? diff --git a/app/models/shipit/user.rb b/app/models/shipit/user.rb index 0e283e143..f8b4956d9 100644 --- a/app/models/shipit/user.rb +++ b/app/models/shipit/user.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class User < Record DEFAULT_AVATAR = URI.parse('https://avatars.githubusercontent.com/u/583231?') @@ -48,6 +49,7 @@ def self.find_or_create_from_github(github_user) def self.find_from_github(github_user) return unless github_user.id + find_by(github_id: github_user.id) end @@ -81,11 +83,13 @@ def authorized? def repositories_contributed_to return [] unless id + Stack.where(id: stacks_contributed_to).distinct.pluck(:repository_id) end def stacks_contributed_to return [] unless id + Commit.where('author_id = :id or committer_id = :id', id: id).distinct.pluck(:stack_id) end @@ -142,6 +146,7 @@ def discard_outdated_credentials! def identify_renamed_user! last_commit = commits.last return unless last_commit + github_author = last_commit.github_commit.author update!(github_user: github_author) rescue Octokit::NotFound diff --git a/app/models/shipit/variable_definition.rb b/app/models/shipit/variable_definition.rb index 5093e81f2..438a7965c 100644 --- a/app/models/shipit/variable_definition.rb +++ b/app/models/shipit/variable_definition.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class VariableDefinition attr_reader :name, :title, :default, :select diff --git a/app/models/shipit/webhooks.rb b/app/models/shipit/webhooks.rb index d42c859bf..d680332cc 100644 --- a/app/models/shipit/webhooks.rb +++ b/app/models/shipit/webhooks.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Webhooks class << self diff --git a/app/models/shipit/webhooks/handlers/check_suite_handler.rb b/app/models/shipit/webhooks/handlers/check_suite_handler.rb index ac180d847..92bf68746 100644 --- a/app/models/shipit/webhooks/handlers/check_suite_handler.rb +++ b/app/models/shipit/webhooks/handlers/check_suite_handler.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Webhooks module Handlers diff --git a/app/models/shipit/webhooks/handlers/handler.rb b/app/models/shipit/webhooks/handlers/handler.rb index d9246f6ae..9057b39f2 100644 --- a/app/models/shipit/webhooks/handlers/handler.rb +++ b/app/models/shipit/webhooks/handlers/handler.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Webhooks module Handlers diff --git a/app/models/shipit/webhooks/handlers/membership_handler.rb b/app/models/shipit/webhooks/handlers/membership_handler.rb index f2db98060..e11f6c23d 100644 --- a/app/models/shipit/webhooks/handlers/membership_handler.rb +++ b/app/models/shipit/webhooks/handlers/membership_handler.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Webhooks module Handlers diff --git a/app/models/shipit/webhooks/handlers/pull_request/assigned_handler.rb b/app/models/shipit/webhooks/handlers/pull_request/assigned_handler.rb index a93757b2c..551802829 100644 --- a/app/models/shipit/webhooks/handlers/pull_request/assigned_handler.rb +++ b/app/models/shipit/webhooks/handlers/pull_request/assigned_handler.rb @@ -60,7 +60,7 @@ def pull_request { id: repository.id, }, - } + }, ) end diff --git a/app/models/shipit/webhooks/handlers/pull_request/edited_handler.rb b/app/models/shipit/webhooks/handlers/pull_request/edited_handler.rb index db79583f6..5af38c3de 100644 --- a/app/models/shipit/webhooks/handlers/pull_request/edited_handler.rb +++ b/app/models/shipit/webhooks/handlers/pull_request/edited_handler.rb @@ -56,7 +56,7 @@ def pull_request { id: repository.id, }, - } + }, ) end diff --git a/app/models/shipit/webhooks/handlers/pull_request/review_stack_adapter.rb b/app/models/shipit/webhooks/handlers/pull_request/review_stack_adapter.rb index 56fd66610..87c538e67 100644 --- a/app/models/shipit/webhooks/handlers/pull_request/review_stack_adapter.rb +++ b/app/models/shipit/webhooks/handlers/pull_request/review_stack_adapter.rb @@ -23,7 +23,7 @@ def find_or_create! def archive!(*args, &block) if stack.blank? Rails.logger.info( - "Processing #{action} event for #{repo_name} PR #{pr_number} but no Stack exists. Ignoring." + "Processing #{action} event for #{repo_name} PR #{pr_number} but no Stack exists. Ignoring.", ) return true end @@ -37,7 +37,7 @@ def archive!(*args, &block) def unarchive!(*args, &block) if stack.blank? Rails.logger.info( - "Processing #{action} event for #{repo_name} PR #{pr_number} but no ReviewStack exists. Creating." + "Processing #{action} event for #{repo_name} PR #{pr_number} but no ReviewStack exists. Creating.", ) return create! end @@ -75,7 +75,7 @@ def create! stack .build_pull_request .update!( - github_pull_request: params.pull_request + github_pull_request: params.pull_request, ) end diff --git a/app/models/shipit/webhooks/handlers/push_handler.rb b/app/models/shipit/webhooks/handlers/push_handler.rb index 3f4663843..34ca8f067 100644 --- a/app/models/shipit/webhooks/handlers/push_handler.rb +++ b/app/models/shipit/webhooks/handlers/push_handler.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Webhooks module Handlers diff --git a/app/models/shipit/webhooks/handlers/status_handler.rb b/app/models/shipit/webhooks/handlers/status_handler.rb index f285fbdb8..b19e9af1f 100644 --- a/app/models/shipit/webhooks/handlers/status_handler.rb +++ b/app/models/shipit/webhooks/handlers/status_handler.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Webhooks module Handlers diff --git a/app/serializers/concerns/shipit/conditional_attributes.rb b/app/serializers/concerns/shipit/conditional_attributes.rb index 588f56fbf..c8f734c48 100644 --- a/app/serializers/concerns/shipit/conditional_attributes.rb +++ b/app/serializers/concerns/shipit/conditional_attributes.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module ConditionalAttributes extend ActiveSupport::Concern diff --git a/app/serializers/shipit/anonymous_user_serializer.rb b/app/serializers/shipit/anonymous_user_serializer.rb index 470764957..039150815 100644 --- a/app/serializers/shipit/anonymous_user_serializer.rb +++ b/app/serializers/shipit/anonymous_user_serializer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class AnonymousUserSerializer < UserSerializer end diff --git a/app/serializers/shipit/command_line_user_serializer.rb b/app/serializers/shipit/command_line_user_serializer.rb index 3cb7df90e..cf919cedd 100644 --- a/app/serializers/shipit/command_line_user_serializer.rb +++ b/app/serializers/shipit/command_line_user_serializer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class CommandLineUserSerializer < UserSerializer end diff --git a/app/serializers/shipit/commit_serializer.rb b/app/serializers/shipit/commit_serializer.rb index e215720a5..027d9f08a 100644 --- a/app/serializers/shipit/commit_serializer.rb +++ b/app/serializers/shipit/commit_serializer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class CommitSerializer < ShortCommitSerializer include GithubUrlHelper diff --git a/app/serializers/shipit/deploy_serializer.rb b/app/serializers/shipit/deploy_serializer.rb index 7b13376e4..61fab9f56 100644 --- a/app/serializers/shipit/deploy_serializer.rb +++ b/app/serializers/shipit/deploy_serializer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class DeploySerializer < TaskSerializer include GithubUrlHelper diff --git a/app/serializers/shipit/hook_serializer.rb b/app/serializers/shipit/hook_serializer.rb index e81362151..e48218c09 100644 --- a/app/serializers/shipit/hook_serializer.rb +++ b/app/serializers/shipit/hook_serializer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class HookSerializer < ActiveModel::Serializer include ConditionalAttributes diff --git a/app/serializers/shipit/merge_request_serializer.rb b/app/serializers/shipit/merge_request_serializer.rb index 1b9e91803..7631fb9a2 100644 --- a/app/serializers/shipit/merge_request_serializer.rb +++ b/app/serializers/shipit/merge_request_serializer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class MergeRequestSerializer < ActiveModel::Serializer include GithubUrlHelper @@ -7,8 +8,20 @@ class MergeRequestSerializer < ActiveModel::Serializer has_one :merge_requested_by has_one :head, serializer: ShortCommitSerializer - attributes :id, :number, :title, :github_id, :additions, :deletions, :state, :merge_status, :mergeable, - :merge_requested_at, :rejection_reason, :html_url, :branch, :base_ref + attributes :id, + :number, + :title, + :github_id, + :additions, + :deletions, + :state, + :merge_status, + :mergeable, + :merge_requested_at, + :rejection_reason, + :html_url, + :branch, + :base_ref def html_url github_pull_request_url(object) diff --git a/app/serializers/shipit/rollback_serializer.rb b/app/serializers/shipit/rollback_serializer.rb index 5efddf1d0..abc8cd2e2 100644 --- a/app/serializers/shipit/rollback_serializer.rb +++ b/app/serializers/shipit/rollback_serializer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class RollbackSerializer < DeploySerializer def type diff --git a/app/serializers/shipit/short_commit_serializer.rb b/app/serializers/shipit/short_commit_serializer.rb index 6f70609fa..a55bd6450 100644 --- a/app/serializers/shipit/short_commit_serializer.rb +++ b/app/serializers/shipit/short_commit_serializer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class ShortCommitSerializer < ActiveModel::Serializer attributes :sha, :message diff --git a/app/serializers/shipit/stack_serializer.rb b/app/serializers/shipit/stack_serializer.rb index c08869f5f..0a59979ee 100644 --- a/app/serializers/shipit/stack_serializer.rb +++ b/app/serializers/shipit/stack_serializer.rb @@ -1,14 +1,34 @@ # frozen_string_literal: true + module Shipit class StackSerializer < ActiveModel::Serializer include ConditionalAttributes has_one :lock_author - attributes :id, :repo_owner, :repo_name, :environment, :html_url, :url, :tasks_url, :deploy_url, - :merge_requests_url, :deploy_spec, :undeployed_commits_count, :is_locked, :lock_reason, :continuous_deployment, - :created_at, :updated_at, :locked_since, :last_deployed_at, :branch, :merge_queue_enabled, :is_archived, - :archived_since, :ignore_ci + attributes :id, + :repo_owner, + :repo_name, + :environment, + :html_url, + :url, + :tasks_url, + :deploy_url, + :merge_requests_url, + :deploy_spec, + :undeployed_commits_count, + :is_locked, + :lock_reason, + :continuous_deployment, + :created_at, + :updated_at, + :locked_since, + :last_deployed_at, + :branch, + :merge_queue_enabled, + :is_archived, + :archived_since, + :ignore_ci def url api_stack_url(object) diff --git a/app/serializers/shipit/tail_task_serializer.rb b/app/serializers/shipit/tail_task_serializer.rb index 0a98a8474..8c8efe56f 100644 --- a/app/serializers/shipit/tail_task_serializer.rb +++ b/app/serializers/shipit/tail_task_serializer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class TailTaskSerializer < ActiveModel::Serializer include ChunksHelper @@ -8,6 +9,7 @@ class TailTaskSerializer < ActiveModel::Serializer def url return @url if defined? @url + @url = next_chunks_url(task, last_byte: next_offset) end @@ -42,6 +44,7 @@ def last_byte def rollback return @rollback if defined? @rollback + @rollback = stack.rollbacks.where(parent_id: task.id).last end end diff --git a/app/serializers/shipit/task_serializer.rb b/app/serializers/shipit/task_serializer.rb index 792936b47..925549ffa 100644 --- a/app/serializers/shipit/task_serializer.rb +++ b/app/serializers/shipit/task_serializer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class TaskSerializer < ActiveModel::Serializer include ConditionalAttributes diff --git a/app/serializers/shipit/user_serializer.rb b/app/serializers/shipit/user_serializer.rb index a18112fd8..bc4304e16 100644 --- a/app/serializers/shipit/user_serializer.rb +++ b/app/serializers/shipit/user_serializer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class UserSerializer < ActiveModel::Serializer attributes :id, :name, :email, :login, :avatar_url, :created_at, :updated_at, :github_id, :anonymous diff --git a/app/validators/ascii_only_validator.rb b/app/validators/ascii_only_validator.rb index bc0bda063..ab14efb5e 100644 --- a/app/validators/ascii_only_validator.rb +++ b/app/validators/ascii_only_validator.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + class AsciiOnlyValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) if value && !value.ascii_only? diff --git a/app/validators/subset_validator.rb b/app/validators/subset_validator.rb index 3eecb397f..d71c9fea3 100644 --- a/app/validators/subset_validator.rb +++ b/app/validators/subset_validator.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + class SubsetValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) superset = options[:of] diff --git a/app/views/shipit/ccmenu/project.xml.builder b/app/views/shipit/ccmenu/project.xml.builder index b03ff293d..0acac6931 100644 --- a/app/views/shipit/ccmenu/project.xml.builder +++ b/app/views/shipit/ccmenu/project.xml.builder @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Derived from http://timnew.me/blog/2013/04/07/multiple-project-summary-reporting-standard-cctray-xml-feed/ status_map = { 'backlogged' => 'failure', 'locked' => 'failure' } xml.instruct! diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 4ea9ee928..5c885d1d2 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + ActiveSupport::Inflector.inflections(:en) do |inflect| inflect.acronym('CCMenu') end diff --git a/config/routes.rb b/config/routes.rb index 9da476b8a..07aab4e84 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Shipit::Engine.routes.draw do stack_id_format = %r{[^/]+/[^/]+/[^/]+} repository_id_format = %r{[^/]+/[^/]+} diff --git a/lib/shipit.rb b/lib/shipit.rb index 885f6b53f..41e216020 100644 --- a/lib/shipit.rb +++ b/lib/shipit.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'active_support/all' require 'active_model_serializers' require 'state_machines-activerecord' @@ -64,7 +65,10 @@ module Shipit delegate :table_name_prefix, to: :secrets - attr_accessor :disable_api_authentication, :timeout_exit_codes, :deployment_checks, :respect_bare_shipit_file, + attr_accessor :disable_api_authentication, + :timeout_exit_codes, + :deployment_checks, + :respect_bare_shipit_file, :database_serializer attr_writer( :internal_hook_receivers, @@ -112,6 +116,7 @@ module SafeJSON class << self def load(serial) return nil if serial.nil? + # JSON.load is unsafe, we should use parse instead JSON.parse(serial) end @@ -136,6 +141,7 @@ def load(serial) def dump(object) return if object.nil? + JSON.dump(object) end end @@ -167,12 +173,14 @@ def github(organization: github_default_organization) def github_default_organization return nil unless secrets&.github + org = secrets.github.keys.first TOP_LEVEL_GH_KEYS.include?(org) ? nil : org end def github_organizations return [nil] unless github_default_organization + secrets.github.keys end diff --git a/lib/shipit/cast_value.rb b/lib/shipit/cast_value.rb index 3ab990084..e204c0617 100644 --- a/lib/shipit/cast_value.rb +++ b/lib/shipit/cast_value.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module CastValue def to_boolean(value) diff --git a/lib/shipit/command.rb b/lib/shipit/command.rb index 7f60ea36a..4b2a69bb2 100644 --- a/lib/shipit/command.rb +++ b/lib/shipit/command.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'pty' require 'shellwords' require 'fileutils' @@ -83,6 +84,7 @@ def interpolated_arguments def start(&block) return if @started + @control_block = block @out = @pid = nil FileUtils.mkdir_p(@chdir) @@ -125,6 +127,7 @@ def red(text) def stream!(&block) stream(&block) raise Failed.new(exit_message, code) unless success? + self end @@ -190,6 +193,7 @@ def kill_and_wait(sig, wait, &block) if reap_child!(block: false) return true end + # If we let the child a little bit of time, it solves it. retry_count -= 1 if retry_count > 0 @@ -235,6 +239,7 @@ def signaled? def reap_child!(block: true) return @status if @status return unless running? # Command was never started e.g. permission denied, not found etc + if block _, @status = Process.waitpid2(@pid) elsif res = Process.waitpid2(@pid, Process::WNOHANG) diff --git a/lib/shipit/commands.rb b/lib/shipit/commands.rb index cbbcff499..b05d769b6 100644 --- a/lib/shipit/commands.rb +++ b/lib/shipit/commands.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class Commands class << self @@ -13,6 +14,7 @@ def git_version def parse_git_version(raw_git_version) match_info = raw_git_version.match(/(\d+\.\d+\.\d+)/) raise 'git command not found' unless match_info + Gem::Version.new(match_info[1]) end end diff --git a/lib/shipit/csv_serializer.rb b/lib/shipit/csv_serializer.rb index 3696fe5ae..f7a3d0d7e 100644 --- a/lib/shipit/csv_serializer.rb +++ b/lib/shipit/csv_serializer.rb @@ -1,15 +1,18 @@ # frozen_string_literal: true + module Shipit module CSVSerializer extend self def load(payload) return [] if payload.blank? + payload.split(',') end def dump(array) return nil if array.blank? + Array.wrap(array).join(',') end end diff --git a/lib/shipit/deploy_commands.rb b/lib/shipit/deploy_commands.rb index 8bba99c41..2b53bdc06 100644 --- a/lib/shipit/deploy_commands.rb +++ b/lib/shipit/deploy_commands.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class DeployCommands < TaskCommands def steps diff --git a/lib/shipit/engine.rb b/lib/shipit/engine.rb index 0d90d124c..da18cf435 100644 --- a/lib/shipit/engine.rb +++ b/lib/shipit/engine.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class Engine < ::Rails::Engine isolate_namespace Shipit diff --git a/lib/shipit/environment_variables.rb b/lib/shipit/environment_variables.rb index fdc2e029f..980a4f266 100644 --- a/lib/shipit/environment_variables.rb +++ b/lib/shipit/environment_variables.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class EnvironmentVariables NotPermitted = Class.new(StandardError) @@ -12,6 +13,7 @@ def with(env) def permit(variable_definitions) return {} unless @env raise "A whitelist is required to sanitize environment variables" unless variable_definitions + sanitize_env_vars(variable_definitions) end diff --git a/lib/shipit/first_parent_commits_iterator.rb b/lib/shipit/first_parent_commits_iterator.rb index d8e0c262b..a58382806 100644 --- a/lib/shipit/first_parent_commits_iterator.rb +++ b/lib/shipit/first_parent_commits_iterator.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class FirstParentCommitsIterator < OctokitIterator def each diff --git a/lib/shipit/flock.rb b/lib/shipit/flock.rb index 36f1f099b..dfbafcfbf 100644 --- a/lib/shipit/flock.rb +++ b/lib/shipit/flock.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'English' require 'timeout' require 'pathname' @@ -16,6 +17,7 @@ def initialize(path) def lock(timeout:) return yield if @acquired + path.parent.mkpath path.open('w') do |file| if retrying(timeout: timeout) { file.flock(File::LOCK_EX | File::LOCK_NB) } diff --git a/lib/shipit/github_app.rb b/lib/shipit/github_app.rb index a8ee5bfba..d7c3f58a7 100644 --- a/lib/shipit/github_app.rb +++ b/lib/shipit/github_app.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class GitHubApp include Mutex_m @@ -107,6 +108,7 @@ def fetch_new_token ) token = Token.from_github(response) raise AuthenticationFailed if token.blank? + Rails.logger.info("Created GitHub access token ending #{token.to_s[-5..-1]}, expires at #{token.expires_at}"\ " and will be refreshed at #{token&.refresh_at}") token diff --git a/lib/shipit/github_http_cache_middleware.rb b/lib/shipit/github_http_cache_middleware.rb index 2accebede..132734c81 100644 --- a/lib/shipit/github_http_cache_middleware.rb +++ b/lib/shipit/github_http_cache_middleware.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class GitHubHTTPCacheMiddleware < Faraday::Middleware def call(request_env) diff --git a/lib/shipit/null_serializer.rb b/lib/shipit/null_serializer.rb index 085a3997d..432e1529e 100644 --- a/lib/shipit/null_serializer.rb +++ b/lib/shipit/null_serializer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module NullSerializer extend self diff --git a/lib/shipit/octokit_check_runs.rb b/lib/shipit/octokit_check_runs.rb index 09d75a016..af7ae34cc 100644 --- a/lib/shipit/octokit_check_runs.rb +++ b/lib/shipit/octokit_check_runs.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module OctokitCheckRuns def check_runs(repo, sha, options = {}) paginate("#{Octokit::Repository.path(repo)}/commits/#{sha}/check-runs", options.reverse_merge( diff --git a/lib/shipit/octokit_iterator.rb b/lib/shipit/octokit_iterator.rb index 3a113cb1b..9d594f71e 100644 --- a/lib/shipit/octokit_iterator.rb +++ b/lib/shipit/octokit_iterator.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class OctokitIterator include Enumerable @@ -20,6 +21,7 @@ def each(&block) response.data.each(&block) return unless response.rels[:next] + response = response.rels[:next].get end end diff --git a/lib/shipit/paginator.rb b/lib/shipit/paginator.rb index 6016e04f1..d044f3494 100644 --- a/lib/shipit/paginator.rb +++ b/lib/shipit/paginator.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class Paginator def initialize(resources, controller, order: { id: :desc }, max_page_size: 100, default_page_size: 30) diff --git a/lib/shipit/rollback_commands.rb b/lib/shipit/rollback_commands.rb index a3effab84..7369f1c44 100644 --- a/lib/shipit/rollback_commands.rb +++ b/lib/shipit/rollback_commands.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class RollbackCommands < DeployCommands def steps diff --git a/lib/shipit/same_site_cookie_middleware.rb b/lib/shipit/same_site_cookie_middleware.rb index 99212ebcc..44f66eba2 100644 --- a/lib/shipit/same_site_cookie_middleware.rb +++ b/lib/shipit/same_site_cookie_middleware.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class SameSiteCookieMiddleware COOKIE_SEPARATOR = "\n" @@ -11,7 +12,7 @@ def call(env) status, headers, body = @app.call(env) if headers && headers['Set-Cookie'] && - Rack::Request.new(env).ssl? + Rack::Request.new(env).ssl? set_cookies = headers['Set-Cookie'].split(COOKIE_SEPARATOR).compact set_cookies.map! do |cookie| diff --git a/lib/shipit/simple_message_verifier.rb b/lib/shipit/simple_message_verifier.rb index 15a2079b3..c82a0f63d 100644 --- a/lib/shipit/simple_message_verifier.rb +++ b/lib/shipit/simple_message_verifier.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit class SimpleMessageVerifier < ActiveSupport::MessageVerifier def initialize(secret, **options) diff --git a/lib/shipit/stack_commands.rb b/lib/shipit/stack_commands.rb index ecc3daf21..d69ca3153 100644 --- a/lib/shipit/stack_commands.rb +++ b/lib/shipit/stack_commands.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -# rubocop:disable Lint/MissingSuper + require 'pathname' require 'fileutils' @@ -76,9 +76,13 @@ def with_temporary_working_directory(commit: nil) Dir.mktmpdir do |dir| git( - 'clone', @stack.git_path, @stack.repo_name, - '--recursive', '--origin', 'cache', - chdir: dir + 'clone', + @stack.git_path, + @stack.repo_name, + '--recursive', + '--origin', + 'cache', + chdir: dir, ).run! git_dir = File.join(dir, @stack.repo_name) @@ -88,7 +92,7 @@ def with_temporary_working_directory(commit: nil) 'checkout', '--quiet', commit.sha, - chdir: git_dir + chdir: git_dir, ).run! if commit yield Pathname.new(git_dir) end @@ -111,7 +115,8 @@ def git_clone(url, path, branch: 'main', **kwargs) end def modern_git_args - return [] unless git_version >= Gem::Version.new('1.7.10') + return [] if git_version < Gem::Version.new('1.7.10') + %w(--single-branch) end diff --git a/lib/shipit/stat.rb b/lib/shipit/stat.rb index 03dc16302..c9b8b90fd 100644 --- a/lib/shipit/stat.rb +++ b/lib/shipit/stat.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit module Stat extend self diff --git a/lib/shipit/task_commands.rb b/lib/shipit/task_commands.rb index 275d14ba7..af0353ba9 100644 --- a/lib/shipit/task_commands.rb +++ b/lib/shipit/task_commands.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -# rubocop:disable Lint/MissingSuper + module Shipit class TaskCommands < Commands delegate :fetch_commit, :fetch, :fetched?, to: :stack_commands @@ -53,7 +53,7 @@ def checkout(commit) 'checkout', '--quiet', commit.sha, - chdir: @task.working_directory + chdir: @task.working_directory, ) end @@ -63,10 +63,11 @@ def clone 'clone', '--quiet', '--local', - '--origin', 'cache', + '--origin', + 'cache', @stack.git_path, @task.working_directory, - chdir: @stack.deploys_path + chdir: @stack.deploys_path, ), git('remote', 'add', 'origin', @stack.repo_git_url, chdir: @task.working_directory), ] diff --git a/lib/shipit/version.rb b/lib/shipit/version.rb index 5e104fc24..2af77e869 100644 --- a/lib/shipit/version.rb +++ b/lib/shipit/version.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Shipit VERSION = '0.38.0' end diff --git a/lib/tasks/cron.rake b/lib/tasks/cron.rake index 038fc2647..99364bbb3 100644 --- a/lib/tasks/cron.rake +++ b/lib/tasks/cron.rake @@ -1,4 +1,5 @@ # frozen_string_literal: true + namespace :cron do desc "Updates deployed revisions" task minutely: :environment do diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index f02e1a4d3..45cfa6e4d 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -1,4 +1,5 @@ # frozen_string_literal: true + namespace :dev do desc "Appends chunks to the last deploy, or specify with DEPLOY=id" task stream: :environment do diff --git a/lib/tasks/shipit.rake b/lib/tasks/shipit.rake index 672e3452b..7d6f94dcd 100644 --- a/lib/tasks/shipit.rake +++ b/lib/tasks/shipit.rake @@ -1,4 +1,5 @@ # frozen_string_literal: true + namespace :shipit do desc "Deploy from a running instance. " task deploy: :environment do diff --git a/lib/tasks/teams.rake b/lib/tasks/teams.rake index 885ad0748..fc767c660 100644 --- a/lib/tasks/teams.rake +++ b/lib/tasks/teams.rake @@ -1,4 +1,5 @@ # frozen_string_literal: true + namespace :teams do desc "Import the members of each team configured through the github.oauth.teams config" task fetch: :environment do diff --git a/shipit-engine.gemspec b/shipit-engine.gemspec index 99ae08cea..0d4a93230 100644 --- a/shipit-engine.gemspec +++ b/shipit-engine.gemspec @@ -1,4 +1,5 @@ # frozen_string_literal: true + $LOAD_PATH.push(File.expand_path('../lib', __FILE__)) # Maintain your gem's version: @@ -15,7 +16,6 @@ Gem::Specification.new do |s| s.license = "MIT" s.files = Dir["{app,config,db,lib,vendor}/**/*", "LICENSE", "Rakefile", "README.md"] - s.test_files = Dir["test/**/*"] - Dir["test/dummy/tmp/**/*"] - Dir["test/dummy/log/**/*"] s.add_dependency('active_model_serializers', '~> 0.9.3') s.add_dependency('ansi_stream', '~> 0.0.6') @@ -29,21 +29,21 @@ Gem::Specification.new do |s| s.add_dependency('lodash-rails', '~> 4.17') s.add_dependency('octokit', '~> 4.20') s.add_dependency('omniauth-github', '~> 1.4') + s.add_dependency('paquito') s.add_dependency('pubsubstub', '~> 0.2.0') s.add_dependency('rails', '~> 7.1.1') - s.add_dependency('rails-timeago', '~> 2.13.0') s.add_dependency('rails_autolink', '~> 1.1.6') + s.add_dependency('rails-timeago', '~> 2.13.0') s.add_dependency('rake') s.add_dependency('redis-objects', '~> 1.5') s.add_dependency('responders', '~> 3.0') s.add_dependency('safe_yaml', '~> 1.0.4') s.add_dependency('sass-rails', '>= 5.0') s.add_dependency('securecompare', '~> 1.0.0') - s.add_dependency('sprockets-rails', '>= 2.3.2') s.add_dependency('sprockets', '< 4') + s.add_dependency('sprockets-rails', '>= 2.3.2') s.add_dependency('state_machines-activerecord', '~> 0.8.0') s.add_dependency('validate_url', '~> 1.0.0') - s.add_dependency('paquito') s.metadata['allowed_push_host'] = 'https://rubygems.org' end diff --git a/test/controllers/api/base_controller_test.rb b/test/controllers/api/base_controller_test.rb index 348514a46..09099e474 100644 --- a/test/controllers/api/base_controller_test.rb +++ b/test/controllers/api/base_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/api/ccmenu_controller_test.rb b/test/controllers/api/ccmenu_controller_test.rb index ba3dbdf2a..32c66144a 100644 --- a/test/controllers/api/ccmenu_controller_test.rb +++ b/test/controllers/api/ccmenu_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/api/commits_controller_test.rb b/test/controllers/api/commits_controller_test.rb index 793216eae..727b8227d 100644 --- a/test/controllers/api/commits_controller_test.rb +++ b/test/controllers/api/commits_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/api/deploys_controller_test.rb b/test/controllers/api/deploys_controller_test.rb index 7a044b8ff..dca47e2e4 100644 --- a/test/controllers/api/deploys_controller_test.rb +++ b/test/controllers/api/deploys_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/api/hooks_controller_test.rb b/test/controllers/api/hooks_controller_test.rb index a577f6a05..b9702720d 100644 --- a/test/controllers/api/hooks_controller_test.rb +++ b/test/controllers/api/hooks_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/api/locks_controller_test.rb b/test/controllers/api/locks_controller_test.rb index faf47aeb1..f5375cdfb 100644 --- a/test/controllers/api/locks_controller_test.rb +++ b/test/controllers/api/locks_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/api/merge_requests_controller_test.rb b/test/controllers/api/merge_requests_controller_test.rb index 7ed252cdd..561b89b82 100644 --- a/test/controllers/api/merge_requests_controller_test.rb +++ b/test/controllers/api/merge_requests_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/api/outputs_controller_test.rb b/test/controllers/api/outputs_controller_test.rb index a2c158e93..4510e989e 100644 --- a/test/controllers/api/outputs_controller_test.rb +++ b/test/controllers/api/outputs_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/api/release_statuses_controller_test.rb b/test/controllers/api/release_statuses_controller_test.rb index 7af530290..71a2c6e11 100644 --- a/test/controllers/api/release_statuses_controller_test.rb +++ b/test/controllers/api/release_statuses_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/api/rollback_controller_test.rb b/test/controllers/api/rollback_controller_test.rb index 0f9af7be8..2f5bcbe9f 100644 --- a/test/controllers/api/rollback_controller_test.rb +++ b/test/controllers/api/rollback_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/api/stacks_controller_test.rb b/test/controllers/api/stacks_controller_test.rb index 0586d221a..321b2f806 100644 --- a/test/controllers/api/stacks_controller_test.rb +++ b/test/controllers/api/stacks_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/api/tasks_controller_test.rb b/test/controllers/api/tasks_controller_test.rb index 4649e413d..92d1791cf 100644 --- a/test/controllers/api/tasks_controller_test.rb +++ b/test/controllers/api/tasks_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/ccmenu_controller_test.rb b/test/controllers/ccmenu_controller_test.rb index b04df76d5..4bcf8e9bf 100644 --- a/test/controllers/ccmenu_controller_test.rb +++ b/test/controllers/ccmenu_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'uri' require 'test_helper' diff --git a/test/controllers/commit_checks_controller_test.rb b/test/controllers/commit_checks_controller_test.rb index 41e7ad7ad..4131e01ed 100644 --- a/test/controllers/commit_checks_controller_test.rb +++ b/test/controllers/commit_checks_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/commits_controller_test.rb b/test/controllers/commits_controller_test.rb index 07548d139..12b6fc537 100644 --- a/test/controllers/commits_controller_test.rb +++ b/test/controllers/commits_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/deploys_controller_test.rb b/test/controllers/deploys_controller_test.rb index f8f1152c3..a51c47554 100644 --- a/test/controllers/deploys_controller_test.rb +++ b/test/controllers/deploys_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/github_authentication_controller_test.rb b/test/controllers/github_authentication_controller_test.rb index ed61f5720..6a3fb5e49 100644 --- a/test/controllers/github_authentication_controller_test.rb +++ b/test/controllers/github_authentication_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/merge_requests_controller_test.rb b/test/controllers/merge_requests_controller_test.rb index 27ff3f631..a71872ff0 100644 --- a/test/controllers/merge_requests_controller_test.rb +++ b/test/controllers/merge_requests_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/merge_status_controller_test.rb b/test/controllers/merge_status_controller_test.rb index 77e58ba1e..464b5ffbf 100644 --- a/test/controllers/merge_status_controller_test.rb +++ b/test/controllers/merge_status_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/release_statuses_controller_test.rb b/test/controllers/release_statuses_controller_test.rb index edba4e268..68f49682a 100644 --- a/test/controllers/release_statuses_controller_test.rb +++ b/test/controllers/release_statuses_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/repositories_controller_test.rb b/test/controllers/repositories_controller_test.rb index 2f3b6bd3f..64f34ed80 100644 --- a/test/controllers/repositories_controller_test.rb +++ b/test/controllers/repositories_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/rollbacks_controller_test.rb b/test/controllers/rollbacks_controller_test.rb index 5629026f9..a700953ea 100644 --- a/test/controllers/rollbacks_controller_test.rb +++ b/test/controllers/rollbacks_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/stacks_controller_test.rb b/test/controllers/stacks_controller_test.rb index 2a7c2fd15..f145b014b 100644 --- a/test/controllers/stacks_controller_test.rb +++ b/test/controllers/stacks_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/status_controller_test.rb b/test/controllers/status_controller_test.rb index 4af5be052..3e7dfa59d 100644 --- a/test/controllers/status_controller_test.rb +++ b/test/controllers/status_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/tasks_controller_test.rb b/test/controllers/tasks_controller_test.rb index ff5fc08c2..d2c55030d 100644 --- a/test/controllers/tasks_controller_test.rb +++ b/test/controllers/tasks_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/controllers/webhooks_controller_test.rb b/test/controllers/webhooks_controller_test.rb index b0c5eda0a..b811b45e1 100644 --- a/test/controllers/webhooks_controller_test.rb +++ b/test/controllers/webhooks_controller_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/helpers/api_helper.rb b/test/helpers/api_helper.rb index 45665a007..3d34ea0ba 100644 --- a/test/helpers/api_helper.rb +++ b/test/helpers/api_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module ApiHelper private diff --git a/test/helpers/fixture_aliases_helper.rb b/test/helpers/fixture_aliases_helper.rb index a66171f66..83c69a505 100644 --- a/test/helpers/fixture_aliases_helper.rb +++ b/test/helpers/fixture_aliases_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module FixtureAliasesHelper def shipit_deploys(*args) shipit_tasks(*args) diff --git a/test/helpers/hooks_helper.rb b/test/helpers/hooks_helper.rb index 50a05f631..5f15d6764 100644 --- a/test/helpers/hooks_helper.rb +++ b/test/helpers/hooks_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module HooksHelper def expect_hook(event, stack = nil, payload = nil) spy_on_hook diff --git a/test/helpers/json_helper.rb b/test/helpers/json_helper.rb index 3751e5ea0..f49173379 100644 --- a/test/helpers/json_helper.rb +++ b/test/helpers/json_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module JSONHelper UNDEFINED = Object.new.freeze private_constant :UNDEFINED diff --git a/test/helpers/links_helper.rb b/test/helpers/links_helper.rb index 387811d2c..e185a89dd 100644 --- a/test/helpers/links_helper.rb +++ b/test/helpers/links_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module LinksHelper LINKS_PATTERN = /\<(.*?)\>; rel="(\w+)"/ diff --git a/test/helpers/payloads_helper.rb b/test/helpers/payloads_helper.rb index 3c00231f8..0d5c2dc39 100644 --- a/test/helpers/payloads_helper.rb +++ b/test/helpers/payloads_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module PayloadsHelper def payload(name) Shipit::Engine.root.join('test/fixtures/payloads', "#{name}.json").read diff --git a/test/helpers/queries_helper.rb b/test/helpers/queries_helper.rb index 29b1e0633..bf0c41fb4 100644 --- a/test/helpers/queries_helper.rb +++ b/test/helpers/queries_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module QueriesHelper def assert_no_queries(ignored_sql = nil, &block) assert_queries(0, ignored_sql, &block) @@ -52,6 +53,7 @@ def call(_name, _start, _finish, _message_id, values) # FIXME: this seems bad. we should probably have a better way to indicate # the query was cached return if values[:name] == 'CACHE' || ignore.any? { |x| x =~ sql } + log << sql end end diff --git a/test/jobs/cache_deploy_spec_job_test.rb b/test/jobs/cache_deploy_spec_job_test.rb index e16b14968..6a3f9f69e 100644 --- a/test/jobs/cache_deploy_spec_job_test.rb +++ b/test/jobs/cache_deploy_spec_job_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/jobs/chunk_rollup_job_test.rb b/test/jobs/chunk_rollup_job_test.rb index 475df86dd..f4d341a5c 100644 --- a/test/jobs/chunk_rollup_job_test.rb +++ b/test/jobs/chunk_rollup_job_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/jobs/deliver_hook_job_test.rb b/test/jobs/deliver_hook_job_test.rb index c896857af..159bd7d89 100644 --- a/test/jobs/deliver_hook_job_test.rb +++ b/test/jobs/deliver_hook_job_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/jobs/destroy_repository_job_test.rb b/test/jobs/destroy_repository_job_test.rb index 0f1e185e6..af4f40ac7 100644 --- a/test/jobs/destroy_repository_job_test.rb +++ b/test/jobs/destroy_repository_job_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/jobs/destroy_stack_job_test.rb b/test/jobs/destroy_stack_job_test.rb index 48e817f75..fba26e994 100644 --- a/test/jobs/destroy_stack_job_test.rb +++ b/test/jobs/destroy_stack_job_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/jobs/emit_event_job_test.rb b/test/jobs/emit_event_job_test.rb index 7d657ff6a..8d97476bb 100644 --- a/test/jobs/emit_event_job_test.rb +++ b/test/jobs/emit_event_job_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/jobs/fetch_commit_stats_job_test.rb b/test/jobs/fetch_commit_stats_job_test.rb index 16970d10b..2658bd09f 100644 --- a/test/jobs/fetch_commit_stats_job_test.rb +++ b/test/jobs/fetch_commit_stats_job_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/jobs/fetch_deployed_revision_job_test.rb b/test/jobs/fetch_deployed_revision_job_test.rb index b5f59b88b..e521109e3 100644 --- a/test/jobs/fetch_deployed_revision_job_test.rb +++ b/test/jobs/fetch_deployed_revision_job_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/jobs/github_sync_job_test.rb b/test/jobs/github_sync_job_test.rb index bac17f3ba..dbd6ca32f 100644 --- a/test/jobs/github_sync_job_test.rb +++ b/test/jobs/github_sync_job_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/jobs/mark_deploy_healthy_job_test.rb b/test/jobs/mark_deploy_healthy_job_test.rb index a37c7699c..87ead1eaa 100644 --- a/test/jobs/mark_deploy_healthy_job_test.rb +++ b/test/jobs/mark_deploy_healthy_job_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/jobs/perform_task_job_test.rb b/test/jobs/perform_task_job_test.rb index fc3f00413..f74871b61 100644 --- a/test/jobs/perform_task_job_test.rb +++ b/test/jobs/perform_task_job_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/jobs/process_merge_requests_job_test.rb b/test/jobs/process_merge_requests_job_test.rb index 72a81933b..9bc82d2ec 100644 --- a/test/jobs/process_merge_requests_job_test.rb +++ b/test/jobs/process_merge_requests_job_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/jobs/purge_old_deliveries_job_test.rb b/test/jobs/purge_old_deliveries_job_test.rb index 744676735..31189ceaa 100644 --- a/test/jobs/purge_old_deliveries_job_test.rb +++ b/test/jobs/purge_old_deliveries_job_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/jobs/reap_dead_tasks_job_test.rb b/test/jobs/reap_dead_tasks_job_test.rb index 321b2ad27..8e672dd55 100644 --- a/test/jobs/reap_dead_tasks_job_test.rb +++ b/test/jobs/reap_dead_tasks_job_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/jobs/refresh_github_user_job_test.rb b/test/jobs/refresh_github_user_job_test.rb index 29003674a..582769240 100644 --- a/test/jobs/refresh_github_user_job_test.rb +++ b/test/jobs/refresh_github_user_job_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/jobs/refresh_status_job_test.rb b/test/jobs/refresh_status_job_test.rb index d60e477f8..c289bc66b 100644 --- a/test/jobs/refresh_status_job_test.rb +++ b/test/jobs/refresh_status_job_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/jobs/unique_job_test.rb b/test/jobs/unique_job_test.rb index 2d47048a9..9b0083d45 100644 --- a/test/jobs/unique_job_test.rb +++ b/test/jobs/unique_job_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/jobs/update_github_last_deployed_ref_job_test.rb b/test/jobs/update_github_last_deployed_ref_job_test.rb index f42306b1e..b576f6fe1 100644 --- a/test/jobs/update_github_last_deployed_ref_job_test.rb +++ b/test/jobs/update_github_last_deployed_ref_job_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/middleware/same_site_cookie_middleware_test.rb b/test/middleware/same_site_cookie_middleware_test.rb index 6e9f552f7..47e1d5c85 100644 --- a/test/middleware/same_site_cookie_middleware_test.rb +++ b/test/middleware/same_site_cookie_middleware_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/models/api_client_test.rb b/test/models/api_client_test.rb index 49b2b92e7..db84218a1 100644 --- a/test/models/api_client_test.rb +++ b/test/models/api_client_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/models/commit_checks_test.rb b/test/models/commit_checks_test.rb index 35f5b2482..02ef4ec58 100644 --- a/test/models/commit_checks_test.rb +++ b/test/models/commit_checks_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' require 'tmpdir' diff --git a/test/models/commit_deployment_status_test.rb b/test/models/commit_deployment_status_test.rb index 8bcbc5ab7..7321d13a9 100644 --- a/test/models/commit_deployment_status_test.rb +++ b/test/models/commit_deployment_status_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/models/commit_deployment_test.rb b/test/models/commit_deployment_test.rb index 8446a038a..ecac094fa 100644 --- a/test/models/commit_deployment_test.rb +++ b/test/models/commit_deployment_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/models/commits_test.rb b/test/models/commits_test.rb index 0965167e5..35bfbc146 100644 --- a/test/models/commits_test.rb +++ b/test/models/commits_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit @@ -472,10 +473,12 @@ class CommitsTest < ActiveSupport::TestCase commit = shipit_commits(:second) assert_predicate commit.status, :group? assert_equal 3, commit.status.size - commit.stack.update!(cached_deploy_spec: DeploySpec.new('ci' => { 'hide' => [ - 'Travis CI', - 'metrics/coveralls', - ] })) + commit.stack.update!(cached_deploy_spec: DeploySpec.new('ci' => { + 'hide' => [ + 'Travis CI', + 'metrics/coveralls', + ], + })) commit.reload refute_predicate commit.status, :group? end diff --git a/test/models/delivery_test.rb b/test/models/delivery_test.rb index 14d431511..a8172b4c7 100644 --- a/test/models/delivery_test.rb +++ b/test/models/delivery_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/models/deploy_spec_test.rb b/test/models/deploy_spec_test.rb index 6343629af..c636d1138 100644 --- a/test/models/deploy_spec_test.rb +++ b/test/models/deploy_spec_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit @@ -392,11 +393,13 @@ class DeploySpecTest < ActiveSupport::TestCase end test "#deploy_variables returns an array of VariableDefinition instances" do - @spec.stubs(:load_config).returns('deploy' => { 'variables' => [{ - 'name' => 'SAFETY_DISABLED', - 'title' => 'Set to 1 to do dangerous things', - 'default' => 0, - }] }) + @spec.stubs(:load_config).returns('deploy' => { + 'variables' => [{ + 'name' => 'SAFETY_DISABLED', + 'title' => 'Set to 1 to do dangerous things', + 'default' => 0, + }], + }) assert_equal 1, @spec.deploy_variables.size variable_definition = @spec.deploy_variables.first @@ -495,22 +498,24 @@ def discover_task_definitions test "task definitions returns an array of VariableDefinition instances" do @spec.expects(:load_config).returns('tasks' => - { 'restart' => - { - 'variables' => [ - { - 'name' => 'SAFETY_DISABLED', - 'title' => 'Set to 1 to do dangerous things', - 'default' => 0, - }, - { - 'name' => 'FOO', - 'title' => 'Set to 0 to foo', - 'default' => 1, - }, - ], - 'steps' => %w(foo), - } }) + { + 'restart' => + { + 'variables' => [ + { + 'name' => 'SAFETY_DISABLED', + 'title' => 'Set to 1 to do dangerous things', + 'default' => 0, + }, + { + 'name' => 'FOO', + 'title' => 'Set to 0 to foo', + 'default' => 1, + }, + ], + 'steps' => %w(foo), + }, + }) assert_equal 2, @spec.task_definitions.first.variables.size variable_definition = @spec.task_definitions.first.variables.first @@ -531,14 +536,17 @@ def discover_task_definitions end test "#review_monitoring returns an array of hashes" do - @spec.expects(:load_config).returns('review' => { 'monitoring' => [ - { 'image' => 'http://example.com/foo.png', 'width' => 200, 'height' => 400 }, - { 'iframe' => 'http://example.com/', 'width' => 200, 'height' => 400 }, - ] }) + @spec.expects(:load_config).returns('review' => { + 'monitoring' => [ + { 'image' => 'http://example.com/foo.png', 'width' => 200, 'height' => 400 }, + { 'iframe' => 'http://example.com/', 'width' => 200, 'height' => 400 }, + ], + }) assert_equal [ { 'image' => 'http://example.com/foo.png', 'width' => 200, 'height' => 400 }, { 'iframe' => 'http://example.com/', 'width' => 200, 'height' => 400 }, - ], @spec.review_monitoring + ], + @spec.review_monitoring end test "#review_monitoring returns an empty array if the section is missing" do diff --git a/test/models/deploy_stats_test.rb b/test/models/deploy_stats_test.rb index c91012b14..572a8fddd 100644 --- a/test/models/deploy_stats_test.rb +++ b/test/models/deploy_stats_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/models/deploys_test.rb b/test/models/deploys_test.rb index 51e120cf6..5778b0aa8 100644 --- a/test/models/deploys_test.rb +++ b/test/models/deploys_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/models/duration_test.rb b/test/models/duration_test.rb index 0b00ba915..55b514ef3 100644 --- a/test/models/duration_test.rb +++ b/test/models/duration_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/models/github_hook_test.rb b/test/models/github_hook_test.rb index 458369d61..ece7d7db1 100644 --- a/test/models/github_hook_test.rb +++ b/test/models/github_hook_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/models/hook_test.rb b/test/models/hook_test.rb index bb3851313..c5f5c7035 100644 --- a/test/models/hook_test.rb +++ b/test/models/hook_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/models/membership_test.rb b/test/models/membership_test.rb index 13f2fbb76..4970b6ab4 100644 --- a/test/models/membership_test.rb +++ b/test/models/membership_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/models/merge_request_test.rb b/test/models/merge_request_test.rb index 249d6a5c6..16f8f020c 100644 --- a/test/models/merge_request_test.rb +++ b/test/models/merge_request_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit @@ -137,7 +138,7 @@ class MergeRequestTest < ActiveSupport::TestCase html_url: 'http://example.com', completed_at: Time.now, started_at: 1.minute.ago, - )] + )], )) merge_request.refresh! diff --git a/test/models/release_statuses_test.rb b/test/models/release_statuses_test.rb index 5687564ba..6b5c29a3a 100644 --- a/test/models/release_statuses_test.rb +++ b/test/models/release_statuses_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/models/rollbacks_test.rb b/test/models/rollbacks_test.rb index 9c5431d6b..36eb6ec09 100644 --- a/test/models/rollbacks_test.rb +++ b/test/models/rollbacks_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/models/shipit/check_run_test.rb b/test/models/shipit/check_run_test.rb index 7aa55a8f1..6aa0aad8f 100644 --- a/test/models/shipit/check_run_test.rb +++ b/test/models/shipit/check_run_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit @@ -14,14 +15,14 @@ class CheckRunTest < ActiveSupport::TestCase assert_difference -> { @commit.check_runs.count }, +1 do @commit.check_runs.create_or_update_from_github!( @stack.id, - github_check_run(conclusion: nil, completed_at: '2021-04-29T18:05:12Z') + github_check_run(conclusion: nil, completed_at: '2021-04-29T18:05:12Z'), ) end assert_no_enqueued_jobs(only: RefreshCheckRunsJob) do @commit.check_runs.create_or_update_from_github!( @stack.id, - github_check_run(conclusion: 'success', completed_at: completed_at + 1.minute) + github_check_run(conclusion: 'success', completed_at: completed_at + 1.minute), ) end @@ -33,14 +34,14 @@ class CheckRunTest < ActiveSupport::TestCase assert_difference -> { @commit.check_runs.count }, +1 do @commit.check_runs.create_or_update_from_github!( @stack.id, - github_check_run(conclusion: 'success', completed_at: completed_at) + github_check_run(conclusion: 'success', completed_at: completed_at), ) end assert_enqueued_with(job: RefreshCheckRunsJob) do @commit.check_runs.create_or_update_from_github!( @stack.id, - github_check_run(conclusion: nil, completed_at: completed_at) + github_check_run(conclusion: nil, completed_at: completed_at), ) end @@ -77,7 +78,7 @@ class CheckRunTest < ActiveSupport::TestCase assert_difference -> { @commit.check_runs.count }, +1 do @commit.check_runs.create_or_update_from_github!( @stack.id, - github_check_run(conclusion: 'success', completed_at: completed_at) + github_check_run(conclusion: 'success', completed_at: completed_at), ) end @@ -109,7 +110,7 @@ class CheckRunTest < ActiveSupport::TestCase assert_difference -> { @commit.check_runs.count }, +1 do @commit.check_runs.create_or_update_from_github!( @stack.id, - github_check_run(conclusion: 'success', completed_at: completed_at) + github_check_run(conclusion: 'success', completed_at: completed_at), ) end @@ -119,7 +120,7 @@ class CheckRunTest < ActiveSupport::TestCase assert_no_enqueued_jobs(only: RefreshCheckRunsJob) do @commit.check_runs.create_or_update_from_github!( @stack.id, - github_check_run(conclusion: nil, completed_at: completed_at - 1.minute) + github_check_run(conclusion: nil, completed_at: completed_at - 1.minute), ) end end @@ -130,7 +131,7 @@ class CheckRunTest < ActiveSupport::TestCase assert_enqueued_with(job: RefreshCheckRunsJob, args: [stack_id: @stack.id]) do @commit.check_runs.create_or_update_from_github!( @stack.id, - github_check_run(conclusion: nil, completed_at: nil, started_at: nil) + github_check_run(conclusion: nil, completed_at: nil, started_at: nil), ) end end diff --git a/test/models/shipit/deploy_spec/file_system_test.rb b/test/models/shipit/deploy_spec/file_system_test.rb index e65480592..7be1de684 100644 --- a/test/models/shipit/deploy_spec/file_system_test.rb +++ b/test/models/shipit/deploy_spec/file_system_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' require 'tmpdir' diff --git a/test/models/shipit/provisioning_handler/base_test.rb b/test/models/shipit/provisioning_handler/base_test.rb index ed15fe95a..a9a29e5d1 100644 --- a/test/models/shipit/provisioning_handler/base_test.rb +++ b/test/models/shipit/provisioning_handler/base_test.rb @@ -8,14 +8,14 @@ class BaseTest < ActiveSupport::TestCase test "provides a default #up handler" do assert( handler.respond_to?(:up), - "expected #{handler.class.name} to provide a default #up handler" + "expected #{handler.class.name} to provide a default #up handler", ) end test "provides a default #down handler" do assert( handler.respond_to?(:down), - "expected #{handler.class.name} to provide a default #down handler" + "expected #{handler.class.name} to provide a default #down handler", ) end diff --git a/test/models/shipit/provisioning_handler_test.rb b/test/models/shipit/provisioning_handler_test.rb index 7b8fd959a..860639db6 100644 --- a/test/models/shipit/provisioning_handler_test.rb +++ b/test/models/shipit/provisioning_handler_test.rb @@ -25,7 +25,7 @@ class StackProvisioningHandlerTest < ActiveSupport::TestCase assert_equal( Shipit::ProvisioningHandler::UnregisteredProvisioningHandler, - Shipit::ProvisioningHandler.fetch(unregistered_handler) + Shipit::ProvisioningHandler.fetch(unregistered_handler), ) end @@ -40,7 +40,7 @@ class StackProvisioningHandlerTest < ActiveSupport::TestCase test "handlers are called during provisioning" do stack = shipit_stacks(:review_stack) stack.update( - provision_status: :deprovisioned + provision_status: :deprovisioned, ) handler = Shipit::ProvisioningHandler.default @@ -52,7 +52,7 @@ class StackProvisioningHandlerTest < ActiveSupport::TestCase test "handlers are called during deprovisioning" do stack = shipit_stacks(:review_stack) stack.update( - provision_status: :provisioned + provision_status: :provisioned, ) handler = Shipit::ProvisioningHandler.default diff --git a/test/models/shipit/pull_request_test.rb b/test/models/shipit/pull_request_test.rb index 344d50bcf..2dd63f586 100644 --- a/test/models/shipit/pull_request_test.rb +++ b/test/models/shipit/pull_request_test.rb @@ -30,7 +30,7 @@ class PullRequestTest < ActiveSupport::TestCase name: "deploy", }, ], - } + }, ) stack = shipit_stacks(:review_stack) pull_request = stack.pull_request diff --git a/test/models/shipit/repository_test.rb b/test/models/shipit/repository_test.rb index b71f21384..5c7dbdbb3 100644 --- a/test/models/shipit/repository_test.rb +++ b/test/models/shipit/repository_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/models/shipit/stack_test.rb b/test/models/shipit/stack_test.rb index a65e82efe..d116d32a9 100644 --- a/test/models/shipit/stack_test.rb +++ b/test/models/shipit/stack_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' require 'securerandom' @@ -13,7 +14,7 @@ def setup test "branch defaults to default branch name" do @stack.branch = "" Shipit.github.api.expects(:repo).with("shopify/shipit-engine").returns( - Struct.new(:default_branch).new('something') + Struct.new(:default_branch).new('something'), ) assert @stack.save assert_equal 'something', @stack.branch diff --git a/test/models/shipit/webhooks/handlers/pull_request/closed_handler_test.rb b/test/models/shipit/webhooks/handlers/pull_request/closed_handler_test.rb index bd4cf745f..9018aaef8 100644 --- a/test/models/shipit/webhooks/handlers/pull_request/closed_handler_test.rb +++ b/test/models/shipit/webhooks/handlers/pull_request/closed_handler_test.rb @@ -41,7 +41,7 @@ class ClosedHandlerTest < ActiveSupport::TestCase repository = shipit_repositories(:shipit) configure_provisioning_behavior( repository: repository, - behavior: :allow_all + behavior: :allow_all, ) Shipit::Webhooks::Handlers::PullRequest::ClosedHandler.new(payload_parsed(:pull_request_closed)).process @@ -55,7 +55,7 @@ class ClosedHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :allow_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_closed) payload["pull_request"]["labels"] << { "name" => "pull-requests-label" } @@ -71,7 +71,7 @@ class ClosedHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :allow_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_closed) payload["pull_request"]["labels"] = [] @@ -87,7 +87,7 @@ class ClosedHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :prevent_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_closed) payload["pull_request"]["labels"] = [] @@ -103,7 +103,7 @@ class ClosedHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :prevent_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_closed) payload["pull_request"]["labels"] << { "name" => "pull-requests-label" } @@ -181,8 +181,8 @@ def complete_active_tasks(stack) additions: 1, deletions: 1, }, - } - ) + }, + ), ) end end diff --git a/test/models/shipit/webhooks/handlers/pull_request/label_capturing_handler_test.rb b/test/models/shipit/webhooks/handlers/pull_request/label_capturing_handler_test.rb index 77b91d459..fe38cef47 100644 --- a/test/models/shipit/webhooks/handlers/pull_request/label_capturing_handler_test.rb +++ b/test/models/shipit/webhooks/handlers/pull_request/label_capturing_handler_test.rb @@ -198,8 +198,8 @@ def environment_for(payload) additions: 1, deletions: 1, }, - } - ) + }, + ), ) end end diff --git a/test/models/shipit/webhooks/handlers/pull_request/labeled_handler_test.rb b/test/models/shipit/webhooks/handlers/pull_request/labeled_handler_test.rb index b8cc48641..ea25cfbcb 100644 --- a/test/models/shipit/webhooks/handlers/pull_request/labeled_handler_test.rb +++ b/test/models/shipit/webhooks/handlers/pull_request/labeled_handler_test.rb @@ -29,7 +29,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase repository: repository, provisioning_enabled: false, behavior: :allow_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) assert_no_difference -> { Shipit::Stack.count } do @@ -41,7 +41,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase repository = shipit_repositories(:shipit) configure_provisioning_behavior( repository: repository, - behavior: :allow_all + behavior: :allow_all, ) assert_no_difference -> { Shipit::Stack.count } do @@ -55,7 +55,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :allow_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_labeled) payload["pull_request"]["labels"] << { "name" => "pull-requests-label" } @@ -71,7 +71,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :allow_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_labeled) payload["pull_request"]["labels"] = [{ "name" => "pull-requests-label" }] @@ -93,7 +93,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :allow_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_labeled) payload["pull_request"]["labels"] = [] @@ -109,7 +109,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :allow_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_labeled) payload["pull_request"]["labels"] = [] @@ -124,7 +124,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :allow_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_labeled) payload["pull_request"]["labels"] = [] @@ -140,7 +140,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :prevent_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) LabeledHandler.new(payload_parsed(:pull_request_labeled)).process @@ -154,7 +154,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :prevent_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) LabeledHandler.new(payload_parsed(:pull_request_labeled)).process @@ -167,7 +167,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :prevent_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) assert_no_difference -> { Shipit::Stack.count } do @@ -181,7 +181,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :prevent_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_labeled) payload["pull_request"]["labels"] = [] @@ -197,7 +197,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :prevent_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_labeled) payload["pull_request"]["labels"] = [] @@ -218,7 +218,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :prevent_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_labeled) payload["pull_request"]["labels"] = [] @@ -234,7 +234,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :allow_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_labeled) payload["pull_request"]["labels"] << { "name" => "pull-requests-label" } @@ -321,8 +321,8 @@ def assert_pending_provision(stack) additions: 1, deletions: 1, }, - } - ) + }, + ), ) end end diff --git a/test/models/shipit/webhooks/handlers/pull_request/opened_handler_test.rb b/test/models/shipit/webhooks/handlers/pull_request/opened_handler_test.rb index 2bcd3a75e..f6675eee3 100644 --- a/test/models/shipit/webhooks/handlers/pull_request/opened_handler_test.rb +++ b/test/models/shipit/webhooks/handlers/pull_request/opened_handler_test.rb @@ -48,7 +48,7 @@ class OpenedHandlerTest < ActiveSupport::TestCase login: "some-new-user-login", email: "somenewuser@login.com", avatar_url: "https://avatars.githubusercontent.com/u/42?v=3", - url: "https://api.github.com/user/some-new-user-login" + url: "https://api.github.com/user/some-new-user-login", ) Shipit.github.api.expects(:user).with("some-new-user-login") .returns(github_user) @@ -98,7 +98,7 @@ class OpenedHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, provisioning_enabled: false, - behavior: :allow_all + behavior: :allow_all, ) assert_no_difference -> { Shipit::Stack.count } do @@ -118,7 +118,7 @@ class OpenedHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :allow_all, - label: "pull-requests-label" + label: "pull-requests-label", ) assert_difference -> { Shipit::Stack.count } do @@ -131,7 +131,7 @@ class OpenedHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :allow_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_opened) payload["pull_request"]["labels"] << { "name" => "pull-requests-label" } @@ -146,7 +146,7 @@ class OpenedHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :allow_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_opened) payload["pull_request"]["labels"] = [] @@ -161,7 +161,7 @@ class OpenedHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :prevent_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_opened) payload["pull_request"]["labels"] = [] @@ -176,7 +176,7 @@ class OpenedHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :prevent_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_opened) payload["pull_request"]["labels"] << { "name" => "pull-requests-label" } @@ -227,8 +227,8 @@ def assert_pending_provision(stack) additions: 1, deletions: 1, }, - } - ) + }, + ), ) end end diff --git a/test/models/shipit/webhooks/handlers/pull_request/reopened_handler_test.rb b/test/models/shipit/webhooks/handlers/pull_request/reopened_handler_test.rb index 886e263dc..98a601b8b 100644 --- a/test/models/shipit/webhooks/handlers/pull_request/reopened_handler_test.rb +++ b/test/models/shipit/webhooks/handlers/pull_request/reopened_handler_test.rb @@ -48,7 +48,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase repository = shipit_repositories(:shipit) configure_provisioning_behavior( repository: repository, - behavior: :allow_all + behavior: :allow_all, ) Shipit::Webhooks::Handlers::PullRequest::ReopenedHandler.new(payload_parsed(:pull_request_reopened)).process @@ -61,7 +61,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase repository = shipit_repositories(:shipit) configure_provisioning_behavior( repository: repository, - behavior: :allow_all + behavior: :allow_all, ) payload = payload_parsed(:pull_request_reopened) @@ -80,7 +80,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase repository = shipit_repositories(:shipit) configure_provisioning_behavior( repository: repository, - behavior: :allow_all + behavior: :allow_all, ) payload = payload_parsed(:pull_request_reopened) @@ -95,7 +95,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :allow_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_reopened) payload["pull_request"]["labels"] << { "name" => "pull-requests-label" } @@ -111,7 +111,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :allow_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_reopened) payload["pull_request"]["labels"] << { "name" => "pull-requests-label" } @@ -133,7 +133,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :allow_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_reopened) payload["pull_request"]["labels"] = [] @@ -149,7 +149,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :prevent_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_reopened) payload["pull_request"]["labels"] = [] @@ -165,7 +165,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :prevent_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_reopened) payload["pull_request"]["labels"] = [] @@ -187,7 +187,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :prevent_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_reopened) payload["pull_request"]["labels"] << { "name" => "pull-requests-label" } @@ -271,8 +271,8 @@ def assert_pending_provision(stack) additions: 1, deletions: 1, }, - } - ) + }, + ), ) end end diff --git a/test/models/shipit/webhooks/handlers/pull_request/review_stack_adapter_test.rb b/test/models/shipit/webhooks/handlers/pull_request/review_stack_adapter_test.rb index 41a58d823..f8abb1f5a 100644 --- a/test/models/shipit/webhooks/handlers/pull_request/review_stack_adapter_test.rb +++ b/test/models/shipit/webhooks/handlers/pull_request/review_stack_adapter_test.rb @@ -11,7 +11,7 @@ class ReviewStackAdapterTest < ActiveSupport::TestCase stack = create_stack review_stack = Shipit::Webhooks::Handlers::PullRequest::ReviewStackAdapter.new( params_for(stack), - scope: stack.repository.stacks + scope: stack.repository.stacks, ) Shipit::ReviewStack.any_instance.expects(:unarchive!).never Shipit::ReviewStackProvisioningQueue.expects(:add).never @@ -23,7 +23,7 @@ class ReviewStackAdapterTest < ActiveSupport::TestCase stack = create_archived_stack review_stack = Shipit::Webhooks::Handlers::PullRequest::ReviewStackAdapter.new( params_for(stack), - scope: stack.repository.stacks + scope: stack.repository.stacks, ) assert_enqueued_with(job: GithubSyncJob, args: [stack_id: stack.id]) do @@ -35,7 +35,7 @@ class ReviewStackAdapterTest < ActiveSupport::TestCase stack = create_archived_stack review_stack = Shipit::Webhooks::Handlers::PullRequest::ReviewStackAdapter.new( params_for(stack), - scope: stack.repository.stacks + scope: stack.repository.stacks, ) assert_changes -> { stack.reload.awaiting_provision }, from: false, to: true do @@ -47,7 +47,7 @@ class ReviewStackAdapterTest < ActiveSupport::TestCase stack = create_archived_stack review_stack = Shipit::Webhooks::Handlers::PullRequest::ReviewStackAdapter.new( params_for(stack), - scope: stack.repository.stacks + scope: stack.repository.stacks, ) Shipit::Stack.any_instance.expects(:archive!).never @@ -59,7 +59,7 @@ class ReviewStackAdapterTest < ActiveSupport::TestCase stack.enqueue_for_provisioning review_stack = Shipit::Webhooks::Handlers::PullRequest::ReviewStackAdapter.new( params_for(stack), - scope: stack.repository.stacks + scope: stack.repository.stacks, ) assert_changes -> { stack.reload.awaiting_provision }, from: true, to: false do @@ -73,7 +73,7 @@ def params_for(stack) repository: { "full_name" => stack.github_repo_name, }, - sender: { login: shipit_users(:walrus).login } + sender: { login: shipit_users(:walrus).login }, ) end diff --git a/test/models/shipit/webhooks/handlers/pull_request/unlabeled_handler_test.rb b/test/models/shipit/webhooks/handlers/pull_request/unlabeled_handler_test.rb index 68afe00c9..489c5504a 100644 --- a/test/models/shipit/webhooks/handlers/pull_request/unlabeled_handler_test.rb +++ b/test/models/shipit/webhooks/handlers/pull_request/unlabeled_handler_test.rb @@ -27,7 +27,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase repository: repository, provisioning_enabled: false, behavior: :allow_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) assert_no_difference -> { Shipit::Stack.count } do @@ -47,7 +47,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :allow_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) UnlabeledHandler.new(payload_parsed(:pull_request_unlabeled)).process @@ -61,7 +61,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :allow_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) UnlabeledHandler.new(payload_parsed(:pull_request_unlabeled)).process @@ -74,7 +74,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :allow_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) assert_no_difference -> { Shipit::Stack.count } do @@ -88,7 +88,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :allow_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_unlabeled) payload["pull_request"]["labels"] << { "name" => "pull-requests-label" } @@ -104,7 +104,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :allow_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_unlabeled) payload["pull_request"]["labels"] << { "name" => "pull-requests-label" } @@ -126,7 +126,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :prevent_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_unlabeled) payload["pull_request"]["labels"] << { "name" => "pull-requests-label" } @@ -142,7 +142,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :prevent_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_unlabeled) payload["pull_request"]["labels"] << { "name" => "pull-requests-label" } @@ -157,7 +157,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :prevent_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_unlabeled) payload["pull_request"]["labels"] << { "name" => "pull-requests-label" } @@ -173,7 +173,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :prevent_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_unlabeled) payload["pull_request"]["labels"] = [] @@ -189,7 +189,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :prevent_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_unlabeled) payload["pull_request"]["labels"] = [] @@ -210,7 +210,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :prevent_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_unlabeled) payload["pull_request"]["labels"] = [] @@ -226,7 +226,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase configure_provisioning_behavior( repository: repository, behavior: :allow_with_label, - label: "pull-requests-label" + label: "pull-requests-label", ) payload = payload_parsed(:pull_request_unlabeled) payload["pull_request"]["labels"] << { "name" => "pull-requests-label" } @@ -313,8 +313,8 @@ def assert_pending_provision(stack) additions: 1, deletions: 1, }, - } - ) + }, + ), ) end end diff --git a/test/models/shipit/webhooks/handlers_test.rb b/test/models/shipit/webhooks/handlers_test.rb index a95f8b0ca..e278347b4 100644 --- a/test/models/shipit/webhooks/handlers_test.rb +++ b/test/models/shipit/webhooks/handlers_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/models/status/group_test.rb b/test/models/status/group_test.rb index ea14c0afa..572f112e5 100644 --- a/test/models/status/group_test.rb +++ b/test/models/status/group_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/models/status/missing_test.rb b/test/models/status/missing_test.rb index 0213feb25..6de6b1c69 100644 --- a/test/models/status/missing_test.rb +++ b/test/models/status/missing_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/models/status_test.rb b/test/models/status_test.rb index 14417124b..4c103561b 100644 --- a/test/models/status_test.rb +++ b/test/models/status_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/models/task_definitions_test.rb b/test/models/task_definitions_test.rb index 6582e3430..204d46bb3 100644 --- a/test/models/task_definitions_test.rb +++ b/test/models/task_definitions_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/models/tasks_test.rb b/test/models/tasks_test.rb index 011c20c55..47f10ae89 100644 --- a/test/models/tasks_test.rb +++ b/test/models/tasks_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/models/team_test.rb b/test/models/team_test.rb index 584b96232..14cda9a3b 100644 --- a/test/models/team_test.rb +++ b/test/models/team_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/models/undeployed_commits_test.rb b/test/models/undeployed_commits_test.rb index 9b87148e7..ddfd6a305 100644 --- a/test/models/undeployed_commits_test.rb +++ b/test/models/undeployed_commits_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/models/users_test.rb b/test/models/users_test.rb index 1cbe57296..7932d9ee4 100644 --- a/test/models/users_test.rb +++ b/test/models/users_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/test_helper.rb b/test/test_helper.rb index a5ba4068e..d2c38cf9c 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + ENV["RAILS_ENV"] ||= "test" if Warning.respond_to?(:[]=) @@ -67,6 +68,7 @@ class TestCase Shipit.redis.flushdb Shipit.instance_variable_names.each do |name| next if %w(@mocha @redis).include?(name) + Shipit.remove_instance_variable(name) end end diff --git a/test/unit/anonymous_user_serializer_test.rb b/test/unit/anonymous_user_serializer_test.rb index 54dde2e49..855e1c62a 100644 --- a/test/unit/anonymous_user_serializer_test.rb +++ b/test/unit/anonymous_user_serializer_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/unit/command_test.rb b/test/unit/command_test.rb index 05aca8d80..27cf061fb 100644 --- a/test/unit/command_test.rb +++ b/test/unit/command_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/unit/commands_test.rb b/test/unit/commands_test.rb index b102b108e..212784d8e 100644 --- a/test/unit/commands_test.rb +++ b/test/unit/commands_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/unit/commit_serializer_test.rb b/test/unit/commit_serializer_test.rb index 5010c9ed6..171c8e958 100644 --- a/test/unit/commit_serializer_test.rb +++ b/test/unit/commit_serializer_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/unit/csv_serializer_test.rb b/test/unit/csv_serializer_test.rb index ba36ef9a2..2fcb3b069 100644 --- a/test/unit/csv_serializer_test.rb +++ b/test/unit/csv_serializer_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/unit/deploy_commands_test.rb b/test/unit/deploy_commands_test.rb index 9b446565c..fbcb35515 100644 --- a/test/unit/deploy_commands_test.rb +++ b/test/unit/deploy_commands_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit @@ -207,9 +208,14 @@ def setup commands = @commands.clone assert_equal 2, commands.size clone_args = [ - 'git', 'clone', '--quiet', - '--local', '--origin', 'cache', - @stack.git_path.to_s, @deploy.working_directory, + 'git', + 'clone', + '--quiet', + '--local', + '--origin', + 'cache', + @stack.git_path.to_s, + @deploy.working_directory, ] assert_equal clone_args, commands.first.args assert_equal ['git', 'remote', 'add', 'origin', @stack.repo_git_url.to_s], commands.second.args @@ -223,7 +229,11 @@ def setup test "#checkout checks out the deployed commit" do command = @commands.checkout(@deploy.until_commit) checkout_args = [ - 'git', '-c', 'advice.detachedHead=false', 'checkout', '--quiet', + 'git', + '-c', + 'advice.detachedHead=false', + 'checkout', + '--quiet', @deploy.until_commit.sha, ] assert_equal checkout_args, command.args diff --git a/test/unit/deploy_serializer_test.rb b/test/unit/deploy_serializer_test.rb index 470e4e0d9..810024a84 100644 --- a/test/unit/deploy_serializer_test.rb +++ b/test/unit/deploy_serializer_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/unit/environment_variables_test.rb b/test/unit/environment_variables_test.rb index 3d028e55d..e343db0ab 100644 --- a/test/unit/environment_variables_test.rb +++ b/test/unit/environment_variables_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/unit/github_app_test.rb b/test/unit/github_app_test.rb index 5beda14d5..bda7e3fab 100644 --- a/test/unit/github_app_test.rb +++ b/test/unit/github_app_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/unit/github_apps_test.rb b/test/unit/github_apps_test.rb index 4e5465337..67a8290db 100644 --- a/test/unit/github_apps_test.rb +++ b/test/unit/github_apps_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/unit/github_url_helper_test.rb b/test/unit/github_url_helper_test.rb index 0b5cd18e7..c60ec099c 100644 --- a/test/unit/github_url_helper_test.rb +++ b/test/unit/github_url_helper_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/unit/rollback_commands_test.rb b/test/unit/rollback_commands_test.rb index bf503171f..8b04c17a7 100644 --- a/test/unit/rollback_commands_test.rb +++ b/test/unit/rollback_commands_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/unit/shipit_deployment_checks_test.rb b/test/unit/shipit_deployment_checks_test.rb index 8413cf9d4..e8d23471c 100644 --- a/test/unit/shipit_deployment_checks_test.rb +++ b/test/unit/shipit_deployment_checks_test.rb @@ -25,7 +25,7 @@ def self.call(_stack) assert_equal( deployment_checks, - Shipit.deployment_checks + Shipit.deployment_checks, ) end diff --git a/test/unit/shipit_helper_test.rb b/test/unit/shipit_helper_test.rb index 46668d1fb..a24ced0f6 100644 --- a/test/unit/shipit_helper_test.rb +++ b/test/unit/shipit_helper_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/unit/shipit_task_execution_strategy_test.rb b/test/unit/shipit_task_execution_strategy_test.rb index 70366758d..5ddd67862 100644 --- a/test/unit/shipit_task_execution_strategy_test.rb +++ b/test/unit/shipit_task_execution_strategy_test.rb @@ -29,7 +29,7 @@ def execute; end assert_equal( strategy, - Shipit.task_execution_strategy + Shipit.task_execution_strategy, ) end diff --git a/test/unit/shipit_test.rb b/test/unit/shipit_test.rb index 01f01303c..9d75fd237 100644 --- a/test/unit/shipit_test.rb +++ b/test/unit/shipit_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/unit/user_serializer_test.rb b/test/unit/user_serializer_test.rb index 85ae23614..2136aedc8 100644 --- a/test/unit/user_serializer_test.rb +++ b/test/unit/user_serializer_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit diff --git a/test/unit/variable_definition_test.rb b/test/unit/variable_definition_test.rb index 29fec6916..25f76ed89 100644 --- a/test/unit/variable_definition_test.rb +++ b/test/unit/variable_definition_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' module Shipit From 2344ade19ab75ee999725713dfce60bf579f836f Mon Sep 17 00:00:00 2001 From: Kartiki Sharma Date: Fri, 19 Jan 2024 17:34:46 -0500 Subject: [PATCH 09/23] Fix Rubocop errors --- lib/shipit/stack_commands.rb | 1 + lib/shipit/task_commands.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/shipit/stack_commands.rb b/lib/shipit/stack_commands.rb index d69ca3153..88af63d68 100644 --- a/lib/shipit/stack_commands.rb +++ b/lib/shipit/stack_commands.rb @@ -6,6 +6,7 @@ module Shipit class StackCommands < Commands def initialize(stack) + super() @stack = stack end diff --git a/lib/shipit/task_commands.rb b/lib/shipit/task_commands.rb index af0353ba9..5e99a604b 100644 --- a/lib/shipit/task_commands.rb +++ b/lib/shipit/task_commands.rb @@ -5,6 +5,7 @@ class TaskCommands < Commands delegate :fetch_commit, :fetch, :fetched?, to: :stack_commands def initialize(task) + super() @task = task @stack = task.stack end From fd20acff863316e0502d160a48a38a6fc371ab5a Mon Sep 17 00:00:00 2001 From: Kartiki Sharma Date: Fri, 19 Jan 2024 17:49:32 -0500 Subject: [PATCH 10/23] Remove use of def self --- app/models/shipit/commit.rb | 130 +++++++++--------- app/models/shipit/deploy.rb | 32 +++-- app/models/shipit/merge_request.rb | 60 ++++---- app/models/shipit/repository.rb | 22 +-- app/models/shipit/review_stack.rb | 32 +++-- .../shipit/review_stack_provisioning_queue.rb | 18 +-- app/models/shipit/stack.rb | 56 ++++---- app/models/shipit/task.rb | 23 ++-- app/models/shipit/user.rb | 64 ++++----- .../shipit/webhooks/handlers/handler.rb | 6 +- lib/shipit/simple_message_verifier.rb | 12 +- lib/snippets/extract-gem-version | 4 +- test/models/shipit/stack_test.rb | 6 +- test/unit/shipit_deployment_checks_test.rb | 12 +- 14 files changed, 254 insertions(+), 223 deletions(-) diff --git a/app/models/shipit/commit.rb b/app/models/shipit/commit.rb index f234af3df..f8d90d936 100644 --- a/app/models/shipit/commit.rb +++ b/app/models/shipit/commit.rb @@ -65,75 +65,90 @@ def lock_author=(user) :soft_failing_statuses, to: :stack - def self.newer_than(commit) - return all unless commit + class << self + def newer_than(commit) + return all unless commit - where('id > ?', commit.try(:id) || commit) - end - - def self.older_than(commit) - return all unless commit + where('id > ?', commit.try(:id) || commit) + end - where('id < ?', commit.try(:id) || commit) - end + def older_than(commit) + return all unless commit - def self.since(commit) - return all unless commit + where('id < ?', commit.try(:id) || commit) + end - where('id >= ?', commit.try(:id) || commit) - end + def since(commit) + return all unless commit - def self.until(commit) - return all unless commit + where('id >= ?', commit.try(:id) || commit) + end - where('id <= ?', commit.try(:id) || commit) - end + def until(commit) + return all unless commit - def self.successful - preload(:statuses).to_a.select(&:success?) - end + where('id <= ?', commit.try(:id) || commit) + end - def self.detach! - Commit.where(id: ids).update_all(detached: true) - end + def successful + preload(:statuses).to_a.select(&:success?) + end - def self.by_sha(sha) - if sha.to_s.size < 6 - raise AmbiguousRevision, "Short SHA1 #{sha} is ambiguous (too short)" + def detach! + Commit.where(id: ids).update_all(detached: true) end - commits = where('sha like ?', "#{sha}%").take(2) - raise AmbiguousRevision, "Short SHA1 #{sha} is ambiguous (matches multiple commits)" if commits.size > 1 + def by_sha(sha) + if sha.to_s.size < 6 + raise AmbiguousRevision, "Short SHA1 #{sha} is ambiguous (too short)" + end - commits.first - end + commits = where('sha like ?', "#{sha}%").take(2) + raise AmbiguousRevision, "Short SHA1 #{sha} is ambiguous (matches multiple commits)" if commits.size > 1 - def self.by_sha!(sha) - by_sha(sha) || raise(ActiveRecord::RecordNotFound, "Couldn't find commit with sha #{sha}") - end + commits.first + end - def self.from_github(commit) - author = User.find_or_create_author_from_github_commit(commit) - author ||= Anonymous.new - committer = User.find_or_create_committer_from_github_commit(commit) - committer ||= Anonymous.new + def by_sha!(sha) + by_sha(sha) || raise(ActiveRecord::RecordNotFound, "Couldn't find commit with sha #{sha}") + end - record = new( - sha: commit.sha, - message: commit.commit.message, - author: author, - committer: committer, - committed_at: commit.commit.committer.date, - authored_at: commit.commit.author.date, - additions: commit.stats&.additions, - deletions: commit.stats&.deletions, - ) + def from_github(commit) + author = User.find_or_create_author_from_github_commit(commit) + author ||= Anonymous.new + committer = User.find_or_create_committer_from_github_commit(commit) + committer ||= Anonymous.new + + record = new( + sha: commit.sha, + message: commit.commit.message, + author: author, + committer: committer, + committed_at: commit.commit.committer.date, + authored_at: commit.commit.author.date, + additions: commit.stats&.additions, + deletions: commit.stats&.deletions, + ) + + if record.pull_request? + record.pull_request_head_sha = commit.parents.last.sha + end - if record.pull_request? - record.pull_request_head_sha = commit.parents.last.sha + record end - record + def create_from_github!(commit, extra_attributes = {}) + record = from_github(commit) + record.update!(extra_attributes) + record + end + + def lock_all(user) + update_all( + locked: true, + lock_author_id: user.id, + ) + end end def message=(message) @@ -149,12 +164,6 @@ def reload(*) super end - def self.create_from_github!(commit, extra_attributes = {}) - record = from_github(commit) - record.update!(extra_attributes) - record - end - def statuses_and_check_runs statuses + check_runs end @@ -342,13 +351,6 @@ def lock(user) ) end - def self.lock_all(user) - update_all( - locked: true, - lock_author_id: user.id, - ) - end - def unlock update!(locked: false, lock_author: nil) end diff --git a/app/models/shipit/deploy.rb b/app/models/shipit/deploy.rb index 536a4ad4f..5b20bb026 100644 --- a/app/models/shipit/deploy.rb +++ b/app/models/shipit/deploy.rb @@ -63,28 +63,30 @@ def append_status(task_status) delegate :broadcast_update, :filter_deploy_envs, to: :stack - def self.newer_than(deploy) - return all unless deploy + class << self + def newer_than(deploy) + return all unless deploy - where('id > ?', deploy.try(:id) || deploy) - end + where('id > ?', deploy.try(:id) || deploy) + end - def self.older_than(deploy) - return all unless deploy + def older_than(deploy) + return all unless deploy - where('id < ?', deploy.try(:id) || deploy) - end + where('id < ?', deploy.try(:id) || deploy) + end - def self.since(deploy) - return all unless deploy + def since(deploy) + return all unless deploy - where('id >= ?', deploy.try(:id) || deploy) - end + where('id >= ?', deploy.try(:id) || deploy) + end - def self.until(deploy) - return all unless deploy + def until(deploy) + return all unless deploy - where('id <= ?', deploy.try(:id) || deploy) + where('id <= ?', deploy.try(:id) || deploy) + end end def build_rollback(user = nil, env: nil, force: false) diff --git a/app/models/shipit/merge_request.rb b/app/models/shipit/merge_request.rb index c5ce9a6a4..fa9208dc5 100644 --- a/app/models/shipit/merge_request.rb +++ b/app/models/shipit/merge_request.rb @@ -106,40 +106,42 @@ def required_statuses end end - def self.schedule_merges - Shipit::Stack.where(merge_queue_enabled: true).find_each(&:schedule_merges) - end + class << self + def schedule_merges + Shipit::Stack.where(merge_queue_enabled: true).find_each(&:schedule_merges) + end - def self.extract_number(stack, number_or_url) - org = stack.repository.owner - case number_or_url - when /\A#?(\d+)\z/ - $1.to_i - when %r{\Ahttps://#{Regexp.escape(Shipit.github(organization: org).domain)}/([^/]+)/([^/]+)/pull/(\d+)} - return unless $1.downcase == stack.repo_owner.downcase - return unless $2.downcase == stack.repo_name.downcase + def extract_number(stack, number_or_url) + org = stack.repository.owner + case number_or_url + when /\A#?(\d+)\z/ + $1.to_i + when %r{\Ahttps://#{Regexp.escape(Shipit.github(organization: org).domain)}/([^/]+)/([^/]+)/pull/(\d+)} + return unless $1.downcase == stack.repo_owner.downcase + return unless $2.downcase == stack.repo_name.downcase - $3.to_i + $3.to_i + end end - end - def self.request_merge!(stack, number, user) - now = Time.now.utc - merge_request = begin - create_with( - merge_requested_at: now, - merge_requested_by: user.presence, - ).find_or_create_by!( - stack: stack, - number: number, - ) - rescue ActiveRecord::RecordNotUnique - retry + def request_merge!(stack, number, user) + now = Time.now.utc + merge_request = begin + create_with( + merge_requested_at: now, + merge_requested_by: user.presence, + ).find_or_create_by!( + stack: stack, + number: number, + ) + rescue ActiveRecord::RecordNotUnique + retry + end + merge_request.update!(merge_requested_by: user.presence) + merge_request.retry! if merge_request.rejected? || merge_request.canceled? || merge_request.revalidating? + merge_request.schedule_refresh! + merge_request end - merge_request.update!(merge_requested_by: user.presence) - merge_request.retry! if merge_request.rejected? || merge_request.canceled? || merge_request.revalidating? - merge_request.schedule_refresh! - merge_request end def reject!(reason) diff --git a/app/models/shipit/repository.rb b/app/models/shipit/repository.rb index a763a60d2..d28ad02b8 100644 --- a/app/models/shipit/repository.rb +++ b/app/models/shipit/repository.rb @@ -53,9 +53,11 @@ class Repository < ApplicationRecord PROVISIONING_BEHAVIORS = %w(allow_all allow_with_label prevent_with_label).freeze enum provisioning_behavior: PROVISIONING_BEHAVIORS.zip(PROVISIONING_BEHAVIORS).to_h, _prefix: :provisioning_behavior - def self.from_github_repo_name(github_repo_name) - repo_owner, repo_name = github_repo_name.downcase.split('/') - find_by(owner: repo_owner, name: repo_name) + class << self + def from_github_repo_name(github_repo_name) + repo_owner, repo_name = github_repo_name.downcase.split('/') + find_by(owner: repo_owner, name: repo_name) + end end def name=(n) @@ -90,12 +92,14 @@ def to_param github_repo_name end - def self.from_param!(param) - repo_owner, repo_name = param.split('/') - where( - owner: repo_owner.downcase, - name: repo_name.downcase, - ).first! + class << self + def from_param!(param) + repo_owner, repo_name = param.split('/') + where( + owner: repo_owner.downcase, + name: repo_name.downcase, + ).first! + end end protected diff --git a/app/models/shipit/review_stack.rb b/app/models/shipit/review_stack.rb index 9383268ef..bcb9f7f37 100644 --- a/app/models/shipit/review_stack.rb +++ b/app/models/shipit/review_stack.rb @@ -2,23 +2,25 @@ module Shipit class ReviewStack < Shipit::Stack - def self.clear_stale_caches - Shipit::ReviewStack.where( - "archived_since > :earliest AND archived_since < :latest", - earliest: 1.day.ago, - latest: 1.hour.ago, - ).find_each do |review_stack| - review_stack.clear_local_files + class << self + def clear_stale_caches + Shipit::ReviewStack.where( + "archived_since > :earliest AND archived_since < :latest", + earliest: 1.day.ago, + latest: 1.hour.ago, + ).find_each do |review_stack| + review_stack.clear_local_files + end end - end - def self.delete_old_deployment_directories - Shipit::Deploy.not_active.where( - "created_at > :earliest AND updated_at < :latest", - earliest: 1.day.ago, - latest: 1.hour.ago, - ).find_each do |deploy| - Shipit::Commands.for(deploy).clear_working_directory + def delete_old_deployment_directories + Shipit::Deploy.not_active.where( + "created_at > :earliest AND updated_at < :latest", + earliest: 1.day.ago, + latest: 1.hour.ago, + ).find_each do |deploy| + Shipit::Commands.for(deploy).clear_working_directory + end end end diff --git a/app/models/shipit/review_stack_provisioning_queue.rb b/app/models/shipit/review_stack_provisioning_queue.rb index 1f63a900f..2a1da7bf7 100644 --- a/app/models/shipit/review_stack_provisioning_queue.rb +++ b/app/models/shipit/review_stack_provisioning_queue.rb @@ -2,16 +2,18 @@ module Shipit class ReviewStackProvisioningQueue - def self.work - new.work - end + class << self + def work + new.work + end - def self.add(stack) - stack.enqueue_for_provisioning - end + def add(stack) + stack.enqueue_for_provisioning + end - def self.queued_stacks - new.queued_stacks + def queued_stacks + new.queued_stacks + end end def work diff --git a/app/models/shipit/stack.rb b/app/models/shipit/stack.rb index 7ef2bf4b1..75a33ab09 100644 --- a/app/models/shipit/stack.rb +++ b/app/models/shipit/stack.rb @@ -116,13 +116,36 @@ def sync_github_if_necessary allow_nil: true, ) - def self.refresh_deployed_revisions - find_each.select(&:supports_fetch_deployed_revision?).each(&:async_refresh_deployed_revision) - end + class << self + def refresh_deployed_revisions + find_each.select(&:supports_fetch_deployed_revision?).each(&:async_refresh_deployed_revision) + end - def self.schedule_continuous_delivery - where(continuous_deployment: true).find_each do |stack| - ContinuousDeliveryJob.perform_later(stack) + def schedule_continuous_delivery + where(continuous_deployment: true).find_each do |stack| + ContinuousDeliveryJob.perform_later(stack) + end + end + + def run_deploy_in_foreground(stack:, revision:) + stack = Shipit::Stack.from_param!(stack) + until_commit = stack.commits.where(sha: revision).limit(1).first + env = stack.cached_deploy_spec.default_deploy_env + current_user = Shipit::CommandLineUser.new + + stack.trigger_deploy(until_commit, current_user, env: env, force: true, run_now: true) + end + + def from_param!(param) + repo_owner, repo_name, environment = param.split('/') + includes(:repository) + .where( + repositories: { + owner: repo_owner.downcase, + name: repo_name.downcase, + }, + environment: environment, + ).first! end end @@ -500,27 +523,6 @@ def to_param [repo_owner, repo_name, environment].join('/') end - def self.run_deploy_in_foreground(stack:, revision:) - stack = Shipit::Stack.from_param!(stack) - until_commit = stack.commits.where(sha: revision).limit(1).first - env = stack.cached_deploy_spec.default_deploy_env - current_user = Shipit::CommandLineUser.new - - stack.trigger_deploy(until_commit, current_user, env: env, force: true, run_now: true) - end - - def self.from_param!(param) - repo_owner, repo_name, environment = param.split('/') - includes(:repository) - .where( - repositories: { - owner: repo_owner.downcase, - name: repo_name.downcase, - }, - environment: environment, - ).first! - end - delegate :plugins, :task_definitions, :hidden_statuses, diff --git a/app/models/shipit/task.rb b/app/models/shipit/task.rb index e0af5e0fc..057d364f9 100644 --- a/app/models/shipit/task.rb +++ b/app/models/shipit/task.rb @@ -430,20 +430,23 @@ def includes_commit?(commit) end end - def self.recently_created_at - 5.minutes.ago + class << self + def recently_created_at + 5.minutes.ago + end + + def zombies + where(status: ZOMBIE_STATES) + .where( + "created_at <= :recently", + recently: recently_created_at, + ) + .reject(&:alive?) + end end ZOMBIE_STATES = %w(running aborting).freeze private_constant :ZOMBIE_STATES - def self.zombies - where(status: ZOMBIE_STATES) - .where( - "created_at <= :recently", - recently: recently_created_at, - ) - .reject(&:alive?) - end def retry_if_necessary return unless retries_configured? && !stack.reload.locked? diff --git a/app/models/shipit/user.rb b/app/models/shipit/user.rb index f8b4956d9..e1bd904c3 100644 --- a/app/models/shipit/user.rb +++ b/app/models/shipit/user.rb @@ -19,47 +19,49 @@ class User < Record after_find :discard_outdated_credentials! - def self.find_or_create_by_login!(login) - find_or_create_by!(login: login) do |user| - # Users are global, any app can be used - # This will not work for users that only exist in an Enterprise install - user.github_user = Shipit.github.api.user(login) + class << self + def find_or_create_by_login!(login) + find_or_create_by!(login: login) do |user| + # Users are global, any app can be used + # This will not work for users that only exist in an Enterprise install + user.github_user = Shipit.github.api.user(login) + end end - end - def self.find_or_create_committer_from_github_commit(github_commit) - find_or_create_from_github(github_commit.committer.presence || github_commit.commit.committer.presence) - end + def find_or_create_committer_from_github_commit(github_commit) + find_or_create_from_github(github_commit.committer.presence || github_commit.commit.committer.presence) + end - def self.find_or_create_author_from_github_commit(github_commit) - if (match_info = github_commit.commit.message.match(/^#{MergeRequest::MERGE_REQUEST_FIELD}: ([\w\-\.]+)$/)) - begin - return find_or_create_by_login!(match_info[1]) - rescue Octokit::NotFound - # Corner case where the merge-requested-by user cannot be found (renamed/deleted). - # In this case we carry on and search for the commit author + def find_or_create_author_from_github_commit(github_commit) + if (match_info = github_commit.commit.message.match(/^#{MergeRequest::MERGE_REQUEST_FIELD}: ([\w\-\.]+)$/)) + begin + return find_or_create_by_login!(match_info[1]) + rescue Octokit::NotFound + # Corner case where the merge-requested-by user cannot be found (renamed/deleted). + # In this case we carry on and search for the commit author + end end + find_or_create_from_github(github_commit.author.presence || github_commit.commit.author.presence) end - find_or_create_from_github(github_commit.author.presence || github_commit.commit.author.presence) - end - def self.find_or_create_from_github(github_user) - find_from_github(github_user) || create_from_github(github_user) - end + def find_or_create_from_github(github_user) + find_from_github(github_user) || create_from_github(github_user) + end - def self.find_from_github(github_user) - return unless github_user.id + def find_from_github(github_user) + return unless github_user.id - find_by(github_id: github_user.id) - end + find_by(github_id: github_user.id) + end - def self.create_from_github(github_user) - create(github_user: github_user) - end + def create_from_github(github_user) + create(github_user: github_user) + end - def self.refresh_shard(shard_index, shards_count) - where.not(login: nil).where('id % ? = ?', shards_count, shard_index).find_each do |user| - RefreshGithubUserJob.perform_later(user) + def refresh_shard(shard_index, shards_count) + where.not(login: nil).where('id % ? = ?', shards_count, shard_index).find_each do |user| + RefreshGithubUserJob.perform_later(user) + end end end diff --git a/app/models/shipit/webhooks/handlers/handler.rb b/app/models/shipit/webhooks/handlers/handler.rb index 9057b39f2..a7af85a2c 100644 --- a/app/models/shipit/webhooks/handlers/handler.rb +++ b/app/models/shipit/webhooks/handlers/handler.rb @@ -10,10 +10,10 @@ class << self def params(&block) @param_parser = ExplicitParameters::Parameters.define(&block) end - end - def self.call(params) - new(params).process + def call(params) + new(params).process + end end attr_reader :params, :payload diff --git a/lib/shipit/simple_message_verifier.rb b/lib/shipit/simple_message_verifier.rb index c82a0f63d..40a97d29b 100644 --- a/lib/shipit/simple_message_verifier.rb +++ b/lib/shipit/simple_message_verifier.rb @@ -18,12 +18,14 @@ def decode(data) end module ToS - def self.dump(object) - object.to_s - end + class << self + def dump(object) + object.to_s + end - def self.load(payload) - payload + def load(payload) + payload + end end end end diff --git a/lib/snippets/extract-gem-version b/lib/snippets/extract-gem-version index cc6997e3f..47afcbbac 100755 --- a/lib/snippets/extract-gem-version +++ b/lib/snippets/extract-gem-version @@ -13,10 +13,12 @@ end module Gem class Specification - def self.new + class << self + def new spec = FakeSpec.new yield spec print spec.version + end end end end diff --git a/test/models/shipit/stack_test.rb b/test/models/shipit/stack_test.rb index d116d32a9..746a1afe7 100644 --- a/test/models/shipit/stack_test.rb +++ b/test/models/shipit/stack_test.rb @@ -74,8 +74,10 @@ def setup mattr_accessor :hooks self.hooks = [] - def self.deliver(event, stack, payload) - hooks << [event, stack, payload] + class << self + def deliver(event, stack, payload) + hooks << [event, stack, payload] + end end end Shipit.internal_hook_receivers = [FakeReceiver] diff --git a/test/unit/shipit_deployment_checks_test.rb b/test/unit/shipit_deployment_checks_test.rb index e8d23471c..33933aede 100644 --- a/test/unit/shipit_deployment_checks_test.rb +++ b/test/unit/shipit_deployment_checks_test.rb @@ -6,8 +6,10 @@ module Shipit class ShipitDeploymentChecksTest < ActiveSupport::TestCase setup do class FakeDeploymentChecks - def self.call(_stack) - true + class << self + def call(_stack) + true + end end end end @@ -57,8 +59,10 @@ def self.call(_stack) test "prevents deployments and delays continuous delivery when checks fail" do class FakeDeploymentChecks - def self.call(_stack) - false + class << self + def call(_stack) + false + end end end From 8aaa462821603efe81c27b78963910910aea64db Mon Sep 17 00:00:00 2001 From: Kartiki Sharma Date: Mon, 22 Jan 2024 10:30:43 -0500 Subject: [PATCH 11/23] Fix more lint errors --- lib/tasks/dev.rake | 2 +- test/helpers/queries_helper.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 45cfa6e4d..0860d4308 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -4,7 +4,7 @@ namespace :dev do desc "Appends chunks to the last deploy, or specify with DEPLOY=id" task stream: :environment do require 'faker' - logger = Logger.new(STDOUT) + logger = Logger.new($stdout) deploy = Shipit::Deploy.find(ENV['DEPLOY']) if ENV['DEPLOY'] deploy ||= Deploy.last diff --git a/test/helpers/queries_helper.rb b/test/helpers/queries_helper.rb index bf0c41fb4..77249e276 100644 --- a/test/helpers/queries_helper.rb +++ b/test/helpers/queries_helper.rb @@ -37,7 +37,7 @@ class SQLCounter # FIXME: this needs to be refactored so specific database can add their own # ignored SQL. This ignored SQL is for Oracle. - ignored_sql.concat([/^select .*nextval/i, /^SAVEPOINT/, /^ROLLBACK TO/, /^\s*select .* from all_triggers/im]) + ignored_sql.push(/^select .*nextval/i, /^SAVEPOINT/, /^ROLLBACK TO/, /^\s*select .* from all_triggers/im) attr_reader :ignore attr_reader :log From e39df9b0169ddf7924e95c2cd0a692644d181363 Mon Sep 17 00:00:00 2001 From: Kartiki Sharma Date: Mon, 22 Jan 2024 10:54:52 -0500 Subject: [PATCH 12/23] Update status_test.rb --- test/models/status_test.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/models/status_test.rb b/test/models/status_test.rb index 4c103561b..56c9c5b0c 100644 --- a/test/models/status_test.rb +++ b/test/models/status_test.rb @@ -4,6 +4,9 @@ module Shipit class StatusTest < ActiveSupport::TestCase + Struct.new('GithubStatus', :state, :description, :context, :target_url, :created_at) + Struct::GithubStatus.superclass + setup do @commit = shipit_commits(:first) @stack = @commit.stack @@ -46,12 +49,8 @@ class StatusTest < ActiveSupport::TestCase private def github_status - @github_status ||= OpenStruct.new( - state: 'success', - description: 'This is a description', - context: 'default', - target_url: 'http://example.com', - created_at: 1.day.ago.to_time, + @github_status ||= Struct::GithubStatus.new( + 'success', 'This is a description', 'default', 'http://example.com', 1.day.ago.to_time ) end From 4514ce0dad596d37f570a7fc617c5eff72812591 Mon Sep 17 00:00:00 2001 From: Kartiki Sharma Date: Mon, 22 Jan 2024 11:00:11 -0500 Subject: [PATCH 13/23] Update github_apps_test.rb --- test/unit/github_apps_test.rb | 63 ++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/test/unit/github_apps_test.rb b/test/unit/github_apps_test.rb index 67a8290db..fc39bf65a 100644 --- a/test/unit/github_apps_test.rb +++ b/test/unit/github_apps_test.rb @@ -4,6 +4,9 @@ module Shipit class GitHubAppsTestOrgOne < ActiveSupport::TestCase + Struct.new('Token', :token, :expires_at) + Struct::Token.superclass + setup do @organization = "OrgOne" @github = app(@organization) @@ -82,13 +85,13 @@ class GitHubAppsTestOrgOne < ActiveSupport::TestCase installation_id: "test_installation_id", private_key: "test_private_key", } - initial_token = OpenStruct.new( - token: "some_initial_github_token", - expires_at: Time.now.utc + 60.minutes, + initial_token = Struct::Token.new( + "some_initial_github_token", + Time.now.utc + 60.minutes, ) - second_token = OpenStruct.new( - token: "some_new_github_token", - expires_at: initial_token.expires_at + 60.minutes, + second_token = Struct::Token.new( + "some_new_github_token", + initial_token.expires_at + 60.minutes, ) auth_payload = "test_auth_payload" @@ -120,13 +123,13 @@ class GitHubAppsTestOrgOne < ActiveSupport::TestCase installation_id: "test_installation_id", private_key: "test_private_key", } - initial_token = OpenStruct.new( - token: "some_initial_github_token", - expires_at: Time.now.utc + 60.minutes, + initial_token = Struct::Token.new( + "some_initial_github_token", + Time.now.utc + 60.minutes, ) - second_token = OpenStruct.new( - token: "some_new_github_token", - expires_at: initial_token.expires_at + 60.minutes, + second_token = Struct::Token.new( + "some_new_github_token", + initial_token.expires_at + 60.minutes, ) auth_payload = "test_auth_payload" @@ -168,9 +171,9 @@ class GitHubAppsTestOrgOne < ActiveSupport::TestCase initial_cached_token = Shipit::GitHubApp::Token.new("some_initial_github_token", Time.now.utc - 1.minute) initial_cached_token.instance_variable_set(:@refresh_at, nil) - second_token = OpenStruct.new( - token: "some_new_github_token", - expires_at: initial_cached_token.expires_at + 60.minutes, + second_token = Struct::Token.new( + "some_new_github_token", + initial_cached_token.expires_at + 60.minutes, ) auth_payload = "test_auth_payload" @@ -288,13 +291,13 @@ class GitHubAppsTestOrgTwo < ActiveSupport::TestCase installation_id: "test_installation_id", private_key: "test_private_key", } - initial_token = OpenStruct.new( - token: "some_initial_github_token", - expires_at: Time.now.utc + 60.minutes, + initial_token = Struct::Token.new( + "some_initial_github_token", + Time.now.utc + 60.minutes, ) - second_token = OpenStruct.new( - token: "some_new_github_token", - expires_at: initial_token.expires_at + 60.minutes, + second_token = Struct::Token.new( + "some_new_github_token", + initial_token.expires_at + 60.minutes, ) auth_payload = "test_auth_payload" @@ -326,13 +329,13 @@ class GitHubAppsTestOrgTwo < ActiveSupport::TestCase installation_id: "test_installation_id", private_key: "test_private_key", } - initial_token = OpenStruct.new( - token: "some_initial_github_token", - expires_at: Time.now.utc + 60.minutes, + initial_token = Struct::Token.new( + "some_initial_github_token", + Time.now.utc + 60.minutes, ) - second_token = OpenStruct.new( - token: "some_new_github_token", - expires_at: initial_token.expires_at + 60.minutes, + second_token = Struct::Token.new( + "some_new_github_token", + initial_token.expires_at + 60.minutes, ) auth_payload = "test_auth_payload" @@ -374,9 +377,9 @@ class GitHubAppsTestOrgTwo < ActiveSupport::TestCase initial_cached_token = Shipit::GitHubApp::Token.new("some_initial_github_token", Time.now.utc - 1.minute) initial_cached_token.instance_variable_set(:@refresh_at, nil) - second_token = OpenStruct.new( - token: "some_new_github_token", - expires_at: initial_cached_token.expires_at + 60.minutes, + second_token = Struct::Token.new( + "some_new_github_token", + initial_cached_token.expires_at + 60.minutes, ) auth_payload = "test_auth_payload" From 326c90501b26e771878aae0ab480a097ec894876 Mon Sep 17 00:00:00 2001 From: Kartiki Sharma Date: Mon, 22 Jan 2024 11:01:12 -0500 Subject: [PATCH 14/23] Update github_app_test.rb --- test/unit/github_app_test.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/unit/github_app_test.rb b/test/unit/github_app_test.rb index bda7e3fab..4051ca7bb 100644 --- a/test/unit/github_app_test.rb +++ b/test/unit/github_app_test.rb @@ -4,6 +4,9 @@ module Shipit class GitHubAppTest < ActiveSupport::TestCase + Struct.new('Token', :token, :expires_at) + Struct::Token.superclass + setup do @github = app @enterprise = app(domain: 'github.example.com') @@ -81,11 +84,11 @@ class GitHubAppTest < ActiveSupport::TestCase installation_id: "test_installation_id", private_key: "test_private_key", } - initial_token = OpenStruct.new( + initial_token = Struct::Token.new( token: "some_initial_github_token", expires_at: Time.now.utc + 60.minutes, ) - second_token = OpenStruct.new( + second_token = Struct::Token.new( token: "some_new_github_token", expires_at: initial_token.expires_at + 60.minutes, ) @@ -119,11 +122,11 @@ class GitHubAppTest < ActiveSupport::TestCase installation_id: "test_installation_id", private_key: "test_private_key", } - initial_token = OpenStruct.new( + initial_token = Struct::Token.new( token: "some_initial_github_token", expires_at: Time.now.utc + 60.minutes, ) - second_token = OpenStruct.new( + second_token = Struct::Token.new( token: "some_new_github_token", expires_at: initial_token.expires_at + 60.minutes, ) @@ -167,7 +170,7 @@ class GitHubAppTest < ActiveSupport::TestCase initial_cached_token = Shipit::GitHubApp::Token.new("some_initial_github_token", Time.now.utc - 1.minute) initial_cached_token.instance_variable_set(:@refresh_at, nil) - second_token = OpenStruct.new( + second_token = Struct::Token.new( token: "some_new_github_token", expires_at: initial_cached_token.expires_at + 60.minutes, ) From 5c2eccaa9d41edb5ea3bfa44fad823f466af4c7c Mon Sep 17 00:00:00 2001 From: Kartiki Sharma Date: Mon, 22 Jan 2024 11:03:00 -0500 Subject: [PATCH 15/23] Update commits_test.rb --- test/models/commits_test.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/models/commits_test.rb b/test/models/commits_test.rb index 35bfbc146..6fe6aaffe 100644 --- a/test/models/commits_test.rb +++ b/test/models/commits_test.rb @@ -4,6 +4,9 @@ module Shipit class CommitsTest < ActiveSupport::TestCase + Struct.new('GithubStatus', :state, :description, :context, :created_at) + Struct::GithubStatus.superclass + setup do @stack = shipit_stacks(:shipit) @pr = @stack.commits.new @@ -630,7 +633,7 @@ class CommitsTest < ActiveSupport::TestCase expected_status_attributes = { state: new_state, description: initial_state, context: 'ci/travis' } add_status = lambda do attrs = expected_status_attributes.merge(created_at: 1.day.ago.to_formatted_s(:db)) - commit.create_status_from_github!(OpenStruct.new(attrs)) + commit.create_status_from_github!(Struct::GithubStatus.new(attrs)) end expect_hook_emit(commit, :commit_status, expected_status_attributes) do if should_fire @@ -650,7 +653,7 @@ class CommitsTest < ActiveSupport::TestCase refute_predicate commit, :deployed? expect_no_hook(:deployable_status) do - github_status = OpenStruct.new( + github_status = Struct::GithubStatus.new( state: 'failure', description: 'Sad', context: 'ci/hidden', @@ -667,7 +670,7 @@ class CommitsTest < ActiveSupport::TestCase refute_predicate commit, :deployed? expect_no_hook(:deployable_status) do - github_status = OpenStruct.new( + github_status = Struct::GithubStatus.new( state: 'failure', description: 'Sad', context: 'ci/ok_to_fail', @@ -682,7 +685,7 @@ class CommitsTest < ActiveSupport::TestCase assert_predicate commit, :deployed? expect_no_hook(:deployable_status) do - github_status = OpenStruct.new( + github_status = Struct::GithubStatus.new( state: 'failure', description: 'Sad', context: 'ci/travis', @@ -694,7 +697,7 @@ class CommitsTest < ActiveSupport::TestCase test "#add_status schedule a MergeMergeRequests job if the commit transition to `pending` or `success`" do commit = shipit_commits(:second) - github_status = OpenStruct.new( + github_status = Struct::GithubStatus.new( state: 'success', description: 'Cool', context: 'metrics/coveralls', From 562c805790857110d276cae03eb0481d644d0c09 Mon Sep 17 00:00:00 2001 From: Kartiki Sharma Date: Mon, 22 Jan 2024 11:08:42 -0500 Subject: [PATCH 16/23] Update update_github_last_deployed_ref_job_test.rb --- test/jobs/update_github_last_deployed_ref_job_test.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/jobs/update_github_last_deployed_ref_job_test.rb b/test/jobs/update_github_last_deployed_ref_job_test.rb index b576f6fe1..e5c92d64b 100644 --- a/test/jobs/update_github_last_deployed_ref_job_test.rb +++ b/test/jobs/update_github_last_deployed_ref_job_test.rb @@ -4,6 +4,11 @@ module Shipit class UpdateGithubLastDeployedRefJobTest < ActiveSupport::TestCase + Struct.new('ResponseInner', :sha, :type, :url) + Struct::ResponseInner.superclass + Struct.new('Response', :ref, :node_id, :url, :object) + Struct::Response.superclass + setup do @stack = shipit_stacks(:shipit) @job = UpdateGithubLastDeployedRefJob.new @@ -18,8 +23,8 @@ class UpdateGithubLastDeployedRefJobTest < ActiveSupport::TestCase ref_url = "http://api.github.test.com/shopify/shipit-engine/git/#{@expected_ref}" commit_url = "https://api.github.test.com/repos/shopify/shipit-engine/git/commits/#{@commit.sha}" - response_inner_obj = OpenStruct.new(sha: @commit.sha, type: "commit", url: commit_url) - @response = OpenStruct.new(ref: @expected_ref, node_id: "blah", url: ref_url, object: response_inner_obj) + response_inner_obj = Struct::ResponseInner.new(@commit.sha, "commit", commit_url) + @response = Struct::Response.new(@expected_ref, "blah", ref_url, response_inner_obj) end test "#perform will create a ref when one is not present" do From c62a5d97657ad659b6177aa8b14f398867302bf3 Mon Sep 17 00:00:00 2001 From: Kartiki Sharma Date: Mon, 22 Jan 2024 11:08:45 -0500 Subject: [PATCH 17/23] Update check_run_test.rb --- test/models/shipit/check_run_test.rb | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/test/models/shipit/check_run_test.rb b/test/models/shipit/check_run_test.rb index 6aa0aad8f..0ec6ecbfa 100644 --- a/test/models/shipit/check_run_test.rb +++ b/test/models/shipit/check_run_test.rb @@ -4,6 +4,11 @@ module Shipit class CheckRunTest < ActiveSupport::TestCase + Struct.new('GithubCheckRun', :id, :conclusion, :output, :name, :html_url, :details_url, :completed_at, :started_at) + Struct::GithubCheckRun.superclass + Struct.new('Output', :description) + Struct::Output.superclass + setup do @commit = shipit_commits(:first) @stack = @commit.stack @@ -155,17 +160,17 @@ class CheckRunTest < ActiveSupport::TestCase private def github_check_run(conclusion: 'success', completed_at: Time.now, started_at: Time.now - 1.minute) - OpenStruct.new( - id: 424_242, - conclusion: conclusion, - output: OpenStruct.new( + Struct::GithubCheckRun.new( + 424_242, + conclusion, + Struct::Output.new( description: 'This is a description', ), - name: 'Test Suite', - html_url: 'http://example.com/run', - details_url: 'http://example.com/details', - completed_at: completed_at, - started_at: started_at, + 'Test Suite', + 'http://example.com/run', + 'http://example.com/details', + completed_at, + started_at, ) end end From fc6da043d47fb52b7700b797449c48ab478cd3d5 Mon Sep 17 00:00:00 2001 From: Kartiki Sharma Date: Mon, 22 Jan 2024 11:10:27 -0500 Subject: [PATCH 18/23] Update review_stack_adapter_test.rb --- .../pull_request/review_stack_adapter_test.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/models/shipit/webhooks/handlers/pull_request/review_stack_adapter_test.rb b/test/models/shipit/webhooks/handlers/pull_request/review_stack_adapter_test.rb index f8abb1f5a..d667d21f7 100644 --- a/test/models/shipit/webhooks/handlers/pull_request/review_stack_adapter_test.rb +++ b/test/models/shipit/webhooks/handlers/pull_request/review_stack_adapter_test.rb @@ -7,6 +7,9 @@ module Webhooks module Handlers module PullRequest class ReviewStackAdapterTest < ActiveSupport::TestCase + Struct.new('Stack', :number, :repository, :sender) + Struct::Stack.superclass + test "unarchive! on an unarchived stack is a no-op" do stack = create_stack review_stack = Shipit::Webhooks::Handlers::PullRequest::ReviewStackAdapter.new( @@ -68,12 +71,12 @@ class ReviewStackAdapterTest < ActiveSupport::TestCase end def params_for(stack) - OpenStruct.new( - number: pr_number, - repository: { + Struct::Stack.new( + pr_number, + { "full_name" => stack.github_repo_name, }, - sender: { login: shipit_users(:walrus).login }, + { login: shipit_users(:walrus).login }, ) end From c69efd9d98ef6737de6ce3f8187cf0895d3e9f89 Mon Sep 17 00:00:00 2001 From: Kartiki Sharma Date: Mon, 22 Jan 2024 11:19:30 -0500 Subject: [PATCH 19/23] Update .rubocop.yml --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 979b3f24a..7cf32bfe4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,5 @@ AllCops: - TargetRubyVersion: 2.7 + TargetRubyVersion: 3.2 Exclude: - tmp/* - bin/* From 68990d5153f7374af11e6b9b14d472610232dcbf Mon Sep 17 00:00:00 2001 From: Kartiki Sharma Date: Mon, 22 Jan 2024 11:24:10 -0500 Subject: [PATCH 20/23] Swap to Ruby 3.1 --- .github/workflows/main.yml | 11 ++++++----- .rubocop.yml | 2 +- dev.yml | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 44b3b3d77..d23ab31e7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,10 +9,10 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Set up Ruby 3.2 + - name: Set up Ruby 3.1 uses: ruby/setup-ruby@v1 with: - ruby-version: '3.2' + ruby-version: '3.1' bundler-cache: true - name: rubocop run: | @@ -25,7 +25,7 @@ jobs: fail-fast: false matrix: ruby_version: - - '3.2' + - '3.1' services: db: @@ -68,7 +68,7 @@ jobs: fail-fast: false matrix: ruby_version: - - '3.2' + - '3.1' services: db: @@ -107,6 +107,7 @@ jobs: fail-fast: false matrix: ruby_version: + - '3.1' - '3.2' services: @@ -138,7 +139,7 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: '3.2' + ruby-version: '3.1' - name: Run setup script run: | git config --global user.email "you@example.com" diff --git a/.rubocop.yml b/.rubocop.yml index 7cf32bfe4..16564d07d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,5 @@ AllCops: - TargetRubyVersion: 3.2 + TargetRubyVersion: 3.1 Exclude: - tmp/* - bin/* diff --git a/dev.yml b/dev.yml index 71f1e355d..a255bb899 100644 --- a/dev.yml +++ b/dev.yml @@ -8,7 +8,7 @@ up: - packages: - sqlite - ruby: - version: 3.2.0 + version: 3.1.0 - isogun - bundler: without: ci From 46bf11efc5f711700d31d0cb961bd5c55d7e4bf0 Mon Sep 17 00:00:00 2001 From: Kartiki Sharma Date: Mon, 22 Jan 2024 11:28:42 -0500 Subject: [PATCH 21/23] Fix rubocop errors: autocorrect --- .../concerns/shipit/api/paginable.rb | 4 +- app/controllers/concerns/shipit/pagination.rb | 4 +- .../shipit/api/ccmenu_controller.rb | 2 +- .../shipit/api/hooks_controller.rb | 2 +- .../shipit/api/stacks_controller.rb | 2 +- .../shipit/commit_checks_controller.rb | 2 +- .../shipit/merge_status_controller.rb | 2 +- app/controllers/shipit/stacks_controller.rb | 8 +-- app/helpers/shipit/chunks_helper.rb | 2 +- app/helpers/shipit/deploys_helper.rb | 6 +- app/helpers/shipit/stacks_helper.rb | 2 +- app/jobs/shipit/github_sync_job.rb | 4 +- .../update_github_last_deployed_ref_job.rb | 4 +- app/models/shipit/check_run.rb | 4 +- app/models/shipit/commit.rb | 18 ++--- app/models/shipit/commit_checks.rb | 2 +- app/models/shipit/deploy.rb | 22 +++--- app/models/shipit/ephemeral_commit_checks.rb | 4 +- app/models/shipit/hook.rb | 2 +- app/models/shipit/merge_request.rb | 6 +- app/models/shipit/pull_request.rb | 2 +- app/models/shipit/release_status.rb | 2 +- app/models/shipit/stack.rb | 20 +++--- app/models/shipit/status.rb | 2 +- app/models/shipit/status/missing.rb | 2 +- app/models/shipit/task.rb | 6 +- app/models/shipit/task_definition.rb | 10 +-- app/models/shipit/team.rb | 8 +-- app/models/shipit/user.rb | 8 +-- .../pull_request/review_stack_adapter.rb | 4 +- .../shipit/webhooks/handlers/push_handler.rb | 2 +- lib/shipit.rb | 2 +- lib/shipit/flock.rb | 2 +- lib/shipit/github_app.rb | 4 +- lib/shipit/stack_commands.rb | 14 ++-- lib/shipit/task_commands.rb | 4 +- lib/tasks/shipit.rake | 4 +- .../controllers/api/stacks_controller_test.rb | 2 +- test/controllers/api/tasks_controller_test.rb | 6 +- test/controllers/deploys_controller_test.rb | 2 +- test/controllers/rollbacks_controller_test.rb | 2 +- test/controllers/tasks_controller_test.rb | 2 +- test/controllers/webhooks_controller_test.rb | 4 +- test/helpers/json_helper.rb | 6 +- test/jobs/chunk_rollup_job_test.rb | 4 +- test/jobs/github_sync_job_test.rb | 4 +- test/models/commits_test.rb | 2 +- test/models/delivery_test.rb | 2 +- test/models/deploys_test.rb | 72 +++++++++---------- test/models/merge_request_test.rb | 4 +- test/models/shipit/check_run_test.rb | 16 ++--- test/models/shipit/repository_test.rb | 2 +- test/models/shipit/stack_test.rb | 14 ++-- .../pull_request/closed_handler_test.rb | 10 +-- .../pull_request/labeled_handler_test.rb | 28 ++++---- .../pull_request/opened_handler_test.rb | 12 ++-- .../pull_request/reopened_handler_test.rb | 18 ++--- .../pull_request/unlabeled_handler_test.rb | 26 +++---- test/models/team_test.rb | 4 +- test/models/undeployed_commits_test.rb | 10 +-- 60 files changed, 225 insertions(+), 225 deletions(-) diff --git a/app/controllers/concerns/shipit/api/paginable.rb b/app/controllers/concerns/shipit/api/paginable.rb index 73c2d9a22..da484e29b 100644 --- a/app/controllers/concerns/shipit/api/paginable.rb +++ b/app/controllers/concerns/shipit/api/paginable.rb @@ -24,8 +24,8 @@ def render_resources(resource, *) resource, self, order: default_order, - max_page_size: max_page_size, - default_page_size: default_page_size, + max_page_size:, + default_page_size:, ) headers[LINK] = render_links(paginator.links) super(paginator.to_a) diff --git a/app/controllers/concerns/shipit/pagination.rb b/app/controllers/concerns/shipit/pagination.rb index dbce8919e..355dc53d3 100644 --- a/app/controllers/concerns/shipit/pagination.rb +++ b/app/controllers/concerns/shipit/pagination.rb @@ -21,8 +21,8 @@ def paginate(relation) relation, self, order: default_order, - max_page_size: max_page_size, - default_page_size: default_page_size, + max_page_size:, + default_page_size:, ) end end diff --git a/app/controllers/shipit/api/ccmenu_controller.rb b/app/controllers/shipit/api/ccmenu_controller.rb index 6c91596c0..b67f4b79f 100644 --- a/app/controllers/shipit/api/ccmenu_controller.rb +++ b/app/controllers/shipit/api/ccmenu_controller.rb @@ -21,7 +21,7 @@ def running? def show latest_deploy = stack.deploys_and_rollbacks.last || NoDeploy.new - render('shipit/ccmenu/project', formats: [:xml], locals: { stack: stack, deploy: latest_deploy }) + render('shipit/ccmenu/project', formats: [:xml], locals: { stack:, deploy: latest_deploy }) end private diff --git a/app/controllers/shipit/api/hooks_controller.rb b/app/controllers/shipit/api/hooks_controller.rb index 1ffd63c21..71d895e79 100644 --- a/app/controllers/shipit/api/hooks_controller.rb +++ b/app/controllers/shipit/api/hooks_controller.rb @@ -44,7 +44,7 @@ def hook end def hooks - Hook.where(stack_id: stack_id) + Hook.where(stack_id:) end def stack_id diff --git a/app/controllers/shipit/api/stacks_controller.rb b/app/controllers/shipit/api/stacks_controller.rb index eae87a8c6..fc4543a73 100644 --- a/app/controllers/shipit/api/stacks_controller.rb +++ b/app/controllers/shipit/api/stacks_controller.rb @@ -15,7 +15,7 @@ def index if params[:repo_owner] && params[:repo_name] full_repo_name = [repo_owner, repo_name].join('/') @stacks = if (repository = Repository.from_github_repo_name(full_repo_name)) - stacks.where(repository: repository) + stacks.where(repository:) else Stack.none end diff --git a/app/controllers/shipit/commit_checks_controller.rb b/app/controllers/shipit/commit_checks_controller.rb index 012193b5a..422111ef7 100644 --- a/app/controllers/shipit/commit_checks_controller.rb +++ b/app/controllers/shipit/commit_checks_controller.rb @@ -17,7 +17,7 @@ def tail url = stack_tail_commit_checks_path(stack, sha: commit.sha, since: next_offset) end - render(json: { url: url, output: output, status: checks.status }) + render(json: { url:, output:, status: checks.status }) end private diff --git a/app/controllers/shipit/merge_status_controller.rb b/app/controllers/shipit/merge_status_controller.rb index fb4a51e65..c32f6dd89 100644 --- a/app/controllers/shipit/merge_status_controller.rb +++ b/app/controllers/shipit/merge_status_controller.rb @@ -45,7 +45,7 @@ def check render(plain: stack_status, status: 503) end end - format.json { render(json: { stack_status: stack_status }) } + format.json { render(json: { stack_status: }) } end end diff --git a/app/controllers/shipit/stacks_controller.rb b/app/controllers/shipit/stacks_controller.rb index 3bfa19c4a..72cb7c5d7 100644 --- a/app/controllers/shipit/stacks_controller.rb +++ b/app/controllers/shipit/stacks_controller.rb @@ -38,7 +38,7 @@ def show scope.preload(:author, :statuses, :check_runs, :lock_author) end - next_expected_commit_to_deploy = @stack.next_expected_commit_to_deploy(commits: commits) + next_expected_commit_to_deploy = @stack.next_expected_commit_to_deploy(commits:) @active_commits = [] @undeployed_commits = [] @@ -49,11 +49,11 @@ def show @active_commits = map_to_undeployed_commit( @active_commits, - next_expected_commit_to_deploy: next_expected_commit_to_deploy, + next_expected_commit_to_deploy:, ) @undeployed_commits = map_to_undeployed_commit( @undeployed_commits, - next_expected_commit_to_deploy: next_expected_commit_to_deploy, + next_expected_commit_to_deploy:, ) end @@ -146,7 +146,7 @@ def update_archived def map_to_undeployed_commit(commits, next_expected_commit_to_deploy:) commits.map.with_index do |c, i| index = commits.size - i - 1 - UndeployedCommit.new(c, index: index, next_expected_commit_to_deploy: next_expected_commit_to_deploy) + UndeployedCommit.new(c, index:, next_expected_commit_to_deploy:) end end diff --git a/app/helpers/shipit/chunks_helper.rb b/app/helpers/shipit/chunks_helper.rb index e8b9912db..61ba3d240 100644 --- a/app/helpers/shipit/chunks_helper.rb +++ b/app/helpers/shipit/chunks_helper.rb @@ -5,7 +5,7 @@ module ChunksHelper def next_chunks_url(task, last_byte: 0) return if task.finished? - tail_stack_task_path(task.stack, task, last_byte: last_byte) + tail_stack_task_path(task.stack, task, last_byte:) end end end diff --git a/app/helpers/shipit/deploys_helper.rb b/app/helpers/shipit/deploys_helper.rb index 0dbbdedf7..c9fb6aa47 100644 --- a/app/helpers/shipit/deploys_helper.rb +++ b/app/helpers/shipit/deploys_helper.rb @@ -5,19 +5,19 @@ module DeploysHelper def render_checklist(checklist) return if checklist.blank? - render('shipit/deploys/checklist', checklist: checklist) + render('shipit/deploys/checklist', checklist:) end def render_monitoring(stack) return unless stack.monitoring? - render('shipit/deploys/monitoring', stack: stack) + render('shipit/deploys/monitoring', stack:) end def render_checks(commit) return unless commit.stack.checks? - render('shipit/commit_checks/checks', commit: commit) + render('shipit/commit_checks/checks', commit:) end def render_monitoring_panel(panel_spec) diff --git a/app/helpers/shipit/stacks_helper.rb b/app/helpers/shipit/stacks_helper.rb index 55069c8a6..6b728d663 100644 --- a/app/helpers/shipit/stacks_helper.rb +++ b/app/helpers/shipit/stacks_helper.rb @@ -34,7 +34,7 @@ def deploy_button(commit) data[:tooltip] = t('deploy_button.hint.max_commits', maximum: commit.stack.maximum_commits_per_deploy) end - link_to(t("deploy_button.caption.#{deploy_state}"), url, class: classes, data: data) + link_to(t("deploy_button.caption.#{deploy_state}"), url, class: classes, data:) end def rollback_button(deploy) diff --git a/app/jobs/shipit/github_sync_job.rb b/app/jobs/shipit/github_sync_job.rb index f4158ddcb..6dd7ecc5a 100644 --- a/app/jobs/shipit/github_sync_job.rb +++ b/app/jobs/shipit/github_sync_job.rb @@ -37,7 +37,7 @@ def append_commit(gh_commit) def fetch_missing_commits(&block) commits = [] github_api = stack&.github_api - iterator = Shipit::FirstParentCommitsIterator.new(github_api: github_api, &block) + iterator = Shipit::FirstParentCommitsIterator.new(github_api:, &block) iterator.each_with_index do |commit, index| break if index >= MAX_FETCHED_COMMITS @@ -61,7 +61,7 @@ def handle_github_errors end def lookup_commit(sha) - stack.commits.find_by(sha: sha) + stack.commits.find_by(sha:) end end end diff --git a/app/jobs/shipit/update_github_last_deployed_ref_job.rb b/app/jobs/shipit/update_github_last_deployed_ref_job.rb index ea9be27da..83ad32a5d 100644 --- a/app/jobs/shipit/update_github_last_deployed_ref_job.rb +++ b/app/jobs/shipit/update_github_last_deployed_ref_job.rb @@ -18,7 +18,7 @@ def perform(stack) full_repo_name = stack.github_repo_name - update_or_create_ref(client: client, repo_name: full_repo_name, ref: stack_ref, new_sha: stack_sha) + update_or_create_ref(client:, repo_name: full_repo_name, ref: stack_ref, new_sha: stack_sha) end private @@ -36,7 +36,7 @@ def update_or_create_ref(client:, repo_name:, ref:, new_sha:) rescue Octokit::UnprocessableEntity => e error_msg = e.message if error_msg.include?("Reference does not exist") - create_ref(client: client, repo_name: repo_name, ref: ref, sha: new_sha) + create_ref(client:, repo_name:, ref:, sha: new_sha) else raise end diff --git a/app/models/shipit/check_run.rb b/app/models/shipit/check_run.rb index d0631f3c2..b795a3398 100644 --- a/app/models/shipit/check_run.rb +++ b/app/models/shipit/check_run.rb @@ -42,7 +42,7 @@ def create_or_update_from_github!(stack_id, github_check_run) unless checkrun_date Rails.logger.warn("No valid timestamp found in checkrun data. Checkrun id: #{github_check_run.id}.") - RefreshCheckRunsJob.set(wait: CHECK_RUN_REFRESH_DELAY).perform_later(stack_id: stack_id) + RefreshCheckRunsJob.set(wait: CHECK_RUN_REFRESH_DELAY).perform_later(stack_id:) return end @@ -51,7 +51,7 @@ def create_or_update_from_github!(stack_id, github_check_run) github_id: github_check_run.id, }, attributes: { - stack_id: stack_id, + stack_id:, name: github_check_run.name, conclusion: github_check_run.conclusion, title: github_check_run.output.title.to_s.truncate(1_000), diff --git a/app/models/shipit/commit.rb b/app/models/shipit/commit.rb index f8d90d936..cadc58e9b 100644 --- a/app/models/shipit/commit.rb +++ b/app/models/shipit/commit.rb @@ -122,8 +122,8 @@ def from_github(commit) record = new( sha: commit.sha, message: commit.commit.message, - author: author, - committer: committer, + author:, + committer:, committed_at: commit.commit.committer.date, authored_at: commit.commit.author.date, additions: commit.stats&.additions, @@ -213,11 +213,11 @@ def create_release_status!(state, user: nil, target_url: nil, description: nil) @last_release_status = nil release_statuses.create!( - stack: stack, - user: user, - state: state, - target_url: target_url, - description: description, + stack:, + user:, + state:, + target_url:, + description:, ) end @@ -246,7 +246,7 @@ def blocked? end def children - self.class.where(stack_id: stack_id).newer_than(self) + self.class.where(stack_id:).newer_than(self) end def detach_children! @@ -374,7 +374,7 @@ def add_status new_status = status unless already_deployed - payload = { commit: self, stack: stack, status: new_status.state } + payload = { commit: self, stack:, status: new_status.state } if previous_status != new_status Hook.emit(:commit_status, stack, payload.merge(commit_status: new_status)) end diff --git a/app/models/shipit/commit_checks.rb b/app/models/shipit/commit_checks.rb index 7b56bc95b..d2a4fda23 100644 --- a/app/models/shipit/commit_checks.rb +++ b/app/models/shipit/commit_checks.rb @@ -23,7 +23,7 @@ def schedule initialize_redis_state end - PerformCommitChecksJob.perform_later(commit: commit) + PerformCommitChecksJob.perform_later(commit:) true end diff --git a/app/models/shipit/deploy.rb b/app/models/shipit/deploy.rb index 5b20bb026..87a508ead 100644 --- a/app/models/shipit/deploy.rb +++ b/app/models/shipit/deploy.rb @@ -13,7 +13,7 @@ class Deploy < Task after_transition to: :aborted, do: :trigger_revert_if_required after_transition any => any, do: :update_release_status after_transition any => any, do: :update_commit_deployments - after_transition any => any, do: :update_last_deploy_time + after_transition any:, do: :update_last_deploy_time end belongs_to :until_commit, class_name: 'Commit', required: true @@ -92,10 +92,10 @@ def until(deploy) def build_rollback(user = nil, env: nil, force: false) Rollback.new( user_id: user&.id, - stack_id: stack_id, + stack_id:, parent_id: id, since_commit: stack.last_deployed_commit, - until_commit: until_commit, + until_commit:, env: env&.to_h || {}, allow_concurrency: force, ignored_safeties: force, @@ -105,14 +105,14 @@ def build_rollback(user = nil, env: nil, force: false) # Rolls the stack back to this deploy def trigger_rollback(user = AnonymousUser.new, env: nil, force: false, lock: true) - rollback = build_rollback(user, env: env, force: force) + rollback = build_rollback(user, env:, force:) rollback.save! rollback.enqueue if lock lock_reason = "A rollback for #{rollback.since_commit.sha} has been triggered. " \ "Please make sure the reason for the rollback has been addressed before deploying again." - stack.update!(lock_reason: lock_reason, lock_author_id: user.id) + stack.update!(lock_reason:, lock_author_id: user.id) end rollback @@ -123,8 +123,8 @@ def trigger_revert(force: false, rollback_to: nil) previous_successful_commit = rollback_to&.until_commit || commit_to_rollback_to rollback = Rollback.create!( - user_id: user_id, - stack_id: stack_id, + user_id:, + stack_id:, parent_id: id, since_commit: until_commit, until_commit: previous_successful_commit, @@ -134,7 +134,7 @@ def trigger_revert(force: false, rollback_to: nil) rollback.enqueue lock_reason = "A rollback for #{until_commit.sha} has been triggered. " \ "Please make sure the reason for the rollback has been addressed before deploying again." - stack.update!(lock_reason: lock_reason, lock_author_id: user_id) + stack.update!(lock_reason:, lock_author_id: user_id) stack.emit_lock_hooks rollback end @@ -211,7 +211,7 @@ def append_release_status(state, description, user: self.user) state, user: user.presence, target_url: permalink, - description: description, + description:, ) status end @@ -234,7 +234,7 @@ def report_healthy!(user: self.user, description: "@#{user.login} signaled this append_release_status( 'success', description, - user: user, + user:, ) end end @@ -245,7 +245,7 @@ def report_faulty!(user: self.user, description: "@#{user.login} signaled this r append_release_status( 'failure', description, - user: user, + user:, ) end end diff --git a/app/models/shipit/ephemeral_commit_checks.rb b/app/models/shipit/ephemeral_commit_checks.rb index 38f191171..d3d253d59 100644 --- a/app/models/shipit/ephemeral_commit_checks.rb +++ b/app/models/shipit/ephemeral_commit_checks.rb @@ -14,7 +14,7 @@ def initialize(commit) def run self.status = 'running' commands = StackCommands.new(stack) - commands.with_temporary_working_directory(commit: commit) do |directory| + commands.with_temporary_working_directory(commit:) do |directory| deploy_spec = DeploySpec::FileSystem.new(directory, stack.environment) capture_all(build_commands(deploy_spec.dependencies_steps, chdir: directory)) capture_all(build_commands(deploy_spec.review_checks, chdir: directory)) @@ -47,7 +47,7 @@ def write(output) private def build_commands(commands, chdir:) - commands.map { |c| Command.new(c, env: Shipit.env, chdir: chdir) } + commands.map { |c| Command.new(c, env: Shipit.env, chdir:) } end def capture_all(commands) diff --git a/app/models/shipit/hook.rb b/app/models/shipit/hook.rb index 8c7ae695c..bb5fd2872 100644 --- a/app/models/shipit/hook.rb +++ b/app/models/shipit/hook.rb @@ -144,7 +144,7 @@ def deliver!(event, payload) url: delivery_url, content_type: CONTENT_TYPES[content_type], payload: serialize_payload(payload), - secret: secret, + secret:, ) end diff --git a/app/models/shipit/merge_request.rb b/app/models/shipit/merge_request.rb index fa9208dc5..d9ee6a111 100644 --- a/app/models/shipit/merge_request.rb +++ b/app/models/shipit/merge_request.rb @@ -131,8 +131,8 @@ def request_merge!(stack, number, user) merge_requested_at: now, merge_requested_by: user.presence, ).find_or_create_by!( - stack: stack, - number: number, + stack:, + number:, ) rescue ActiveRecord::RecordNotUnique retry @@ -298,7 +298,7 @@ def emit_hooks return unless @merge_status_changed @merge_status_changed = nil - Hook.emit('merge', stack, merge_request: self, status: merge_status, stack: stack) + Hook.emit('merge', stack, merge_request: self, status: merge_status, stack:) end def find_or_create_commit_from_github_by_sha!(sha, attributes) diff --git a/app/models/shipit/pull_request.rb b/app/models/shipit/pull_request.rb index 0083ad9c0..a8c25abb2 100644 --- a/app/models/shipit/pull_request.rb +++ b/app/models/shipit/pull_request.rb @@ -30,7 +30,7 @@ def emit_update_hooks end def emit_hooks(reason) - Hook.emit('pull_request', stack, action: reason, pull_request: self, stack: stack) + Hook.emit('pull_request', stack, action: reason, pull_request: self, stack:) end def github_pull_request=(github_pull_request) diff --git a/app/models/shipit/release_status.rb b/app/models/shipit/release_status.rb index 314b24b91..83a46c6bb 100644 --- a/app/models/shipit/release_status.rb +++ b/app/models/shipit/release_status.rb @@ -31,7 +31,7 @@ def create_status_on_github commit.sha, state, context: stack.release_status_context, - target_url: target_url, + target_url:, description: description&.truncate(MAX_DESCRIPTION_LENGTH), ) end diff --git a/app/models/shipit/stack.rb b/app/models/shipit/stack.rb index 75a33ab09..66ad7503e 100644 --- a/app/models/shipit/stack.rb +++ b/app/models/shipit/stack.rb @@ -133,7 +133,7 @@ def run_deploy_in_foreground(stack:, revision:) env = stack.cached_deploy_spec.default_deploy_env current_user = Shipit::CommandLineUser.new - stack.trigger_deploy(until_commit, current_user, env: env, force: true, run_now: true) + stack.trigger_deploy(until_commit, current_user, env:, force: true, run_now: true) end def from_param!(param) @@ -144,7 +144,7 @@ def from_param!(param) owner: repo_owner.downcase, name: repo_name.downcase, }, - environment: environment, + environment:, ).first! end end @@ -164,7 +164,7 @@ def trigger_task(definition_id, user, env: nil, force: false) commit = last_deployed_commit.presence || commits.first task = tasks.create( user_id: user.id, - definition: definition, + definition:, until_commit_id: commit.id, since_commit_id: commit.id, env: definition.filter_envs(env), @@ -179,8 +179,8 @@ def build_deploy(until_commit, user, env: nil, force: false) since_commit = last_deployed_commit.presence || commits.first deploys.build( user_id: user.id, - until_commit: until_commit, - since_commit: since_commit, + until_commit:, + since_commit:, env: filter_deploy_envs(env&.to_h || {}), allow_concurrency: force, ignored_safeties: force || !until_commit.deployable?, @@ -304,7 +304,7 @@ def head def merge_status(backlog_leniency_factor: 2.0) return 'locked' if locked? return 'failure' if %w(failure error).freeze.include?(branch_status) - return 'backlogged' if backlogged?(backlog_leniency_factor: backlog_leniency_factor) + return 'backlogged' if backlogged?(backlog_leniency_factor:) 'success' end @@ -424,7 +424,7 @@ def git_path def acquire_git_cache_lock(timeout: 15, &block) @git_cache_lock ||= Flock.new(git_path.to_s + '.lock') - @git_cache_lock.lock(timeout: timeout, &block) + @git_cache_lock.lock(timeout:, &block) end def clear_git_cache! @@ -569,7 +569,7 @@ def update_latest_deployed_ref def broadcast_update Pubsubstub.publish( "stack.#{id}", - { id: id, updated_at: updated_at }.to_json, + { id:, updated_at: }.to_json, name: 'update', ) end @@ -645,7 +645,7 @@ def emit_lock_hooks { from: previous_changes['locked_since'].first, until: Time.zone.now } end - Hook.emit(:lock, self, locked: locked?, lock_details: lock_details, stack: self) + Hook.emit(:lock, self, locked: locked?, lock_details:, stack: self) end private @@ -699,7 +699,7 @@ def emit_removed_hooks end def emit_merge_status_hooks - Hook.emit(:merge_status, self, merge_status: merge_status, stack: self) + Hook.emit(:merge_status, self, merge_status:, stack: self) end def ci_enabled_cache_key diff --git a/app/models/shipit/status.rb b/app/models/shipit/status.rb index 050ddeb93..be089eb69 100644 --- a/app/models/shipit/status.rb +++ b/app/models/shipit/status.rb @@ -23,7 +23,7 @@ class Status < Record class << self def replicate_from_github!(stack_id, github_status) find_or_create_by!( - stack_id: stack_id, + stack_id:, state: github_status.state, description: github_status.description, target_url: github_status.target_url, diff --git a/app/models/shipit/status/missing.rb b/app/models/shipit/status/missing.rb index 128fb7163..31b3f0327 100644 --- a/app/models/shipit/status/missing.rb +++ b/app/models/shipit/status/missing.rb @@ -25,7 +25,7 @@ def missing? end def description - I18n.t('missing_status.description', context: context) + I18n.t('missing_status.description', context:) end def to_partial_path diff --git a/app/models/shipit/task.rb b/app/models/shipit/task.rb index 057d364f9..bbebbe5e7 100644 --- a/app/models/shipit/task.rb +++ b/app/models/shipit/task.rb @@ -358,8 +358,8 @@ def request_abort def abort!(rollback_once_aborted: false, rollback_once_aborted_to: nil, aborted_by:) update!( - rollback_once_aborted: rollback_once_aborted, - rollback_once_aborted_to: rollback_once_aborted_to, + rollback_once_aborted:, + rollback_once_aborted_to:, aborted_by_id: aborted_by.id, ) @@ -395,7 +395,7 @@ def emit_hooks_if_status_changed end def emit_hooks - Hook.emit(hook_event, stack, hook_event => self, status: status, stack: stack) + Hook.emit(hook_event, stack, hook_event => self, status:, stack:) end def hook_event diff --git a/app/models/shipit/task_definition.rb b/app/models/shipit/task_definition.rb index 950baa035..25e23b6d6 100644 --- a/app/models/shipit/task_definition.rb +++ b/app/models/shipit/task_definition.rb @@ -49,13 +49,13 @@ def allow_concurrency? def as_json { - id: id, - action: action, + id:, + action:, title: @title, - description: description, - steps: steps, + description:, + steps:, variables: variables.map(&:to_h), - checklist: checklist, + checklist:, allow_concurrency: allow_concurrency?, } end diff --git a/app/models/shipit/team.rb b/app/models/shipit/team.rb index 73664bcf6..e74c0706c 100644 --- a/app/models/shipit/team.rb +++ b/app/models/shipit/team.rb @@ -17,17 +17,17 @@ class Team < Record class << self def find_or_create_by_handle(handle) organization, slug = handle.split('/').map(&:downcase) - find_by(organization: organization, slug: slug) || fetch_and_create_from_github(organization, slug) + find_by(organization:, slug:) || fetch_and_create_from_github(organization, slug) end def fetch_and_create_from_github(organization, slug) if github_team = find_team_on_github(organization, slug) - create!(github_team: github_team, organization: organization) + create!(github_team:, organization:) end end def find_team_on_github(organization, slug) - gh_api = Shipit.github(organization: organization).api + gh_api = Shipit.github(organization:).api teams = Shipit::OctokitIterator.new(github_api: gh_api) { gh_api.org_teams(organization, per_page: 100) } teams.find { |t| t.slug == slug } rescue Octokit::NotFound @@ -43,7 +43,7 @@ def add_member(member) end def refresh_members! - github_api = Shipit.github(organization: organization).api + github_api = Shipit.github(organization:).api github_members = Shipit::OctokitIterator.new(github_api.get(api_url).rels[:members]) members = github_members.map { |u| User.find_or_create_from_github(u) } self.members = members diff --git a/app/models/shipit/user.rb b/app/models/shipit/user.rb index e1bd904c3..40c0e5770 100644 --- a/app/models/shipit/user.rb +++ b/app/models/shipit/user.rb @@ -21,7 +21,7 @@ class User < Record class << self def find_or_create_by_login!(login) - find_or_create_by!(login: login) do |user| + find_or_create_by!(login:) do |user| # Users are global, any app can be used # This will not work for users that only exist in an Enterprise install user.github_user = Shipit.github.api.user(login) @@ -55,7 +55,7 @@ def find_from_github(github_user) end def create_from_github(github_user) - create(github_user: github_user) + create(github_user:) end def refresh_shard(shard_index, shards_count) @@ -72,7 +72,7 @@ def github_api end def identifiers_for_ping - { github_id: github_id, name: name, email: email, github_login: login } + { github_id:, name:, email:, github_login: login } end def logged_in? @@ -92,7 +92,7 @@ def repositories_contributed_to def stacks_contributed_to return [] unless id - Commit.where('author_id = :id or committer_id = :id', id: id).distinct.pluck(:stack_id) + Commit.where('author_id = :id or committer_id = :id', id:).distinct.pluck(:stack_id) end def refresh_from_github! diff --git a/app/models/shipit/webhooks/handlers/pull_request/review_stack_adapter.rb b/app/models/shipit/webhooks/handlers/pull_request/review_stack_adapter.rb index 87c538e67..aed2ceca2 100644 --- a/app/models/shipit/webhooks/handlers/pull_request/review_stack_adapter.rb +++ b/app/models/shipit/webhooks/handlers/pull_request/review_stack_adapter.rb @@ -13,7 +13,7 @@ def initialize(params, scope: Shipit::ReviewStack) end def stack - @stack ||= scope.find_by(environment: environment) + @stack ||= scope.find_by(environment:) end def find_or_create! @@ -87,7 +87,7 @@ def create! def stack_attributes { branch: params.pull_request.head.ref, - environment: environment, + environment:, ignore_ci: false, continuous_deployment: false, } diff --git a/app/models/shipit/webhooks/handlers/push_handler.rb b/app/models/shipit/webhooks/handlers/push_handler.rb index 34ca8f067..7464dbff1 100644 --- a/app/models/shipit/webhooks/handlers/push_handler.rb +++ b/app/models/shipit/webhooks/handlers/push_handler.rb @@ -10,7 +10,7 @@ class PushHandler < Handler def process stacks .not_archived - .where(branch: branch) + .where(branch:) .find_each(&:sync_github) end diff --git a/lib/shipit.rb b/lib/shipit.rb index 41e216020..d471f2fad 100644 --- a/lib/shipit.rb +++ b/lib/shipit.rb @@ -150,7 +150,7 @@ def dump(object) self.database_serializer = TransitionalSerializer def serialized_column(attribute_name, type: nil, coder: nil) - column = Paquito::SerializedColumn.new(database_serializer, type, attribute_name: attribute_name) + column = Paquito::SerializedColumn.new(database_serializer, type, attribute_name:) if coder Paquito.chain(coder, column) else diff --git a/lib/shipit/flock.rb b/lib/shipit/flock.rb index dfbafcfbf..f3ccd4b3a 100644 --- a/lib/shipit/flock.rb +++ b/lib/shipit/flock.rb @@ -20,7 +20,7 @@ def lock(timeout:) path.parent.mkpath path.open('w') do |file| - if retrying(timeout: timeout) { file.flock(File::LOCK_EX | File::LOCK_NB) } + if retrying(timeout:) { file.flock(File::LOCK_EX | File::LOCK_NB) } file.write($PROCESS_ID.to_s) @acquired = true begin diff --git a/lib/shipit/github_app.rb b/lib/shipit/github_app.rb index d7c3f58a7..1e77bb497 100644 --- a/lib/shipit/github_app.rb +++ b/lib/shipit/github_app.rb @@ -156,8 +156,8 @@ def enterprise? def new_client(options = {}) if enterprise? options = options.reverse_merge( - api_endpoint: api_endpoint, - web_endpoint: web_endpoint, + api_endpoint:, + web_endpoint:, ) end client = Octokit::Client.new(options) diff --git a/lib/shipit/stack_commands.rb b/lib/shipit/stack_commands.rb index 88af63d68..0b6e242e8 100644 --- a/lib/shipit/stack_commands.rb +++ b/lib/shipit/stack_commands.rb @@ -17,26 +17,26 @@ def env def fetch_commit(commit) create_directories if valid_git_repository?(@stack.git_path) - git('fetch', 'origin', '--quiet', '--tags', commit.sha, env: env, chdir: @stack.git_path) + git('fetch', 'origin', '--quiet', '--tags', commit.sha, env:, chdir: @stack.git_path) else @stack.clear_git_cache! - git_clone(@stack.repo_git_url, @stack.git_path, branch: @stack.branch, env: env, chdir: @stack.deploys_path) + git_clone(@stack.repo_git_url, @stack.git_path, branch: @stack.branch, env:, chdir: @stack.deploys_path) end end def fetch create_directories if valid_git_repository?(@stack.git_path) - git('fetch', 'origin', '--quiet', '--tags', @stack.branch, env: env, chdir: @stack.git_path) + git('fetch', 'origin', '--quiet', '--tags', @stack.branch, env:, chdir: @stack.git_path) else @stack.clear_git_cache! - git_clone(@stack.repo_git_url, @stack.git_path, branch: @stack.branch, env: env, chdir: @stack.deploys_path) + git_clone(@stack.repo_git_url, @stack.git_path, branch: @stack.branch, env:, chdir: @stack.deploys_path) end end def fetched?(commit) if valid_git_repository?(@stack.git_path) - git('rev-parse', '--quiet', '--verify', "#{commit.sha}^{commit}", env: env, chdir: @stack.git_path) + git('rev-parse', '--quiet', '--verify', "#{commit.sha}^{commit}", env:, chdir: @stack.git_path) else # When the stack's git cache is not valid, the commit is # NOT fetched. To keep the interface of this method @@ -44,7 +44,7 @@ def fetched?(commit) # method returns false - has a non-zero exit status. We utilize # the POSIX 'test' command with no arguments which should # always have an exit status of 1. - Command.new('test', env: env, chdir: @stack.deploys_path) + Command.new('test', env:, chdir: @stack.deploys_path) end end @@ -52,7 +52,7 @@ def fetch_deployed_revision with_temporary_working_directory(commit: @stack.commits.reachable.last) do |dir| spec = DeploySpec::FileSystem.new(dir, @stack.environment) outputs = spec.fetch_deployed_revision_steps!.map do |command_line| - Command.new(command_line, env: env, chdir: dir).run + Command.new(command_line, env:, chdir: dir).run end outputs.find(&:present?).try(:strip) end diff --git a/lib/shipit/task_commands.rb b/lib/shipit/task_commands.rb index 5e99a604b..b251d5c29 100644 --- a/lib/shipit/task_commands.rb +++ b/lib/shipit/task_commands.rb @@ -16,13 +16,13 @@ def deploy_spec def install_dependencies deploy_spec.dependencies_steps!.map do |command_line| - Command.new(command_line, env: env, chdir: steps_directory) + Command.new(command_line, env:, chdir: steps_directory) end end def perform steps.map do |command_line| - Command.new(command_line, env: env, chdir: steps_directory) + Command.new(command_line, env:, chdir: steps_directory) end end diff --git a/lib/tasks/shipit.rake b/lib/tasks/shipit.rake index 7d6f94dcd..6fe922249 100644 --- a/lib/tasks/shipit.rake +++ b/lib/tasks/shipit.rake @@ -13,12 +13,12 @@ namespace :shipit do class Task def write(text) p(text) - chunks.create!(text: text) + chunks.create!(text:) end end end - Shipit::Stack.run_deploy_in_foreground(stack: stack, revision: revision) + Shipit::Stack.run_deploy_in_foreground(stack:, revision:) rescue ArgumentError p("Use this command as follows:") p("bundle exec rake shipit:deploy stack='shopify/shipit/production' revision='$SHA'") diff --git a/test/controllers/api/stacks_controller_test.rb b/test/controllers/api/stacks_controller_test.rb index 321b2f806..e376c3112 100644 --- a/test/controllers/api/stacks_controller_test.rb +++ b/test/controllers/api/stacks_controller_test.rb @@ -42,7 +42,7 @@ class StacksControllerTest < ApiControllerTestCase test "#create fails to create stack if it already exists" do repository = shipit_repositories(:rails) existing_stack = Stack.create!( - repository: repository, + repository:, environment: 'staging', branch: 'staging', ) diff --git a/test/controllers/api/tasks_controller_test.rb b/test/controllers/api/tasks_controller_test.rb index 92d1791cf..3fe84b3aa 100644 --- a/test/controllers/api/tasks_controller_test.rb +++ b/test/controllers/api/tasks_controller_test.rb @@ -47,14 +47,14 @@ class TasksControllerTest < ApiControllerTestCase test "#trigger refuses to trigger a task with tasks not whitelisted" do env = { 'DANGEROUS_VARIABLE' => 'bar' } - post :trigger, params: { stack_id: @stack.to_param, task_name: 'restart', env: env } + post :trigger, params: { stack_id: @stack.to_param, task_name: 'restart', env: } assert_response :unprocessable_entity assert_json 'message', 'Variables DANGEROUS_VARIABLE have not been whitelisted' end test "#trigger triggers a task with only whitelisted env variables" do env = { 'FOO' => 'bar' } - post :trigger, params: { stack_id: @stack.to_param, task_name: 'restart', env: env } + post :trigger, params: { stack_id: @stack.to_param, task_name: 'restart', env: } assert_response :accepted assert_json 'type', 'task' assert_json 'status', 'pending' @@ -68,7 +68,7 @@ class TasksControllerTest < ApiControllerTestCase test "#trigger triggers a task with explicitly passed and default variables" do env = { 'WALRUS' => 'overridden value' } - post :trigger, params: { stack_id: @stack.to_param, task_name: 'restart', env: env } + post :trigger, params: { stack_id: @stack.to_param, task_name: 'restart', env: } assert_response :accepted # FOO and BAR are variables with a default value diff --git a/test/controllers/deploys_controller_test.rb b/test/controllers/deploys_controller_test.rb index a51c47554..8723af97d 100644 --- a/test/controllers/deploys_controller_test.rb +++ b/test/controllers/deploys_controller_test.rb @@ -63,7 +63,7 @@ class DeploysControllerTest < ActionController::TestCase test ":create can receive an :env hash" do env = { 'SAFETY_DISABLED' => '1' } - post :create, params: { stack_id: @stack.to_param, deploy: { until_commit_id: @commit.id, env: env } } + post :create, params: { stack_id: @stack.to_param, deploy: { until_commit_id: @commit.id, env: } } new_deploy = Deploy.last assert_equal env, new_deploy.env end diff --git a/test/controllers/rollbacks_controller_test.rb b/test/controllers/rollbacks_controller_test.rb index a700953ea..d15bff748 100644 --- a/test/controllers/rollbacks_controller_test.rb +++ b/test/controllers/rollbacks_controller_test.rb @@ -19,7 +19,7 @@ class RollbacksControllerTest < ActionController::TestCase test ":create can receive an :env hash" do env = { 'SAFETY_DISABLED' => '1' } - post :create, params: { stack_id: @stack.to_param, rollback: { parent_id: @deploy.id, env: env } } + post :create, params: { stack_id: @stack.to_param, rollback: { parent_id: @deploy.id, env: } } new_rollback = Rollback.last assert_equal env, new_rollback.env end diff --git a/test/controllers/tasks_controller_test.rb b/test/controllers/tasks_controller_test.rb index d2c55030d..7fae31d94 100644 --- a/test/controllers/tasks_controller_test.rb +++ b/test/controllers/tasks_controller_test.rb @@ -55,7 +55,7 @@ class TasksControllerTest < ActionController::TestCase test "tasks with variables defined in the shipit.yml can be triggered with their variables set" do env = { "FOO" => "0" } - post :create, params: { stack_id: @stack, definition_id: @definition.id, task: { env: env }, force: 'true' } + post :create, params: { stack_id: @stack, definition_id: @definition.id, task: { env: }, force: 'true' } assert_redirected_to stack_tasks_path(@stack, Task.last) end diff --git a/test/controllers/webhooks_controller_test.rb b/test/controllers/webhooks_controller_test.rb index b811b45e1..15cbc777d 100644 --- a/test/controllers/webhooks_controller_test.rb +++ b/test/controllers/webhooks_controller_test.rb @@ -25,7 +25,7 @@ class WebhooksControllerTest < ActionController::TestCase body = JSON.parse(payload(:push_master)).to_json assert_enqueued_with(job: GithubSyncJob, args: [stack_id: @stack.id]) do - post :create, body: body, as: :json + post :create, body:, as: :json end end @@ -44,7 +44,7 @@ class WebhooksControllerTest < ActionController::TestCase body = JSON.parse(payload(:status_master)).merge(repository_params).to_json assert_difference 'commit.statuses.count', 1 do - post :create, body: body, as: :json + post :create, body:, as: :json end status = commit.statuses.last diff --git a/test/helpers/json_helper.rb b/test/helpers/json_helper.rb index f49173379..db71dcbfc 100644 --- a/test/helpers/json_helper.rb +++ b/test/helpers/json_helper.rb @@ -9,7 +9,7 @@ def assert_json(path = nil, expected_value = UNDEFINED, &block) end def assert_json_document(document, path, expected_value = UNDEFINED) - value = follow_path(path.to_s.split('.'), document: document) + value = follow_path(path.to_s.split('.'), document:) if block_given? yield value elsif expected_value == UNDEFINED @@ -27,7 +27,7 @@ def assert_json_keys(path, keys = nil, document: response.body) path = nil end - value = follow_path(path.to_s.split('.'), document: document) + value = follow_path(path.to_s.split('.'), document:) case value when Hash assert_equal(keys.sort, value.keys.sort) @@ -39,7 +39,7 @@ def assert_json_keys(path, keys = nil, document: response.body) def assert_no_json(path, document: response.body) segments = path.to_s.split('.') last_segment = segments.pop - leaf = follow_path(segments, document: document) + leaf = follow_path(segments, document:) case leaf when Hash refute(leaf.key?(last_segment), "Expected #{leaf.inspect} not to include #{last_segment.inspect}") diff --git a/test/jobs/chunk_rollup_job_test.rb b/test/jobs/chunk_rollup_job_test.rb index f4d341a5c..cb09e58db 100644 --- a/test/jobs/chunk_rollup_job_test.rb +++ b/test/jobs/chunk_rollup_job_test.rb @@ -26,7 +26,7 @@ class ChunkRollupJobTest < ActiveSupport::TestCase test "#peform ignores non-finished jobs" do logger = mock logger.expects(:error).once - @job.stubs(logger: logger) + @job.stubs(logger:) @task.update_attribute(:status, :pending) @@ -36,7 +36,7 @@ class ChunkRollupJobTest < ActiveSupport::TestCase test "#perform ignores tasks already rolled up" do logger = mock logger.expects(:error).once - @job.stubs(logger: logger) + @job.stubs(logger:) @task.rolled_up = true diff --git a/test/jobs/github_sync_job_test.rb b/test/jobs/github_sync_job_test.rb index dbd6ca32f..081f6e21a 100644 --- a/test/jobs/github_sync_job_test.rb +++ b/test/jobs/github_sync_job_test.rb @@ -62,13 +62,13 @@ class GithubSyncJobTest < ActiveSupport::TestCase [ stub( sha: '36514755579bfb5bc313f403b216f4347a027990', - author: author, + author:, committer: author, stats: nil, commit: stub( sha: '36514755579bfb5bc313f403b216f4347a027990', message: 'Revert "fix it!"', - author: author, + author:, committer: author, ), ), diff --git a/test/models/commits_test.rb b/test/models/commits_test.rb index 6fe6aaffe..c69b3f299 100644 --- a/test/models/commits_test.rb +++ b/test/models/commits_test.rb @@ -93,7 +93,7 @@ class CommitsTest < ActiveSupport::TestCase email: 'walrus@shopify.com', date: Time.now, }, - message: message, + message:, }, ), ) diff --git a/test/models/delivery_test.rb b/test/models/delivery_test.rb index a8172b4c7..20e97a114 100644 --- a/test/models/delivery_test.rb +++ b/test/models/delivery_test.rb @@ -26,7 +26,7 @@ class DeliveryTest < ActiveSupport::TestCase test "#send! post the payload and update the status to `sent`" do headers = { 'content-type' => 'text/plain', 'content-length' => '2' } - stub_request(:post, @delivery.url).to_return(headers: headers, body: 'OK') + stub_request(:post, @delivery.url).to_return(headers:, body: 'OK') assert_equal 'scheduled', @delivery.status @delivery.send! diff --git a/test/models/deploys_test.rb b/test/models/deploys_test.rb index 5778b0aa8..607839948 100644 --- a/test/models/deploys_test.rb +++ b/test/models/deploys_test.rb @@ -261,7 +261,7 @@ def setup expect_event(deploy) deploy.status = 'running' - expect_hook(:deploy, deploy.stack, status: 'success', deploy: deploy, stack: deploy.stack) do + expect_hook(:deploy, deploy.stack, status: 'success', deploy:, stack: deploy.stack) do deploy.complete! end end @@ -281,7 +281,7 @@ def setup expect_event(deploy) deploy.status = 'running' - expect_hook(:deploy, deploy.stack, status: 'failed', deploy: deploy, stack: deploy.stack) do + expect_hook(:deploy, deploy.stack, status: 'failed', deploy:, stack: deploy.stack) do deploy.failure! end end @@ -301,7 +301,7 @@ def setup expect_event(deploy) deploy.status = 'running' - expect_hook(:deploy, deploy.stack, status: 'error', deploy: deploy, stack: deploy.stack) do + expect_hook(:deploy, deploy.stack, status: 'error', deploy:, stack: deploy.stack) do deploy.error! end end @@ -321,7 +321,7 @@ def setup expect_event(deploy) deploy.status = 'pending' - expect_hook(:deploy, deploy.stack, status: 'running', deploy: deploy, stack: deploy.stack) do + expect_hook(:deploy, deploy.stack, status: 'running', deploy:, stack: deploy.stack) do deploy.run! end end @@ -514,7 +514,7 @@ def setup def create_test_stack(repository: Shipit::Repository.find_or_create_by!(owner: "shopify-test", name: "shipit-engine-test")) Shipit::Stack.create( - repository: repository, + repository:, environment: 'production', branch: "master", merge_queue_enabled: true, @@ -525,7 +525,7 @@ def create_test_stack(repository: Shipit::Repository.find_or_create_by!(owner: " def create_test_commit(stack_id:, user_id:) Shipit::Commit.new( - stack_id: stack_id, + stack_id:, author_id: user_id, sha: SecureRandom.hex(20), additions: 2, @@ -540,18 +540,18 @@ def create_test_commit(stack_id:, user_id:) def create_test_status(commit_id:, stack_id:, state: "success") Shipit::Status.new( description: "Description for commit #{commit_id}", - stack_id: stack_id, - commit_id: commit_id, - state: state, + stack_id:, + commit_id:, + state:, ) end def create_test_deploy(stack_id:, user_id:, since_commit_id:, until_commit_id: since_commit_id) Shipit::Deploy.new( - stack_id: stack_id, - user_id: user_id, - since_commit_id: since_commit_id, - until_commit_id: until_commit_id, + stack_id:, + user_id:, + since_commit_id:, + until_commit_id:, status: "success", type: "Shipit::Deploy", ) @@ -568,7 +568,7 @@ def assert_generated_record_ids_are_sequential(record_id_series) def generate_commits(amount:, stack_id:, user_id:, validate:) commit_ids = [] amount.times do - commit = create_test_commit(stack_id: stack_id, user_id: user_id) + commit = create_test_commit(stack_id:, user_id:) commit.save commit.reload commit_ids << commit.id @@ -586,11 +586,11 @@ def generate_commits(amount:, stack_id:, user_id:, validate:) stack_id = test_stack.id # Create valid commit history for the stack. We need several commits to deploy and roll back through. - commit_ids = generate_commits(amount: 4, stack_id: stack_id, user_id: user_id, validate: true) - commit_ids.each { |commit_id| create_test_status(commit_id: commit_id, stack_id: stack_id, state: "success").save } + commit_ids = generate_commits(amount: 4, stack_id:, user_id:, validate: true) + commit_ids.each { |commit_id| create_test_status(commit_id:, stack_id:, state: "success").save } # Three deploys of commits 1-2, 2-3 and 3-4 respectively. Reverting last should result in Deploy 3 (commit 3) being latest. - 3.times { |index| create_test_deploy(stack_id: stack_id, user_id: user_id, since_commit_id: commit_ids[index], until_commit_id: commit_ids[index + 1]).save } + 3.times { |index| create_test_deploy(stack_id:, user_id:, since_commit_id: commit_ids[index], until_commit_id: commit_ids[index + 1]).save } # Get the reference with Rails-mutated field values. commit3 = Shipit::Commit.second_to_last @@ -622,7 +622,7 @@ def generate_commits(amount:, stack_id:, user_id:, validate:) running_deploy = shipit_deploys(:shipit_running) rollback_to = shipit_deploys(:shipit_pending) - final_rollback = running_deploy.trigger_revert(rollback_to: rollback_to) + final_rollback = running_deploy.trigger_revert(rollback_to:) assert_equal "Shipit::Rollback", final_rollback.type assert_equal 4, final_rollback.until_commit_id @@ -636,8 +636,8 @@ def generate_commits(amount:, stack_id:, user_id:, validate:) stack_id = test_stack.id # Create valid commit history for the stack. We need several commits to deploy and roll back through. - commit_ids = generate_commits(amount: 4, stack_id: stack_id, user_id: user_id, validate: true) - commit_ids.each { |commit_id| create_test_status(commit_id: commit_id, stack_id: stack_id, state: "success").save } + commit_ids = generate_commits(amount: 4, stack_id:, user_id:, validate: true) + commit_ids.each { |commit_id| create_test_status(commit_id:, stack_id:, state: "success").save } # We want the following order of Deploys: # 1. Success (commits 1-2) @@ -646,10 +646,10 @@ def generate_commits(amount:, stack_id:, user_id:, validate:) # 4. Running (commits 3-4) # 5. Reversion of the running deploy to the last successful deploy. (-> commits 1-2, i.e. the successful deploy.) - deploy1 = create_test_deploy(stack_id: stack_id, user_id: user_id, since_commit_id: commit_ids[0], until_commit_id: commit_ids[1]) + deploy1 = create_test_deploy(stack_id:, user_id:, since_commit_id: commit_ids[0], until_commit_id: commit_ids[1]) deploy1.save - deploy2 = create_test_deploy(stack_id: stack_id, user_id: user_id, since_commit_id: commit_ids[1], until_commit_id: commit_ids[2]) + deploy2 = create_test_deploy(stack_id:, user_id:, since_commit_id: commit_ids[1], until_commit_id: commit_ids[2]) deploy2.status = "faulty" deploy2.save @@ -659,7 +659,7 @@ def generate_commits(amount:, stack_id:, user_id:, validate:) assert_equal commit_ids[1], test_stack.last_deployed_commit.id - deploy3 = create_test_deploy(stack_id: stack_id, user_id: user_id, since_commit_id: commit_ids[2], until_commit_id: commit_ids[3]) + deploy3 = create_test_deploy(stack_id:, user_id:, since_commit_id: commit_ids[2], until_commit_id: commit_ids[3]) deploy3.status = "running" deploy3.rollback_once_aborted = false deploy3.save @@ -694,8 +694,8 @@ def generate_commits(amount:, stack_id:, user_id:, validate:) stack_id = test_stack.id # Create valid commit history for the stack. We need several commits to deploy and roll back through. - commit_ids = generate_commits(amount: 4, stack_id: stack_id, user_id: user_id, validate: true) - commit_ids.each { |commit_id| create_test_status(commit_id: commit_id, stack_id: stack_id, state: "success").save } + commit_ids = generate_commits(amount: 4, stack_id:, user_id:, validate: true) + commit_ids.each { |commit_id| create_test_status(commit_id:, stack_id:, state: "success").save } # We want the following order of Deploys: # 1. Success (commits 1-2) @@ -704,14 +704,14 @@ def generate_commits(amount:, stack_id:, user_id:, validate:) # 4. Reversion of the running deploy to the last successful deploy. (-> commits 1-2, i.e. the successful deploy.) # If the revert functionality doesn't restrict to deploys and rollbacks, then commit 3 will be latest deployed when the reversion is done. - deploy1 = create_test_deploy(stack_id: stack_id, user_id: user_id, since_commit_id: commit_ids[0], until_commit_id: commit_ids[1]) + deploy1 = create_test_deploy(stack_id:, user_id:, since_commit_id: commit_ids[0], until_commit_id: commit_ids[1]) deploy1.save - deploy2 = create_test_deploy(stack_id: stack_id, user_id: user_id, since_commit_id: commit_ids[1], until_commit_id: commit_ids[2]) + deploy2 = create_test_deploy(stack_id:, user_id:, since_commit_id: commit_ids[1], until_commit_id: commit_ids[2]) deploy2.type = "Shipit::Fake" deploy2.save - deploy3 = create_test_deploy(stack_id: stack_id, user_id: user_id, since_commit_id: commit_ids[2], until_commit_id: commit_ids[3]) + deploy3 = create_test_deploy(stack_id:, user_id:, since_commit_id: commit_ids[2], until_commit_id: commit_ids[3]) deploy3.status = "running" deploy3.rollback_once_aborted = false deploy3.save @@ -745,8 +745,8 @@ def generate_commits(amount:, stack_id:, user_id:, validate:) stack_id = test_stack.id # Create valid commit history for the stack. We need several commits to deploy and roll back through. - commit_ids = generate_commits(amount: 4, stack_id: stack_id, user_id: user_id, validate: true) - commit_ids.each { |commit_id| create_test_status(commit_id: commit_id, stack_id: stack_id, state: "success").save } + commit_ids = generate_commits(amount: 4, stack_id:, user_id:, validate: true) + commit_ids.each { |commit_id| create_test_status(commit_id:, stack_id:, state: "success").save } # We want the following order of Deploys: # 1. Success (commits 1-2) @@ -755,13 +755,13 @@ def generate_commits(amount:, stack_id:, user_id:, validate:) # 4. Reversion of the running deploy to the last successful deploy of the same stack. (-> commits 1-2, i.e. the successful deploy.) # If the revert functionality doesn't restrict to the correct stack, then commit 3 will be latest deployed when the reversion is done. - deploy1 = create_test_deploy(stack_id: stack_id, user_id: user_id, since_commit_id: commit_ids[0], until_commit_id: commit_ids[1]) + deploy1 = create_test_deploy(stack_id:, user_id:, since_commit_id: commit_ids[0], until_commit_id: commit_ids[1]) deploy1.save - deploy2 = create_test_deploy(stack_id: other_stack.id, user_id: user_id, since_commit_id: commit_ids[1], until_commit_id: commit_ids[2]) + deploy2 = create_test_deploy(stack_id: other_stack.id, user_id:, since_commit_id: commit_ids[1], until_commit_id: commit_ids[2]) deploy2.save - deploy3 = create_test_deploy(stack_id: stack_id, user_id: user_id, since_commit_id: commit_ids[2], until_commit_id: commit_ids[3]) + deploy3 = create_test_deploy(stack_id:, user_id:, since_commit_id: commit_ids[2], until_commit_id: commit_ids[3]) deploy3.status = "running" deploy3.rollback_once_aborted = false deploy3.save @@ -789,9 +789,9 @@ def generate_commits(amount:, stack_id:, user_id:, validate:) test_stack.reload stack_id = test_stack.id - commit_ids = generate_commits(amount: 2, stack_id: stack_id, user_id: user_id, validate: true) - commit_ids.each { |commit_id| create_test_status(commit_id: commit_id, stack_id: stack_id, state: "success").save } - deploy1 = create_test_deploy(stack_id: stack_id, user_id: user_id, since_commit_id: commit_ids[0], until_commit_id: commit_ids[1]) + commit_ids = generate_commits(amount: 2, stack_id:, user_id:, validate: true) + commit_ids.each { |commit_id| create_test_status(commit_id:, stack_id:, state: "success").save } + deploy1 = create_test_deploy(stack_id:, user_id:, since_commit_id: commit_ids[0], until_commit_id: commit_ids[1]) deploy1.save rollback = deploy1.trigger_revert diff --git a/test/models/merge_request_test.rb b/test/models/merge_request_test.rb index 16f8f020c..668d22f61 100644 --- a/test/models/merge_request_test.rb +++ b/test/models/merge_request_test.rb @@ -102,8 +102,8 @@ class MergeRequestTest < ActiveSupport::TestCase [head_sha, base_sha].each do |sha| Shipit.github.api.expects(:commit).with(@stack.github_repo_name, sha).returns( stub( - sha: sha, - author: author, + sha:, + author:, committer: author, commit: stub( message: 'Great feature', diff --git a/test/models/shipit/check_run_test.rb b/test/models/shipit/check_run_test.rb index 0ec6ecbfa..2c57bb644 100644 --- a/test/models/shipit/check_run_test.rb +++ b/test/models/shipit/check_run_test.rb @@ -39,14 +39,14 @@ class CheckRunTest < ActiveSupport::TestCase assert_difference -> { @commit.check_runs.count }, +1 do @commit.check_runs.create_or_update_from_github!( @stack.id, - github_check_run(conclusion: 'success', completed_at: completed_at), + github_check_run(conclusion: 'success', completed_at:), ) end assert_enqueued_with(job: RefreshCheckRunsJob) do @commit.check_runs.create_or_update_from_github!( @stack.id, - github_check_run(conclusion: nil, completed_at: completed_at), + github_check_run(conclusion: nil, completed_at:), ) end @@ -56,7 +56,7 @@ class CheckRunTest < ActiveSupport::TestCase @stack.id, github_check_run( conclusion: 'action_required', - completed_at: completed_at, + completed_at:, started_at: completed_at + 1.minute, ), ) @@ -68,12 +68,12 @@ class CheckRunTest < ActiveSupport::TestCase test ".create_or_update_from_github! is idempotent" do completed_at = Time.now assert_difference -> { @commit.check_runs.count }, +1 do - @commit.check_runs.create_or_update_from_github!(@stack.id, github_check_run(completed_at: completed_at)) + @commit.check_runs.create_or_update_from_github!(@stack.id, github_check_run(completed_at:)) end assert_no_difference -> { @commit.check_runs.count } do assert_no_enqueued_jobs(only: RefreshCheckRunsJob) do - @commit.check_runs.create_or_update_from_github!(@stack.id, github_check_run(completed_at: completed_at)) + @commit.check_runs.create_or_update_from_github!(@stack.id, github_check_run(completed_at:)) end end end @@ -83,7 +83,7 @@ class CheckRunTest < ActiveSupport::TestCase assert_difference -> { @commit.check_runs.count }, +1 do @commit.check_runs.create_or_update_from_github!( @stack.id, - github_check_run(conclusion: 'success', completed_at: completed_at), + github_check_run(conclusion: 'success', completed_at:), ) end @@ -115,7 +115,7 @@ class CheckRunTest < ActiveSupport::TestCase assert_difference -> { @commit.check_runs.count }, +1 do @commit.check_runs.create_or_update_from_github!( @stack.id, - github_check_run(conclusion: 'success', completed_at: completed_at), + github_check_run(conclusion: 'success', completed_at:), ) end @@ -152,7 +152,7 @@ class CheckRunTest < ActiveSupport::TestCase 'action_required' => 'pending', }.each do |conclusion, expected_status| test "#state is #{expected_status.inspect} when conclusion is #{conclusion.inspect}" do - @check_run.update!(conclusion: conclusion) + @check_run.update!(conclusion:) assert_equal expected_status, @check_run.state end end diff --git a/test/models/shipit/repository_test.rb b/test/models/shipit/repository_test.rb index 5c7dbdbb3..4ad8f0536 100644 --- a/test/models/shipit/repository_test.rb +++ b/test/models/shipit/repository_test.rb @@ -72,7 +72,7 @@ class RepositoryTest < ActiveSupport::TestCase owner = "repository-owner" name = "repository-name" github_repo_name = [owner, name].join("/") - expected_repository = Repository.create(owner: owner, name: name) + expected_repository = Repository.create(owner:, name:) found_repository = Repository.from_github_repo_name(github_repo_name) diff --git a/test/models/shipit/stack_test.rb b/test/models/shipit/stack_test.rb index 746a1afe7..c013b567e 100644 --- a/test/models/shipit/stack_test.rb +++ b/test/models/shipit/stack_test.rb @@ -87,7 +87,7 @@ def deliver(event, stack, payload) assert_includes(FakeReceiver.hooks, [ :deploy, @stack, - { deploy: deploy, status: "pending", stack: @stack }, + { deploy:, status: "pending", stack: @stack }, ]) ensure Shipit.internal_hook_receivers = original_receivers @@ -818,7 +818,7 @@ def deliver(event, stack, payload) assert !commits.empty? commits.each { |c| refute_predicate c, :deployable? } - assert_nil @stack.next_expected_commit_to_deploy(commits: commits) + assert_nil @stack.next_expected_commit_to_deploy(commits:) end test "#next_expected_commit_to_deploy returns nil if all deployable commits are active" do @@ -828,7 +828,7 @@ def deliver(event, stack, payload) assert !commits.empty? commits.each { |c| assert_predicate c, :active? } - assert_nil @stack.next_expected_commit_to_deploy(commits: commits) + assert_nil @stack.next_expected_commit_to_deploy(commits:) end test "#next_expected_commit_to_deploy returns nil if there are no commits" do @@ -841,7 +841,7 @@ def deliver(event, stack, payload) assert !commits.empty? - most_recent_limited = @stack.next_expected_commit_to_deploy(commits: commits) + most_recent_limited = @stack.next_expected_commit_to_deploy(commits:) most_recent = commits.find { |c| !c.active? && c.deployable? } assert most_recent.id > most_recent_limited.id @@ -860,7 +860,7 @@ def deliver(event, stack, payload) test "#lock_reverted_commits! locks all commits between the original and reverted commits" do reverted_commit = @stack.undeployed_commits.first revert_author = shipit_users(:bob) - generate_revert_commit(stack: @stack, reverted_commit: reverted_commit, author: revert_author) + generate_revert_commit(stack: @stack, reverted_commit:, author: revert_author) @stack.reload assert_equal( @@ -888,7 +888,7 @@ def deliver(event, stack, payload) test "#lock_reverted_commits! is a no-op if the reverted commit has already shipped" do reverted_commit = shipit_commits(:first) revert_author = shipit_users(:bob) - generate_revert_commit(stack: @stack, reverted_commit: reverted_commit, author: revert_author) + generate_revert_commit(stack: @stack, reverted_commit:, author: revert_author) @stack.reload initial_state = [ @@ -1016,7 +1016,7 @@ def generate_revert_commit(stack:, reverted_commit:, author: reverted_commit.aut stack.commits.create( sha: SecureRandom.hex(20), message: "Revert \"#{reverted_commit.message_header}\"", - author: author, + author:, committer: author, authored_at: Time.zone.now, committed_at: Time.zone.now, diff --git a/test/models/shipit/webhooks/handlers/pull_request/closed_handler_test.rb b/test/models/shipit/webhooks/handlers/pull_request/closed_handler_test.rb index 9018aaef8..43673aca2 100644 --- a/test/models/shipit/webhooks/handlers/pull_request/closed_handler_test.rb +++ b/test/models/shipit/webhooks/handlers/pull_request/closed_handler_test.rb @@ -40,7 +40,7 @@ class ClosedHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_all, ) @@ -53,7 +53,7 @@ class ClosedHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -69,7 +69,7 @@ class ClosedHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -85,7 +85,7 @@ class ClosedHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -101,7 +101,7 @@ class ClosedHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :prevent_with_label, label: "pull-requests-label", ) diff --git a/test/models/shipit/webhooks/handlers/pull_request/labeled_handler_test.rb b/test/models/shipit/webhooks/handlers/pull_request/labeled_handler_test.rb index ea25cfbcb..078243c9d 100644 --- a/test/models/shipit/webhooks/handlers/pull_request/labeled_handler_test.rb +++ b/test/models/shipit/webhooks/handlers/pull_request/labeled_handler_test.rb @@ -26,7 +26,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase test "ignores Github PullRequest webhooks when the Repository has disabled the Review Stacks feature" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, provisioning_enabled: false, behavior: :allow_with_label, label: "pull-requests-label", @@ -40,7 +40,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase test "ignores Github PullRequest webhooks when the repository allows_all PullRequests to create ReviewStacks" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_all, ) @@ -53,7 +53,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase stack = create_archived_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -69,7 +69,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase test "creates and provisions a new review stack when the repository creates ReviewStacks with allow_with_label and the label is present" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -91,7 +91,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -107,7 +107,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -122,7 +122,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase test "ignores Github PullRequest webhooks when the repository allow_with_label to create ReviewStacks and the label is absent" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -138,7 +138,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -152,7 +152,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -165,7 +165,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase test "ignores Github PullRequest webhooks when the repository prevent_with_label to create ReviewStacks and the label is present" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -179,7 +179,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase stack = create_archived_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -195,7 +195,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase test "creates and provisions a new review stack when the repository creates ReviewStacks with prevent_with_label and the label is absent" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -216,7 +216,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase test "assigns the PullRequest to newly created stacks" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -232,7 +232,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase create_archived_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_with_label, label: "pull-requests-label", ) diff --git a/test/models/shipit/webhooks/handlers/pull_request/opened_handler_test.rb b/test/models/shipit/webhooks/handlers/pull_request/opened_handler_test.rb index f6675eee3..2e2676853 100644 --- a/test/models/shipit/webhooks/handlers/pull_request/opened_handler_test.rb +++ b/test/models/shipit/webhooks/handlers/pull_request/opened_handler_test.rb @@ -96,7 +96,7 @@ class OpenedHandlerTest < ActiveSupport::TestCase test "only provision stacks for repos with auto-provisioning enabled" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, provisioning_enabled: false, behavior: :allow_all, ) @@ -116,7 +116,7 @@ class OpenedHandlerTest < ActiveSupport::TestCase test "creates stacks for repos that allow_all" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_all, label: "pull-requests-label", ) @@ -129,7 +129,7 @@ class OpenedHandlerTest < ActiveSupport::TestCase test "creates stacks for repos that allow_with_label when label is present" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -144,7 +144,7 @@ class OpenedHandlerTest < ActiveSupport::TestCase test "does not create stacks for repos that allow_with_label when label is absent" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -159,7 +159,7 @@ class OpenedHandlerTest < ActiveSupport::TestCase test "create stacks for repos what prevent_with_label when label is absent" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -174,7 +174,7 @@ class OpenedHandlerTest < ActiveSupport::TestCase test "does not create stacks for repos what prevent_with_label when label is present" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :prevent_with_label, label: "pull-requests-label", ) diff --git a/test/models/shipit/webhooks/handlers/pull_request/reopened_handler_test.rb b/test/models/shipit/webhooks/handlers/pull_request/reopened_handler_test.rb index 98a601b8b..1112c63aa 100644 --- a/test/models/shipit/webhooks/handlers/pull_request/reopened_handler_test.rb +++ b/test/models/shipit/webhooks/handlers/pull_request/reopened_handler_test.rb @@ -47,7 +47,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase stack = create_archived_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_all, ) @@ -60,7 +60,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase test "provisions missing stacks for repos that allow_all" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_all, ) payload = payload_parsed(:pull_request_reopened) @@ -79,7 +79,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase test "auto-created stack should have pull request assigned" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_all, ) payload = payload_parsed(:pull_request_reopened) @@ -93,7 +93,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase stack = create_archived_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -109,7 +109,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase test "provisions missing stacks for repos that allow_with_label when label is present" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -131,7 +131,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase stack = create_archived_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -147,7 +147,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase stack = create_archived_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -163,7 +163,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase test "provisions missing stacks for repos that prevent_with_label when label is absent" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -185,7 +185,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase stack = create_archived_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :prevent_with_label, label: "pull-requests-label", ) diff --git a/test/models/shipit/webhooks/handlers/pull_request/unlabeled_handler_test.rb b/test/models/shipit/webhooks/handlers/pull_request/unlabeled_handler_test.rb index 489c5504a..cc577d6eb 100644 --- a/test/models/shipit/webhooks/handlers/pull_request/unlabeled_handler_test.rb +++ b/test/models/shipit/webhooks/handlers/pull_request/unlabeled_handler_test.rb @@ -24,7 +24,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase test "ignores Github PullRequest webhooks when the Repository has disabled the Review Stacks feature" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, provisioning_enabled: false, behavior: :allow_with_label, label: "pull-requests-label", @@ -45,7 +45,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -59,7 +59,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -72,7 +72,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase test "ignores Github PullRequest webhooks when the repository allow_with_label to create ReviewStacks and the label is absent" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -86,7 +86,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase stack = create_archived_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -102,7 +102,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase test "creates and provisions a new review stack when the repository creates ReviewStacks with allow_with_label and the label is present" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -124,7 +124,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -140,7 +140,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -155,7 +155,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase test "ignores Github PullRequest webhooks when the repository prevent_with_label to create ReviewStacks and the label is present" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -171,7 +171,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase stack = create_archived_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -187,7 +187,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase test "creates and provisions a new review stack when the repository creates ReviewStacks with prevent_with_label and the label is absent" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -208,7 +208,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase test "assigns the PullRequest to newly created stacks" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -224,7 +224,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase create_archived_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository: repository, + repository:, behavior: :allow_with_label, label: "pull-requests-label", ) diff --git a/test/models/team_test.rb b/test/models/team_test.rb index 14cda9a3b..3260b41a1 100644 --- a/test/models/team_test.rb +++ b/test/models/team_test.rb @@ -35,7 +35,7 @@ class TeamTest < ActiveSupport::TestCase skip unless limit slug = 'a' * 255 - team = new_team(slug: slug) + team = new_team(slug:) response = stub(rels: {}, data: [team]) Shipit.github.api.expects(:org_teams).with('shopify', per_page: 100).returns(response.data) @@ -70,7 +70,7 @@ def new_team(slug: 'new-team') stub( id: 24, name: 'New Team', - slug: slug, + slug:, url: 'https://example.com', description: 'The Best one', organization: 'shopify', diff --git a/test/models/undeployed_commits_test.rb b/test/models/undeployed_commits_test.rb index ddfd6a305..c6c712482 100644 --- a/test/models/undeployed_commits_test.rb +++ b/test/models/undeployed_commits_test.rb @@ -44,7 +44,7 @@ class UndeployedCommitsTest < ActiveSupport::TestCase test "#expected_to_be_deployed? returns true if the stack has continuous deployment enabled, next expected commit to deploy id is greater or equals to the commit id and commit is not active" do commit = shipit_commits(:undeployed_4) next_expected_commit_to_deploy = commit.stack.next_expected_commit_to_deploy - undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy: next_expected_commit_to_deploy) + undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy:) refute_predicate next_expected_commit_to_deploy, :nil? assert_predicate undeployed_commit.stack, :continuous_deployment @@ -57,7 +57,7 @@ class UndeployedCommitsTest < ActiveSupport::TestCase test "#expected_to_be_deployed? returns true if the active task has no commit range" do commit = shipit_commits(:task_no_commits) next_expected_commit_to_deploy = commit.stack.next_expected_commit_to_deploy - undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy: next_expected_commit_to_deploy) + undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy:) refute_predicate next_expected_commit_to_deploy, :nil? assert_predicate undeployed_commit.stack, :continuous_deployment @@ -70,7 +70,7 @@ class UndeployedCommitsTest < ActiveSupport::TestCase test "#expected_to_be_deployed? returns false if the stack has continuous deployment disabled" do commit = shipit_commits(:cyclimse_first) next_expected_commit_to_deploy = commit.stack.next_expected_commit_to_deploy - undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy: next_expected_commit_to_deploy) + undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy:) refute_predicate next_expected_commit_to_deploy, :nil? refute_predicate undeployed_commit.stack, :continuous_deployment @@ -83,7 +83,7 @@ class UndeployedCommitsTest < ActiveSupport::TestCase test "#expected_to_be_deployed? returns false if the commit is part of the active task" do commit = shipit_commits(:undeployed_3) next_expected_commit_to_deploy = commit.stack.next_expected_commit_to_deploy - undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy: next_expected_commit_to_deploy) + undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy:) refute_predicate next_expected_commit_to_deploy, :nil? assert_predicate undeployed_commit.stack, :continuous_deployment @@ -103,7 +103,7 @@ class UndeployedCommitsTest < ActiveSupport::TestCase test "#expected_to_be_deployed? returns false if the commit has an id greater than next commit to deploy" do commit = shipit_commits(:undeployed_7) next_expected_commit_to_deploy = commit.stack.next_expected_commit_to_deploy - undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy: next_expected_commit_to_deploy) + undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy:) refute_predicate next_expected_commit_to_deploy, :nil? assert_predicate undeployed_commit.stack, :continuous_deployment From 01e0da45130c69734c8fd5521dc5f7be44bed3d2 Mon Sep 17 00:00:00 2001 From: Kartiki Sharma Date: Mon, 22 Jan 2024 12:02:46 -0500 Subject: [PATCH 22/23] Revert "Fix rubocop errors: autocorrect" This reverts commit 46bf11efc5f711700d31d0cb961bd5c55d7e4bf0. --- .../concerns/shipit/api/paginable.rb | 4 +- app/controllers/concerns/shipit/pagination.rb | 4 +- .../shipit/api/ccmenu_controller.rb | 2 +- .../shipit/api/hooks_controller.rb | 2 +- .../shipit/api/stacks_controller.rb | 2 +- .../shipit/commit_checks_controller.rb | 2 +- .../shipit/merge_status_controller.rb | 2 +- app/controllers/shipit/stacks_controller.rb | 8 +-- app/helpers/shipit/chunks_helper.rb | 2 +- app/helpers/shipit/deploys_helper.rb | 6 +- app/helpers/shipit/stacks_helper.rb | 2 +- app/jobs/shipit/github_sync_job.rb | 4 +- .../update_github_last_deployed_ref_job.rb | 4 +- app/models/shipit/check_run.rb | 4 +- app/models/shipit/commit.rb | 18 ++--- app/models/shipit/commit_checks.rb | 2 +- app/models/shipit/deploy.rb | 22 +++--- app/models/shipit/ephemeral_commit_checks.rb | 4 +- app/models/shipit/hook.rb | 2 +- app/models/shipit/merge_request.rb | 6 +- app/models/shipit/pull_request.rb | 2 +- app/models/shipit/release_status.rb | 2 +- app/models/shipit/stack.rb | 20 +++--- app/models/shipit/status.rb | 2 +- app/models/shipit/status/missing.rb | 2 +- app/models/shipit/task.rb | 6 +- app/models/shipit/task_definition.rb | 10 +-- app/models/shipit/team.rb | 8 +-- app/models/shipit/user.rb | 8 +-- .../pull_request/review_stack_adapter.rb | 4 +- .../shipit/webhooks/handlers/push_handler.rb | 2 +- lib/shipit.rb | 2 +- lib/shipit/flock.rb | 2 +- lib/shipit/github_app.rb | 4 +- lib/shipit/stack_commands.rb | 14 ++-- lib/shipit/task_commands.rb | 4 +- lib/tasks/shipit.rake | 4 +- .../controllers/api/stacks_controller_test.rb | 2 +- test/controllers/api/tasks_controller_test.rb | 6 +- test/controllers/deploys_controller_test.rb | 2 +- test/controllers/rollbacks_controller_test.rb | 2 +- test/controllers/tasks_controller_test.rb | 2 +- test/controllers/webhooks_controller_test.rb | 4 +- test/helpers/json_helper.rb | 6 +- test/jobs/chunk_rollup_job_test.rb | 4 +- test/jobs/github_sync_job_test.rb | 4 +- test/models/commits_test.rb | 2 +- test/models/delivery_test.rb | 2 +- test/models/deploys_test.rb | 72 +++++++++---------- test/models/merge_request_test.rb | 4 +- test/models/shipit/check_run_test.rb | 16 ++--- test/models/shipit/repository_test.rb | 2 +- test/models/shipit/stack_test.rb | 14 ++-- .../pull_request/closed_handler_test.rb | 10 +-- .../pull_request/labeled_handler_test.rb | 28 ++++---- .../pull_request/opened_handler_test.rb | 12 ++-- .../pull_request/reopened_handler_test.rb | 18 ++--- .../pull_request/unlabeled_handler_test.rb | 26 +++---- test/models/team_test.rb | 4 +- test/models/undeployed_commits_test.rb | 10 +-- 60 files changed, 225 insertions(+), 225 deletions(-) diff --git a/app/controllers/concerns/shipit/api/paginable.rb b/app/controllers/concerns/shipit/api/paginable.rb index da484e29b..73c2d9a22 100644 --- a/app/controllers/concerns/shipit/api/paginable.rb +++ b/app/controllers/concerns/shipit/api/paginable.rb @@ -24,8 +24,8 @@ def render_resources(resource, *) resource, self, order: default_order, - max_page_size:, - default_page_size:, + max_page_size: max_page_size, + default_page_size: default_page_size, ) headers[LINK] = render_links(paginator.links) super(paginator.to_a) diff --git a/app/controllers/concerns/shipit/pagination.rb b/app/controllers/concerns/shipit/pagination.rb index 355dc53d3..dbce8919e 100644 --- a/app/controllers/concerns/shipit/pagination.rb +++ b/app/controllers/concerns/shipit/pagination.rb @@ -21,8 +21,8 @@ def paginate(relation) relation, self, order: default_order, - max_page_size:, - default_page_size:, + max_page_size: max_page_size, + default_page_size: default_page_size, ) end end diff --git a/app/controllers/shipit/api/ccmenu_controller.rb b/app/controllers/shipit/api/ccmenu_controller.rb index b67f4b79f..6c91596c0 100644 --- a/app/controllers/shipit/api/ccmenu_controller.rb +++ b/app/controllers/shipit/api/ccmenu_controller.rb @@ -21,7 +21,7 @@ def running? def show latest_deploy = stack.deploys_and_rollbacks.last || NoDeploy.new - render('shipit/ccmenu/project', formats: [:xml], locals: { stack:, deploy: latest_deploy }) + render('shipit/ccmenu/project', formats: [:xml], locals: { stack: stack, deploy: latest_deploy }) end private diff --git a/app/controllers/shipit/api/hooks_controller.rb b/app/controllers/shipit/api/hooks_controller.rb index 71d895e79..1ffd63c21 100644 --- a/app/controllers/shipit/api/hooks_controller.rb +++ b/app/controllers/shipit/api/hooks_controller.rb @@ -44,7 +44,7 @@ def hook end def hooks - Hook.where(stack_id:) + Hook.where(stack_id: stack_id) end def stack_id diff --git a/app/controllers/shipit/api/stacks_controller.rb b/app/controllers/shipit/api/stacks_controller.rb index fc4543a73..eae87a8c6 100644 --- a/app/controllers/shipit/api/stacks_controller.rb +++ b/app/controllers/shipit/api/stacks_controller.rb @@ -15,7 +15,7 @@ def index if params[:repo_owner] && params[:repo_name] full_repo_name = [repo_owner, repo_name].join('/') @stacks = if (repository = Repository.from_github_repo_name(full_repo_name)) - stacks.where(repository:) + stacks.where(repository: repository) else Stack.none end diff --git a/app/controllers/shipit/commit_checks_controller.rb b/app/controllers/shipit/commit_checks_controller.rb index 422111ef7..012193b5a 100644 --- a/app/controllers/shipit/commit_checks_controller.rb +++ b/app/controllers/shipit/commit_checks_controller.rb @@ -17,7 +17,7 @@ def tail url = stack_tail_commit_checks_path(stack, sha: commit.sha, since: next_offset) end - render(json: { url:, output:, status: checks.status }) + render(json: { url: url, output: output, status: checks.status }) end private diff --git a/app/controllers/shipit/merge_status_controller.rb b/app/controllers/shipit/merge_status_controller.rb index c32f6dd89..fb4a51e65 100644 --- a/app/controllers/shipit/merge_status_controller.rb +++ b/app/controllers/shipit/merge_status_controller.rb @@ -45,7 +45,7 @@ def check render(plain: stack_status, status: 503) end end - format.json { render(json: { stack_status: }) } + format.json { render(json: { stack_status: stack_status }) } end end diff --git a/app/controllers/shipit/stacks_controller.rb b/app/controllers/shipit/stacks_controller.rb index 72cb7c5d7..3bfa19c4a 100644 --- a/app/controllers/shipit/stacks_controller.rb +++ b/app/controllers/shipit/stacks_controller.rb @@ -38,7 +38,7 @@ def show scope.preload(:author, :statuses, :check_runs, :lock_author) end - next_expected_commit_to_deploy = @stack.next_expected_commit_to_deploy(commits:) + next_expected_commit_to_deploy = @stack.next_expected_commit_to_deploy(commits: commits) @active_commits = [] @undeployed_commits = [] @@ -49,11 +49,11 @@ def show @active_commits = map_to_undeployed_commit( @active_commits, - next_expected_commit_to_deploy:, + next_expected_commit_to_deploy: next_expected_commit_to_deploy, ) @undeployed_commits = map_to_undeployed_commit( @undeployed_commits, - next_expected_commit_to_deploy:, + next_expected_commit_to_deploy: next_expected_commit_to_deploy, ) end @@ -146,7 +146,7 @@ def update_archived def map_to_undeployed_commit(commits, next_expected_commit_to_deploy:) commits.map.with_index do |c, i| index = commits.size - i - 1 - UndeployedCommit.new(c, index:, next_expected_commit_to_deploy:) + UndeployedCommit.new(c, index: index, next_expected_commit_to_deploy: next_expected_commit_to_deploy) end end diff --git a/app/helpers/shipit/chunks_helper.rb b/app/helpers/shipit/chunks_helper.rb index 61ba3d240..e8b9912db 100644 --- a/app/helpers/shipit/chunks_helper.rb +++ b/app/helpers/shipit/chunks_helper.rb @@ -5,7 +5,7 @@ module ChunksHelper def next_chunks_url(task, last_byte: 0) return if task.finished? - tail_stack_task_path(task.stack, task, last_byte:) + tail_stack_task_path(task.stack, task, last_byte: last_byte) end end end diff --git a/app/helpers/shipit/deploys_helper.rb b/app/helpers/shipit/deploys_helper.rb index c9fb6aa47..0dbbdedf7 100644 --- a/app/helpers/shipit/deploys_helper.rb +++ b/app/helpers/shipit/deploys_helper.rb @@ -5,19 +5,19 @@ module DeploysHelper def render_checklist(checklist) return if checklist.blank? - render('shipit/deploys/checklist', checklist:) + render('shipit/deploys/checklist', checklist: checklist) end def render_monitoring(stack) return unless stack.monitoring? - render('shipit/deploys/monitoring', stack:) + render('shipit/deploys/monitoring', stack: stack) end def render_checks(commit) return unless commit.stack.checks? - render('shipit/commit_checks/checks', commit:) + render('shipit/commit_checks/checks', commit: commit) end def render_monitoring_panel(panel_spec) diff --git a/app/helpers/shipit/stacks_helper.rb b/app/helpers/shipit/stacks_helper.rb index 6b728d663..55069c8a6 100644 --- a/app/helpers/shipit/stacks_helper.rb +++ b/app/helpers/shipit/stacks_helper.rb @@ -34,7 +34,7 @@ def deploy_button(commit) data[:tooltip] = t('deploy_button.hint.max_commits', maximum: commit.stack.maximum_commits_per_deploy) end - link_to(t("deploy_button.caption.#{deploy_state}"), url, class: classes, data:) + link_to(t("deploy_button.caption.#{deploy_state}"), url, class: classes, data: data) end def rollback_button(deploy) diff --git a/app/jobs/shipit/github_sync_job.rb b/app/jobs/shipit/github_sync_job.rb index 6dd7ecc5a..f4158ddcb 100644 --- a/app/jobs/shipit/github_sync_job.rb +++ b/app/jobs/shipit/github_sync_job.rb @@ -37,7 +37,7 @@ def append_commit(gh_commit) def fetch_missing_commits(&block) commits = [] github_api = stack&.github_api - iterator = Shipit::FirstParentCommitsIterator.new(github_api:, &block) + iterator = Shipit::FirstParentCommitsIterator.new(github_api: github_api, &block) iterator.each_with_index do |commit, index| break if index >= MAX_FETCHED_COMMITS @@ -61,7 +61,7 @@ def handle_github_errors end def lookup_commit(sha) - stack.commits.find_by(sha:) + stack.commits.find_by(sha: sha) end end end diff --git a/app/jobs/shipit/update_github_last_deployed_ref_job.rb b/app/jobs/shipit/update_github_last_deployed_ref_job.rb index 83ad32a5d..ea9be27da 100644 --- a/app/jobs/shipit/update_github_last_deployed_ref_job.rb +++ b/app/jobs/shipit/update_github_last_deployed_ref_job.rb @@ -18,7 +18,7 @@ def perform(stack) full_repo_name = stack.github_repo_name - update_or_create_ref(client:, repo_name: full_repo_name, ref: stack_ref, new_sha: stack_sha) + update_or_create_ref(client: client, repo_name: full_repo_name, ref: stack_ref, new_sha: stack_sha) end private @@ -36,7 +36,7 @@ def update_or_create_ref(client:, repo_name:, ref:, new_sha:) rescue Octokit::UnprocessableEntity => e error_msg = e.message if error_msg.include?("Reference does not exist") - create_ref(client:, repo_name:, ref:, sha: new_sha) + create_ref(client: client, repo_name: repo_name, ref: ref, sha: new_sha) else raise end diff --git a/app/models/shipit/check_run.rb b/app/models/shipit/check_run.rb index b795a3398..d0631f3c2 100644 --- a/app/models/shipit/check_run.rb +++ b/app/models/shipit/check_run.rb @@ -42,7 +42,7 @@ def create_or_update_from_github!(stack_id, github_check_run) unless checkrun_date Rails.logger.warn("No valid timestamp found in checkrun data. Checkrun id: #{github_check_run.id}.") - RefreshCheckRunsJob.set(wait: CHECK_RUN_REFRESH_DELAY).perform_later(stack_id:) + RefreshCheckRunsJob.set(wait: CHECK_RUN_REFRESH_DELAY).perform_later(stack_id: stack_id) return end @@ -51,7 +51,7 @@ def create_or_update_from_github!(stack_id, github_check_run) github_id: github_check_run.id, }, attributes: { - stack_id:, + stack_id: stack_id, name: github_check_run.name, conclusion: github_check_run.conclusion, title: github_check_run.output.title.to_s.truncate(1_000), diff --git a/app/models/shipit/commit.rb b/app/models/shipit/commit.rb index cadc58e9b..f8d90d936 100644 --- a/app/models/shipit/commit.rb +++ b/app/models/shipit/commit.rb @@ -122,8 +122,8 @@ def from_github(commit) record = new( sha: commit.sha, message: commit.commit.message, - author:, - committer:, + author: author, + committer: committer, committed_at: commit.commit.committer.date, authored_at: commit.commit.author.date, additions: commit.stats&.additions, @@ -213,11 +213,11 @@ def create_release_status!(state, user: nil, target_url: nil, description: nil) @last_release_status = nil release_statuses.create!( - stack:, - user:, - state:, - target_url:, - description:, + stack: stack, + user: user, + state: state, + target_url: target_url, + description: description, ) end @@ -246,7 +246,7 @@ def blocked? end def children - self.class.where(stack_id:).newer_than(self) + self.class.where(stack_id: stack_id).newer_than(self) end def detach_children! @@ -374,7 +374,7 @@ def add_status new_status = status unless already_deployed - payload = { commit: self, stack:, status: new_status.state } + payload = { commit: self, stack: stack, status: new_status.state } if previous_status != new_status Hook.emit(:commit_status, stack, payload.merge(commit_status: new_status)) end diff --git a/app/models/shipit/commit_checks.rb b/app/models/shipit/commit_checks.rb index d2a4fda23..7b56bc95b 100644 --- a/app/models/shipit/commit_checks.rb +++ b/app/models/shipit/commit_checks.rb @@ -23,7 +23,7 @@ def schedule initialize_redis_state end - PerformCommitChecksJob.perform_later(commit:) + PerformCommitChecksJob.perform_later(commit: commit) true end diff --git a/app/models/shipit/deploy.rb b/app/models/shipit/deploy.rb index 87a508ead..5b20bb026 100644 --- a/app/models/shipit/deploy.rb +++ b/app/models/shipit/deploy.rb @@ -13,7 +13,7 @@ class Deploy < Task after_transition to: :aborted, do: :trigger_revert_if_required after_transition any => any, do: :update_release_status after_transition any => any, do: :update_commit_deployments - after_transition any:, do: :update_last_deploy_time + after_transition any => any, do: :update_last_deploy_time end belongs_to :until_commit, class_name: 'Commit', required: true @@ -92,10 +92,10 @@ def until(deploy) def build_rollback(user = nil, env: nil, force: false) Rollback.new( user_id: user&.id, - stack_id:, + stack_id: stack_id, parent_id: id, since_commit: stack.last_deployed_commit, - until_commit:, + until_commit: until_commit, env: env&.to_h || {}, allow_concurrency: force, ignored_safeties: force, @@ -105,14 +105,14 @@ def build_rollback(user = nil, env: nil, force: false) # Rolls the stack back to this deploy def trigger_rollback(user = AnonymousUser.new, env: nil, force: false, lock: true) - rollback = build_rollback(user, env:, force:) + rollback = build_rollback(user, env: env, force: force) rollback.save! rollback.enqueue if lock lock_reason = "A rollback for #{rollback.since_commit.sha} has been triggered. " \ "Please make sure the reason for the rollback has been addressed before deploying again." - stack.update!(lock_reason:, lock_author_id: user.id) + stack.update!(lock_reason: lock_reason, lock_author_id: user.id) end rollback @@ -123,8 +123,8 @@ def trigger_revert(force: false, rollback_to: nil) previous_successful_commit = rollback_to&.until_commit || commit_to_rollback_to rollback = Rollback.create!( - user_id:, - stack_id:, + user_id: user_id, + stack_id: stack_id, parent_id: id, since_commit: until_commit, until_commit: previous_successful_commit, @@ -134,7 +134,7 @@ def trigger_revert(force: false, rollback_to: nil) rollback.enqueue lock_reason = "A rollback for #{until_commit.sha} has been triggered. " \ "Please make sure the reason for the rollback has been addressed before deploying again." - stack.update!(lock_reason:, lock_author_id: user_id) + stack.update!(lock_reason: lock_reason, lock_author_id: user_id) stack.emit_lock_hooks rollback end @@ -211,7 +211,7 @@ def append_release_status(state, description, user: self.user) state, user: user.presence, target_url: permalink, - description:, + description: description, ) status end @@ -234,7 +234,7 @@ def report_healthy!(user: self.user, description: "@#{user.login} signaled this append_release_status( 'success', description, - user:, + user: user, ) end end @@ -245,7 +245,7 @@ def report_faulty!(user: self.user, description: "@#{user.login} signaled this r append_release_status( 'failure', description, - user:, + user: user, ) end end diff --git a/app/models/shipit/ephemeral_commit_checks.rb b/app/models/shipit/ephemeral_commit_checks.rb index d3d253d59..38f191171 100644 --- a/app/models/shipit/ephemeral_commit_checks.rb +++ b/app/models/shipit/ephemeral_commit_checks.rb @@ -14,7 +14,7 @@ def initialize(commit) def run self.status = 'running' commands = StackCommands.new(stack) - commands.with_temporary_working_directory(commit:) do |directory| + commands.with_temporary_working_directory(commit: commit) do |directory| deploy_spec = DeploySpec::FileSystem.new(directory, stack.environment) capture_all(build_commands(deploy_spec.dependencies_steps, chdir: directory)) capture_all(build_commands(deploy_spec.review_checks, chdir: directory)) @@ -47,7 +47,7 @@ def write(output) private def build_commands(commands, chdir:) - commands.map { |c| Command.new(c, env: Shipit.env, chdir:) } + commands.map { |c| Command.new(c, env: Shipit.env, chdir: chdir) } end def capture_all(commands) diff --git a/app/models/shipit/hook.rb b/app/models/shipit/hook.rb index bb5fd2872..8c7ae695c 100644 --- a/app/models/shipit/hook.rb +++ b/app/models/shipit/hook.rb @@ -144,7 +144,7 @@ def deliver!(event, payload) url: delivery_url, content_type: CONTENT_TYPES[content_type], payload: serialize_payload(payload), - secret:, + secret: secret, ) end diff --git a/app/models/shipit/merge_request.rb b/app/models/shipit/merge_request.rb index d9ee6a111..fa9208dc5 100644 --- a/app/models/shipit/merge_request.rb +++ b/app/models/shipit/merge_request.rb @@ -131,8 +131,8 @@ def request_merge!(stack, number, user) merge_requested_at: now, merge_requested_by: user.presence, ).find_or_create_by!( - stack:, - number:, + stack: stack, + number: number, ) rescue ActiveRecord::RecordNotUnique retry @@ -298,7 +298,7 @@ def emit_hooks return unless @merge_status_changed @merge_status_changed = nil - Hook.emit('merge', stack, merge_request: self, status: merge_status, stack:) + Hook.emit('merge', stack, merge_request: self, status: merge_status, stack: stack) end def find_or_create_commit_from_github_by_sha!(sha, attributes) diff --git a/app/models/shipit/pull_request.rb b/app/models/shipit/pull_request.rb index a8c25abb2..0083ad9c0 100644 --- a/app/models/shipit/pull_request.rb +++ b/app/models/shipit/pull_request.rb @@ -30,7 +30,7 @@ def emit_update_hooks end def emit_hooks(reason) - Hook.emit('pull_request', stack, action: reason, pull_request: self, stack:) + Hook.emit('pull_request', stack, action: reason, pull_request: self, stack: stack) end def github_pull_request=(github_pull_request) diff --git a/app/models/shipit/release_status.rb b/app/models/shipit/release_status.rb index 83a46c6bb..314b24b91 100644 --- a/app/models/shipit/release_status.rb +++ b/app/models/shipit/release_status.rb @@ -31,7 +31,7 @@ def create_status_on_github commit.sha, state, context: stack.release_status_context, - target_url:, + target_url: target_url, description: description&.truncate(MAX_DESCRIPTION_LENGTH), ) end diff --git a/app/models/shipit/stack.rb b/app/models/shipit/stack.rb index 66ad7503e..75a33ab09 100644 --- a/app/models/shipit/stack.rb +++ b/app/models/shipit/stack.rb @@ -133,7 +133,7 @@ def run_deploy_in_foreground(stack:, revision:) env = stack.cached_deploy_spec.default_deploy_env current_user = Shipit::CommandLineUser.new - stack.trigger_deploy(until_commit, current_user, env:, force: true, run_now: true) + stack.trigger_deploy(until_commit, current_user, env: env, force: true, run_now: true) end def from_param!(param) @@ -144,7 +144,7 @@ def from_param!(param) owner: repo_owner.downcase, name: repo_name.downcase, }, - environment:, + environment: environment, ).first! end end @@ -164,7 +164,7 @@ def trigger_task(definition_id, user, env: nil, force: false) commit = last_deployed_commit.presence || commits.first task = tasks.create( user_id: user.id, - definition:, + definition: definition, until_commit_id: commit.id, since_commit_id: commit.id, env: definition.filter_envs(env), @@ -179,8 +179,8 @@ def build_deploy(until_commit, user, env: nil, force: false) since_commit = last_deployed_commit.presence || commits.first deploys.build( user_id: user.id, - until_commit:, - since_commit:, + until_commit: until_commit, + since_commit: since_commit, env: filter_deploy_envs(env&.to_h || {}), allow_concurrency: force, ignored_safeties: force || !until_commit.deployable?, @@ -304,7 +304,7 @@ def head def merge_status(backlog_leniency_factor: 2.0) return 'locked' if locked? return 'failure' if %w(failure error).freeze.include?(branch_status) - return 'backlogged' if backlogged?(backlog_leniency_factor:) + return 'backlogged' if backlogged?(backlog_leniency_factor: backlog_leniency_factor) 'success' end @@ -424,7 +424,7 @@ def git_path def acquire_git_cache_lock(timeout: 15, &block) @git_cache_lock ||= Flock.new(git_path.to_s + '.lock') - @git_cache_lock.lock(timeout:, &block) + @git_cache_lock.lock(timeout: timeout, &block) end def clear_git_cache! @@ -569,7 +569,7 @@ def update_latest_deployed_ref def broadcast_update Pubsubstub.publish( "stack.#{id}", - { id:, updated_at: }.to_json, + { id: id, updated_at: updated_at }.to_json, name: 'update', ) end @@ -645,7 +645,7 @@ def emit_lock_hooks { from: previous_changes['locked_since'].first, until: Time.zone.now } end - Hook.emit(:lock, self, locked: locked?, lock_details:, stack: self) + Hook.emit(:lock, self, locked: locked?, lock_details: lock_details, stack: self) end private @@ -699,7 +699,7 @@ def emit_removed_hooks end def emit_merge_status_hooks - Hook.emit(:merge_status, self, merge_status:, stack: self) + Hook.emit(:merge_status, self, merge_status: merge_status, stack: self) end def ci_enabled_cache_key diff --git a/app/models/shipit/status.rb b/app/models/shipit/status.rb index be089eb69..050ddeb93 100644 --- a/app/models/shipit/status.rb +++ b/app/models/shipit/status.rb @@ -23,7 +23,7 @@ class Status < Record class << self def replicate_from_github!(stack_id, github_status) find_or_create_by!( - stack_id:, + stack_id: stack_id, state: github_status.state, description: github_status.description, target_url: github_status.target_url, diff --git a/app/models/shipit/status/missing.rb b/app/models/shipit/status/missing.rb index 31b3f0327..128fb7163 100644 --- a/app/models/shipit/status/missing.rb +++ b/app/models/shipit/status/missing.rb @@ -25,7 +25,7 @@ def missing? end def description - I18n.t('missing_status.description', context:) + I18n.t('missing_status.description', context: context) end def to_partial_path diff --git a/app/models/shipit/task.rb b/app/models/shipit/task.rb index bbebbe5e7..057d364f9 100644 --- a/app/models/shipit/task.rb +++ b/app/models/shipit/task.rb @@ -358,8 +358,8 @@ def request_abort def abort!(rollback_once_aborted: false, rollback_once_aborted_to: nil, aborted_by:) update!( - rollback_once_aborted:, - rollback_once_aborted_to:, + rollback_once_aborted: rollback_once_aborted, + rollback_once_aborted_to: rollback_once_aborted_to, aborted_by_id: aborted_by.id, ) @@ -395,7 +395,7 @@ def emit_hooks_if_status_changed end def emit_hooks - Hook.emit(hook_event, stack, hook_event => self, status:, stack:) + Hook.emit(hook_event, stack, hook_event => self, status: status, stack: stack) end def hook_event diff --git a/app/models/shipit/task_definition.rb b/app/models/shipit/task_definition.rb index 25e23b6d6..950baa035 100644 --- a/app/models/shipit/task_definition.rb +++ b/app/models/shipit/task_definition.rb @@ -49,13 +49,13 @@ def allow_concurrency? def as_json { - id:, - action:, + id: id, + action: action, title: @title, - description:, - steps:, + description: description, + steps: steps, variables: variables.map(&:to_h), - checklist:, + checklist: checklist, allow_concurrency: allow_concurrency?, } end diff --git a/app/models/shipit/team.rb b/app/models/shipit/team.rb index e74c0706c..73664bcf6 100644 --- a/app/models/shipit/team.rb +++ b/app/models/shipit/team.rb @@ -17,17 +17,17 @@ class Team < Record class << self def find_or_create_by_handle(handle) organization, slug = handle.split('/').map(&:downcase) - find_by(organization:, slug:) || fetch_and_create_from_github(organization, slug) + find_by(organization: organization, slug: slug) || fetch_and_create_from_github(organization, slug) end def fetch_and_create_from_github(organization, slug) if github_team = find_team_on_github(organization, slug) - create!(github_team:, organization:) + create!(github_team: github_team, organization: organization) end end def find_team_on_github(organization, slug) - gh_api = Shipit.github(organization:).api + gh_api = Shipit.github(organization: organization).api teams = Shipit::OctokitIterator.new(github_api: gh_api) { gh_api.org_teams(organization, per_page: 100) } teams.find { |t| t.slug == slug } rescue Octokit::NotFound @@ -43,7 +43,7 @@ def add_member(member) end def refresh_members! - github_api = Shipit.github(organization:).api + github_api = Shipit.github(organization: organization).api github_members = Shipit::OctokitIterator.new(github_api.get(api_url).rels[:members]) members = github_members.map { |u| User.find_or_create_from_github(u) } self.members = members diff --git a/app/models/shipit/user.rb b/app/models/shipit/user.rb index 40c0e5770..e1bd904c3 100644 --- a/app/models/shipit/user.rb +++ b/app/models/shipit/user.rb @@ -21,7 +21,7 @@ class User < Record class << self def find_or_create_by_login!(login) - find_or_create_by!(login:) do |user| + find_or_create_by!(login: login) do |user| # Users are global, any app can be used # This will not work for users that only exist in an Enterprise install user.github_user = Shipit.github.api.user(login) @@ -55,7 +55,7 @@ def find_from_github(github_user) end def create_from_github(github_user) - create(github_user:) + create(github_user: github_user) end def refresh_shard(shard_index, shards_count) @@ -72,7 +72,7 @@ def github_api end def identifiers_for_ping - { github_id:, name:, email:, github_login: login } + { github_id: github_id, name: name, email: email, github_login: login } end def logged_in? @@ -92,7 +92,7 @@ def repositories_contributed_to def stacks_contributed_to return [] unless id - Commit.where('author_id = :id or committer_id = :id', id:).distinct.pluck(:stack_id) + Commit.where('author_id = :id or committer_id = :id', id: id).distinct.pluck(:stack_id) end def refresh_from_github! diff --git a/app/models/shipit/webhooks/handlers/pull_request/review_stack_adapter.rb b/app/models/shipit/webhooks/handlers/pull_request/review_stack_adapter.rb index aed2ceca2..87c538e67 100644 --- a/app/models/shipit/webhooks/handlers/pull_request/review_stack_adapter.rb +++ b/app/models/shipit/webhooks/handlers/pull_request/review_stack_adapter.rb @@ -13,7 +13,7 @@ def initialize(params, scope: Shipit::ReviewStack) end def stack - @stack ||= scope.find_by(environment:) + @stack ||= scope.find_by(environment: environment) end def find_or_create! @@ -87,7 +87,7 @@ def create! def stack_attributes { branch: params.pull_request.head.ref, - environment:, + environment: environment, ignore_ci: false, continuous_deployment: false, } diff --git a/app/models/shipit/webhooks/handlers/push_handler.rb b/app/models/shipit/webhooks/handlers/push_handler.rb index 7464dbff1..34ca8f067 100644 --- a/app/models/shipit/webhooks/handlers/push_handler.rb +++ b/app/models/shipit/webhooks/handlers/push_handler.rb @@ -10,7 +10,7 @@ class PushHandler < Handler def process stacks .not_archived - .where(branch:) + .where(branch: branch) .find_each(&:sync_github) end diff --git a/lib/shipit.rb b/lib/shipit.rb index d471f2fad..41e216020 100644 --- a/lib/shipit.rb +++ b/lib/shipit.rb @@ -150,7 +150,7 @@ def dump(object) self.database_serializer = TransitionalSerializer def serialized_column(attribute_name, type: nil, coder: nil) - column = Paquito::SerializedColumn.new(database_serializer, type, attribute_name:) + column = Paquito::SerializedColumn.new(database_serializer, type, attribute_name: attribute_name) if coder Paquito.chain(coder, column) else diff --git a/lib/shipit/flock.rb b/lib/shipit/flock.rb index f3ccd4b3a..dfbafcfbf 100644 --- a/lib/shipit/flock.rb +++ b/lib/shipit/flock.rb @@ -20,7 +20,7 @@ def lock(timeout:) path.parent.mkpath path.open('w') do |file| - if retrying(timeout:) { file.flock(File::LOCK_EX | File::LOCK_NB) } + if retrying(timeout: timeout) { file.flock(File::LOCK_EX | File::LOCK_NB) } file.write($PROCESS_ID.to_s) @acquired = true begin diff --git a/lib/shipit/github_app.rb b/lib/shipit/github_app.rb index 1e77bb497..d7c3f58a7 100644 --- a/lib/shipit/github_app.rb +++ b/lib/shipit/github_app.rb @@ -156,8 +156,8 @@ def enterprise? def new_client(options = {}) if enterprise? options = options.reverse_merge( - api_endpoint:, - web_endpoint:, + api_endpoint: api_endpoint, + web_endpoint: web_endpoint, ) end client = Octokit::Client.new(options) diff --git a/lib/shipit/stack_commands.rb b/lib/shipit/stack_commands.rb index 0b6e242e8..88af63d68 100644 --- a/lib/shipit/stack_commands.rb +++ b/lib/shipit/stack_commands.rb @@ -17,26 +17,26 @@ def env def fetch_commit(commit) create_directories if valid_git_repository?(@stack.git_path) - git('fetch', 'origin', '--quiet', '--tags', commit.sha, env:, chdir: @stack.git_path) + git('fetch', 'origin', '--quiet', '--tags', commit.sha, env: env, chdir: @stack.git_path) else @stack.clear_git_cache! - git_clone(@stack.repo_git_url, @stack.git_path, branch: @stack.branch, env:, chdir: @stack.deploys_path) + git_clone(@stack.repo_git_url, @stack.git_path, branch: @stack.branch, env: env, chdir: @stack.deploys_path) end end def fetch create_directories if valid_git_repository?(@stack.git_path) - git('fetch', 'origin', '--quiet', '--tags', @stack.branch, env:, chdir: @stack.git_path) + git('fetch', 'origin', '--quiet', '--tags', @stack.branch, env: env, chdir: @stack.git_path) else @stack.clear_git_cache! - git_clone(@stack.repo_git_url, @stack.git_path, branch: @stack.branch, env:, chdir: @stack.deploys_path) + git_clone(@stack.repo_git_url, @stack.git_path, branch: @stack.branch, env: env, chdir: @stack.deploys_path) end end def fetched?(commit) if valid_git_repository?(@stack.git_path) - git('rev-parse', '--quiet', '--verify', "#{commit.sha}^{commit}", env:, chdir: @stack.git_path) + git('rev-parse', '--quiet', '--verify', "#{commit.sha}^{commit}", env: env, chdir: @stack.git_path) else # When the stack's git cache is not valid, the commit is # NOT fetched. To keep the interface of this method @@ -44,7 +44,7 @@ def fetched?(commit) # method returns false - has a non-zero exit status. We utilize # the POSIX 'test' command with no arguments which should # always have an exit status of 1. - Command.new('test', env:, chdir: @stack.deploys_path) + Command.new('test', env: env, chdir: @stack.deploys_path) end end @@ -52,7 +52,7 @@ def fetch_deployed_revision with_temporary_working_directory(commit: @stack.commits.reachable.last) do |dir| spec = DeploySpec::FileSystem.new(dir, @stack.environment) outputs = spec.fetch_deployed_revision_steps!.map do |command_line| - Command.new(command_line, env:, chdir: dir).run + Command.new(command_line, env: env, chdir: dir).run end outputs.find(&:present?).try(:strip) end diff --git a/lib/shipit/task_commands.rb b/lib/shipit/task_commands.rb index b251d5c29..5e99a604b 100644 --- a/lib/shipit/task_commands.rb +++ b/lib/shipit/task_commands.rb @@ -16,13 +16,13 @@ def deploy_spec def install_dependencies deploy_spec.dependencies_steps!.map do |command_line| - Command.new(command_line, env:, chdir: steps_directory) + Command.new(command_line, env: env, chdir: steps_directory) end end def perform steps.map do |command_line| - Command.new(command_line, env:, chdir: steps_directory) + Command.new(command_line, env: env, chdir: steps_directory) end end diff --git a/lib/tasks/shipit.rake b/lib/tasks/shipit.rake index 6fe922249..7d6f94dcd 100644 --- a/lib/tasks/shipit.rake +++ b/lib/tasks/shipit.rake @@ -13,12 +13,12 @@ namespace :shipit do class Task def write(text) p(text) - chunks.create!(text:) + chunks.create!(text: text) end end end - Shipit::Stack.run_deploy_in_foreground(stack:, revision:) + Shipit::Stack.run_deploy_in_foreground(stack: stack, revision: revision) rescue ArgumentError p("Use this command as follows:") p("bundle exec rake shipit:deploy stack='shopify/shipit/production' revision='$SHA'") diff --git a/test/controllers/api/stacks_controller_test.rb b/test/controllers/api/stacks_controller_test.rb index e376c3112..321b2f806 100644 --- a/test/controllers/api/stacks_controller_test.rb +++ b/test/controllers/api/stacks_controller_test.rb @@ -42,7 +42,7 @@ class StacksControllerTest < ApiControllerTestCase test "#create fails to create stack if it already exists" do repository = shipit_repositories(:rails) existing_stack = Stack.create!( - repository:, + repository: repository, environment: 'staging', branch: 'staging', ) diff --git a/test/controllers/api/tasks_controller_test.rb b/test/controllers/api/tasks_controller_test.rb index 3fe84b3aa..92d1791cf 100644 --- a/test/controllers/api/tasks_controller_test.rb +++ b/test/controllers/api/tasks_controller_test.rb @@ -47,14 +47,14 @@ class TasksControllerTest < ApiControllerTestCase test "#trigger refuses to trigger a task with tasks not whitelisted" do env = { 'DANGEROUS_VARIABLE' => 'bar' } - post :trigger, params: { stack_id: @stack.to_param, task_name: 'restart', env: } + post :trigger, params: { stack_id: @stack.to_param, task_name: 'restart', env: env } assert_response :unprocessable_entity assert_json 'message', 'Variables DANGEROUS_VARIABLE have not been whitelisted' end test "#trigger triggers a task with only whitelisted env variables" do env = { 'FOO' => 'bar' } - post :trigger, params: { stack_id: @stack.to_param, task_name: 'restart', env: } + post :trigger, params: { stack_id: @stack.to_param, task_name: 'restart', env: env } assert_response :accepted assert_json 'type', 'task' assert_json 'status', 'pending' @@ -68,7 +68,7 @@ class TasksControllerTest < ApiControllerTestCase test "#trigger triggers a task with explicitly passed and default variables" do env = { 'WALRUS' => 'overridden value' } - post :trigger, params: { stack_id: @stack.to_param, task_name: 'restart', env: } + post :trigger, params: { stack_id: @stack.to_param, task_name: 'restart', env: env } assert_response :accepted # FOO and BAR are variables with a default value diff --git a/test/controllers/deploys_controller_test.rb b/test/controllers/deploys_controller_test.rb index 8723af97d..a51c47554 100644 --- a/test/controllers/deploys_controller_test.rb +++ b/test/controllers/deploys_controller_test.rb @@ -63,7 +63,7 @@ class DeploysControllerTest < ActionController::TestCase test ":create can receive an :env hash" do env = { 'SAFETY_DISABLED' => '1' } - post :create, params: { stack_id: @stack.to_param, deploy: { until_commit_id: @commit.id, env: } } + post :create, params: { stack_id: @stack.to_param, deploy: { until_commit_id: @commit.id, env: env } } new_deploy = Deploy.last assert_equal env, new_deploy.env end diff --git a/test/controllers/rollbacks_controller_test.rb b/test/controllers/rollbacks_controller_test.rb index d15bff748..a700953ea 100644 --- a/test/controllers/rollbacks_controller_test.rb +++ b/test/controllers/rollbacks_controller_test.rb @@ -19,7 +19,7 @@ class RollbacksControllerTest < ActionController::TestCase test ":create can receive an :env hash" do env = { 'SAFETY_DISABLED' => '1' } - post :create, params: { stack_id: @stack.to_param, rollback: { parent_id: @deploy.id, env: } } + post :create, params: { stack_id: @stack.to_param, rollback: { parent_id: @deploy.id, env: env } } new_rollback = Rollback.last assert_equal env, new_rollback.env end diff --git a/test/controllers/tasks_controller_test.rb b/test/controllers/tasks_controller_test.rb index 7fae31d94..d2c55030d 100644 --- a/test/controllers/tasks_controller_test.rb +++ b/test/controllers/tasks_controller_test.rb @@ -55,7 +55,7 @@ class TasksControllerTest < ActionController::TestCase test "tasks with variables defined in the shipit.yml can be triggered with their variables set" do env = { "FOO" => "0" } - post :create, params: { stack_id: @stack, definition_id: @definition.id, task: { env: }, force: 'true' } + post :create, params: { stack_id: @stack, definition_id: @definition.id, task: { env: env }, force: 'true' } assert_redirected_to stack_tasks_path(@stack, Task.last) end diff --git a/test/controllers/webhooks_controller_test.rb b/test/controllers/webhooks_controller_test.rb index 15cbc777d..b811b45e1 100644 --- a/test/controllers/webhooks_controller_test.rb +++ b/test/controllers/webhooks_controller_test.rb @@ -25,7 +25,7 @@ class WebhooksControllerTest < ActionController::TestCase body = JSON.parse(payload(:push_master)).to_json assert_enqueued_with(job: GithubSyncJob, args: [stack_id: @stack.id]) do - post :create, body:, as: :json + post :create, body: body, as: :json end end @@ -44,7 +44,7 @@ class WebhooksControllerTest < ActionController::TestCase body = JSON.parse(payload(:status_master)).merge(repository_params).to_json assert_difference 'commit.statuses.count', 1 do - post :create, body:, as: :json + post :create, body: body, as: :json end status = commit.statuses.last diff --git a/test/helpers/json_helper.rb b/test/helpers/json_helper.rb index db71dcbfc..f49173379 100644 --- a/test/helpers/json_helper.rb +++ b/test/helpers/json_helper.rb @@ -9,7 +9,7 @@ def assert_json(path = nil, expected_value = UNDEFINED, &block) end def assert_json_document(document, path, expected_value = UNDEFINED) - value = follow_path(path.to_s.split('.'), document:) + value = follow_path(path.to_s.split('.'), document: document) if block_given? yield value elsif expected_value == UNDEFINED @@ -27,7 +27,7 @@ def assert_json_keys(path, keys = nil, document: response.body) path = nil end - value = follow_path(path.to_s.split('.'), document:) + value = follow_path(path.to_s.split('.'), document: document) case value when Hash assert_equal(keys.sort, value.keys.sort) @@ -39,7 +39,7 @@ def assert_json_keys(path, keys = nil, document: response.body) def assert_no_json(path, document: response.body) segments = path.to_s.split('.') last_segment = segments.pop - leaf = follow_path(segments, document:) + leaf = follow_path(segments, document: document) case leaf when Hash refute(leaf.key?(last_segment), "Expected #{leaf.inspect} not to include #{last_segment.inspect}") diff --git a/test/jobs/chunk_rollup_job_test.rb b/test/jobs/chunk_rollup_job_test.rb index cb09e58db..f4d341a5c 100644 --- a/test/jobs/chunk_rollup_job_test.rb +++ b/test/jobs/chunk_rollup_job_test.rb @@ -26,7 +26,7 @@ class ChunkRollupJobTest < ActiveSupport::TestCase test "#peform ignores non-finished jobs" do logger = mock logger.expects(:error).once - @job.stubs(logger:) + @job.stubs(logger: logger) @task.update_attribute(:status, :pending) @@ -36,7 +36,7 @@ class ChunkRollupJobTest < ActiveSupport::TestCase test "#perform ignores tasks already rolled up" do logger = mock logger.expects(:error).once - @job.stubs(logger:) + @job.stubs(logger: logger) @task.rolled_up = true diff --git a/test/jobs/github_sync_job_test.rb b/test/jobs/github_sync_job_test.rb index 081f6e21a..dbd6ca32f 100644 --- a/test/jobs/github_sync_job_test.rb +++ b/test/jobs/github_sync_job_test.rb @@ -62,13 +62,13 @@ class GithubSyncJobTest < ActiveSupport::TestCase [ stub( sha: '36514755579bfb5bc313f403b216f4347a027990', - author:, + author: author, committer: author, stats: nil, commit: stub( sha: '36514755579bfb5bc313f403b216f4347a027990', message: 'Revert "fix it!"', - author:, + author: author, committer: author, ), ), diff --git a/test/models/commits_test.rb b/test/models/commits_test.rb index c69b3f299..6fe6aaffe 100644 --- a/test/models/commits_test.rb +++ b/test/models/commits_test.rb @@ -93,7 +93,7 @@ class CommitsTest < ActiveSupport::TestCase email: 'walrus@shopify.com', date: Time.now, }, - message:, + message: message, }, ), ) diff --git a/test/models/delivery_test.rb b/test/models/delivery_test.rb index 20e97a114..a8172b4c7 100644 --- a/test/models/delivery_test.rb +++ b/test/models/delivery_test.rb @@ -26,7 +26,7 @@ class DeliveryTest < ActiveSupport::TestCase test "#send! post the payload and update the status to `sent`" do headers = { 'content-type' => 'text/plain', 'content-length' => '2' } - stub_request(:post, @delivery.url).to_return(headers:, body: 'OK') + stub_request(:post, @delivery.url).to_return(headers: headers, body: 'OK') assert_equal 'scheduled', @delivery.status @delivery.send! diff --git a/test/models/deploys_test.rb b/test/models/deploys_test.rb index 607839948..5778b0aa8 100644 --- a/test/models/deploys_test.rb +++ b/test/models/deploys_test.rb @@ -261,7 +261,7 @@ def setup expect_event(deploy) deploy.status = 'running' - expect_hook(:deploy, deploy.stack, status: 'success', deploy:, stack: deploy.stack) do + expect_hook(:deploy, deploy.stack, status: 'success', deploy: deploy, stack: deploy.stack) do deploy.complete! end end @@ -281,7 +281,7 @@ def setup expect_event(deploy) deploy.status = 'running' - expect_hook(:deploy, deploy.stack, status: 'failed', deploy:, stack: deploy.stack) do + expect_hook(:deploy, deploy.stack, status: 'failed', deploy: deploy, stack: deploy.stack) do deploy.failure! end end @@ -301,7 +301,7 @@ def setup expect_event(deploy) deploy.status = 'running' - expect_hook(:deploy, deploy.stack, status: 'error', deploy:, stack: deploy.stack) do + expect_hook(:deploy, deploy.stack, status: 'error', deploy: deploy, stack: deploy.stack) do deploy.error! end end @@ -321,7 +321,7 @@ def setup expect_event(deploy) deploy.status = 'pending' - expect_hook(:deploy, deploy.stack, status: 'running', deploy:, stack: deploy.stack) do + expect_hook(:deploy, deploy.stack, status: 'running', deploy: deploy, stack: deploy.stack) do deploy.run! end end @@ -514,7 +514,7 @@ def setup def create_test_stack(repository: Shipit::Repository.find_or_create_by!(owner: "shopify-test", name: "shipit-engine-test")) Shipit::Stack.create( - repository:, + repository: repository, environment: 'production', branch: "master", merge_queue_enabled: true, @@ -525,7 +525,7 @@ def create_test_stack(repository: Shipit::Repository.find_or_create_by!(owner: " def create_test_commit(stack_id:, user_id:) Shipit::Commit.new( - stack_id:, + stack_id: stack_id, author_id: user_id, sha: SecureRandom.hex(20), additions: 2, @@ -540,18 +540,18 @@ def create_test_commit(stack_id:, user_id:) def create_test_status(commit_id:, stack_id:, state: "success") Shipit::Status.new( description: "Description for commit #{commit_id}", - stack_id:, - commit_id:, - state:, + stack_id: stack_id, + commit_id: commit_id, + state: state, ) end def create_test_deploy(stack_id:, user_id:, since_commit_id:, until_commit_id: since_commit_id) Shipit::Deploy.new( - stack_id:, - user_id:, - since_commit_id:, - until_commit_id:, + stack_id: stack_id, + user_id: user_id, + since_commit_id: since_commit_id, + until_commit_id: until_commit_id, status: "success", type: "Shipit::Deploy", ) @@ -568,7 +568,7 @@ def assert_generated_record_ids_are_sequential(record_id_series) def generate_commits(amount:, stack_id:, user_id:, validate:) commit_ids = [] amount.times do - commit = create_test_commit(stack_id:, user_id:) + commit = create_test_commit(stack_id: stack_id, user_id: user_id) commit.save commit.reload commit_ids << commit.id @@ -586,11 +586,11 @@ def generate_commits(amount:, stack_id:, user_id:, validate:) stack_id = test_stack.id # Create valid commit history for the stack. We need several commits to deploy and roll back through. - commit_ids = generate_commits(amount: 4, stack_id:, user_id:, validate: true) - commit_ids.each { |commit_id| create_test_status(commit_id:, stack_id:, state: "success").save } + commit_ids = generate_commits(amount: 4, stack_id: stack_id, user_id: user_id, validate: true) + commit_ids.each { |commit_id| create_test_status(commit_id: commit_id, stack_id: stack_id, state: "success").save } # Three deploys of commits 1-2, 2-3 and 3-4 respectively. Reverting last should result in Deploy 3 (commit 3) being latest. - 3.times { |index| create_test_deploy(stack_id:, user_id:, since_commit_id: commit_ids[index], until_commit_id: commit_ids[index + 1]).save } + 3.times { |index| create_test_deploy(stack_id: stack_id, user_id: user_id, since_commit_id: commit_ids[index], until_commit_id: commit_ids[index + 1]).save } # Get the reference with Rails-mutated field values. commit3 = Shipit::Commit.second_to_last @@ -622,7 +622,7 @@ def generate_commits(amount:, stack_id:, user_id:, validate:) running_deploy = shipit_deploys(:shipit_running) rollback_to = shipit_deploys(:shipit_pending) - final_rollback = running_deploy.trigger_revert(rollback_to:) + final_rollback = running_deploy.trigger_revert(rollback_to: rollback_to) assert_equal "Shipit::Rollback", final_rollback.type assert_equal 4, final_rollback.until_commit_id @@ -636,8 +636,8 @@ def generate_commits(amount:, stack_id:, user_id:, validate:) stack_id = test_stack.id # Create valid commit history for the stack. We need several commits to deploy and roll back through. - commit_ids = generate_commits(amount: 4, stack_id:, user_id:, validate: true) - commit_ids.each { |commit_id| create_test_status(commit_id:, stack_id:, state: "success").save } + commit_ids = generate_commits(amount: 4, stack_id: stack_id, user_id: user_id, validate: true) + commit_ids.each { |commit_id| create_test_status(commit_id: commit_id, stack_id: stack_id, state: "success").save } # We want the following order of Deploys: # 1. Success (commits 1-2) @@ -646,10 +646,10 @@ def generate_commits(amount:, stack_id:, user_id:, validate:) # 4. Running (commits 3-4) # 5. Reversion of the running deploy to the last successful deploy. (-> commits 1-2, i.e. the successful deploy.) - deploy1 = create_test_deploy(stack_id:, user_id:, since_commit_id: commit_ids[0], until_commit_id: commit_ids[1]) + deploy1 = create_test_deploy(stack_id: stack_id, user_id: user_id, since_commit_id: commit_ids[0], until_commit_id: commit_ids[1]) deploy1.save - deploy2 = create_test_deploy(stack_id:, user_id:, since_commit_id: commit_ids[1], until_commit_id: commit_ids[2]) + deploy2 = create_test_deploy(stack_id: stack_id, user_id: user_id, since_commit_id: commit_ids[1], until_commit_id: commit_ids[2]) deploy2.status = "faulty" deploy2.save @@ -659,7 +659,7 @@ def generate_commits(amount:, stack_id:, user_id:, validate:) assert_equal commit_ids[1], test_stack.last_deployed_commit.id - deploy3 = create_test_deploy(stack_id:, user_id:, since_commit_id: commit_ids[2], until_commit_id: commit_ids[3]) + deploy3 = create_test_deploy(stack_id: stack_id, user_id: user_id, since_commit_id: commit_ids[2], until_commit_id: commit_ids[3]) deploy3.status = "running" deploy3.rollback_once_aborted = false deploy3.save @@ -694,8 +694,8 @@ def generate_commits(amount:, stack_id:, user_id:, validate:) stack_id = test_stack.id # Create valid commit history for the stack. We need several commits to deploy and roll back through. - commit_ids = generate_commits(amount: 4, stack_id:, user_id:, validate: true) - commit_ids.each { |commit_id| create_test_status(commit_id:, stack_id:, state: "success").save } + commit_ids = generate_commits(amount: 4, stack_id: stack_id, user_id: user_id, validate: true) + commit_ids.each { |commit_id| create_test_status(commit_id: commit_id, stack_id: stack_id, state: "success").save } # We want the following order of Deploys: # 1. Success (commits 1-2) @@ -704,14 +704,14 @@ def generate_commits(amount:, stack_id:, user_id:, validate:) # 4. Reversion of the running deploy to the last successful deploy. (-> commits 1-2, i.e. the successful deploy.) # If the revert functionality doesn't restrict to deploys and rollbacks, then commit 3 will be latest deployed when the reversion is done. - deploy1 = create_test_deploy(stack_id:, user_id:, since_commit_id: commit_ids[0], until_commit_id: commit_ids[1]) + deploy1 = create_test_deploy(stack_id: stack_id, user_id: user_id, since_commit_id: commit_ids[0], until_commit_id: commit_ids[1]) deploy1.save - deploy2 = create_test_deploy(stack_id:, user_id:, since_commit_id: commit_ids[1], until_commit_id: commit_ids[2]) + deploy2 = create_test_deploy(stack_id: stack_id, user_id: user_id, since_commit_id: commit_ids[1], until_commit_id: commit_ids[2]) deploy2.type = "Shipit::Fake" deploy2.save - deploy3 = create_test_deploy(stack_id:, user_id:, since_commit_id: commit_ids[2], until_commit_id: commit_ids[3]) + deploy3 = create_test_deploy(stack_id: stack_id, user_id: user_id, since_commit_id: commit_ids[2], until_commit_id: commit_ids[3]) deploy3.status = "running" deploy3.rollback_once_aborted = false deploy3.save @@ -745,8 +745,8 @@ def generate_commits(amount:, stack_id:, user_id:, validate:) stack_id = test_stack.id # Create valid commit history for the stack. We need several commits to deploy and roll back through. - commit_ids = generate_commits(amount: 4, stack_id:, user_id:, validate: true) - commit_ids.each { |commit_id| create_test_status(commit_id:, stack_id:, state: "success").save } + commit_ids = generate_commits(amount: 4, stack_id: stack_id, user_id: user_id, validate: true) + commit_ids.each { |commit_id| create_test_status(commit_id: commit_id, stack_id: stack_id, state: "success").save } # We want the following order of Deploys: # 1. Success (commits 1-2) @@ -755,13 +755,13 @@ def generate_commits(amount:, stack_id:, user_id:, validate:) # 4. Reversion of the running deploy to the last successful deploy of the same stack. (-> commits 1-2, i.e. the successful deploy.) # If the revert functionality doesn't restrict to the correct stack, then commit 3 will be latest deployed when the reversion is done. - deploy1 = create_test_deploy(stack_id:, user_id:, since_commit_id: commit_ids[0], until_commit_id: commit_ids[1]) + deploy1 = create_test_deploy(stack_id: stack_id, user_id: user_id, since_commit_id: commit_ids[0], until_commit_id: commit_ids[1]) deploy1.save - deploy2 = create_test_deploy(stack_id: other_stack.id, user_id:, since_commit_id: commit_ids[1], until_commit_id: commit_ids[2]) + deploy2 = create_test_deploy(stack_id: other_stack.id, user_id: user_id, since_commit_id: commit_ids[1], until_commit_id: commit_ids[2]) deploy2.save - deploy3 = create_test_deploy(stack_id:, user_id:, since_commit_id: commit_ids[2], until_commit_id: commit_ids[3]) + deploy3 = create_test_deploy(stack_id: stack_id, user_id: user_id, since_commit_id: commit_ids[2], until_commit_id: commit_ids[3]) deploy3.status = "running" deploy3.rollback_once_aborted = false deploy3.save @@ -789,9 +789,9 @@ def generate_commits(amount:, stack_id:, user_id:, validate:) test_stack.reload stack_id = test_stack.id - commit_ids = generate_commits(amount: 2, stack_id:, user_id:, validate: true) - commit_ids.each { |commit_id| create_test_status(commit_id:, stack_id:, state: "success").save } - deploy1 = create_test_deploy(stack_id:, user_id:, since_commit_id: commit_ids[0], until_commit_id: commit_ids[1]) + commit_ids = generate_commits(amount: 2, stack_id: stack_id, user_id: user_id, validate: true) + commit_ids.each { |commit_id| create_test_status(commit_id: commit_id, stack_id: stack_id, state: "success").save } + deploy1 = create_test_deploy(stack_id: stack_id, user_id: user_id, since_commit_id: commit_ids[0], until_commit_id: commit_ids[1]) deploy1.save rollback = deploy1.trigger_revert diff --git a/test/models/merge_request_test.rb b/test/models/merge_request_test.rb index 668d22f61..16f8f020c 100644 --- a/test/models/merge_request_test.rb +++ b/test/models/merge_request_test.rb @@ -102,8 +102,8 @@ class MergeRequestTest < ActiveSupport::TestCase [head_sha, base_sha].each do |sha| Shipit.github.api.expects(:commit).with(@stack.github_repo_name, sha).returns( stub( - sha:, - author:, + sha: sha, + author: author, committer: author, commit: stub( message: 'Great feature', diff --git a/test/models/shipit/check_run_test.rb b/test/models/shipit/check_run_test.rb index 2c57bb644..0ec6ecbfa 100644 --- a/test/models/shipit/check_run_test.rb +++ b/test/models/shipit/check_run_test.rb @@ -39,14 +39,14 @@ class CheckRunTest < ActiveSupport::TestCase assert_difference -> { @commit.check_runs.count }, +1 do @commit.check_runs.create_or_update_from_github!( @stack.id, - github_check_run(conclusion: 'success', completed_at:), + github_check_run(conclusion: 'success', completed_at: completed_at), ) end assert_enqueued_with(job: RefreshCheckRunsJob) do @commit.check_runs.create_or_update_from_github!( @stack.id, - github_check_run(conclusion: nil, completed_at:), + github_check_run(conclusion: nil, completed_at: completed_at), ) end @@ -56,7 +56,7 @@ class CheckRunTest < ActiveSupport::TestCase @stack.id, github_check_run( conclusion: 'action_required', - completed_at:, + completed_at: completed_at, started_at: completed_at + 1.minute, ), ) @@ -68,12 +68,12 @@ class CheckRunTest < ActiveSupport::TestCase test ".create_or_update_from_github! is idempotent" do completed_at = Time.now assert_difference -> { @commit.check_runs.count }, +1 do - @commit.check_runs.create_or_update_from_github!(@stack.id, github_check_run(completed_at:)) + @commit.check_runs.create_or_update_from_github!(@stack.id, github_check_run(completed_at: completed_at)) end assert_no_difference -> { @commit.check_runs.count } do assert_no_enqueued_jobs(only: RefreshCheckRunsJob) do - @commit.check_runs.create_or_update_from_github!(@stack.id, github_check_run(completed_at:)) + @commit.check_runs.create_or_update_from_github!(@stack.id, github_check_run(completed_at: completed_at)) end end end @@ -83,7 +83,7 @@ class CheckRunTest < ActiveSupport::TestCase assert_difference -> { @commit.check_runs.count }, +1 do @commit.check_runs.create_or_update_from_github!( @stack.id, - github_check_run(conclusion: 'success', completed_at:), + github_check_run(conclusion: 'success', completed_at: completed_at), ) end @@ -115,7 +115,7 @@ class CheckRunTest < ActiveSupport::TestCase assert_difference -> { @commit.check_runs.count }, +1 do @commit.check_runs.create_or_update_from_github!( @stack.id, - github_check_run(conclusion: 'success', completed_at:), + github_check_run(conclusion: 'success', completed_at: completed_at), ) end @@ -152,7 +152,7 @@ class CheckRunTest < ActiveSupport::TestCase 'action_required' => 'pending', }.each do |conclusion, expected_status| test "#state is #{expected_status.inspect} when conclusion is #{conclusion.inspect}" do - @check_run.update!(conclusion:) + @check_run.update!(conclusion: conclusion) assert_equal expected_status, @check_run.state end end diff --git a/test/models/shipit/repository_test.rb b/test/models/shipit/repository_test.rb index 4ad8f0536..5c7dbdbb3 100644 --- a/test/models/shipit/repository_test.rb +++ b/test/models/shipit/repository_test.rb @@ -72,7 +72,7 @@ class RepositoryTest < ActiveSupport::TestCase owner = "repository-owner" name = "repository-name" github_repo_name = [owner, name].join("/") - expected_repository = Repository.create(owner:, name:) + expected_repository = Repository.create(owner: owner, name: name) found_repository = Repository.from_github_repo_name(github_repo_name) diff --git a/test/models/shipit/stack_test.rb b/test/models/shipit/stack_test.rb index c013b567e..746a1afe7 100644 --- a/test/models/shipit/stack_test.rb +++ b/test/models/shipit/stack_test.rb @@ -87,7 +87,7 @@ def deliver(event, stack, payload) assert_includes(FakeReceiver.hooks, [ :deploy, @stack, - { deploy:, status: "pending", stack: @stack }, + { deploy: deploy, status: "pending", stack: @stack }, ]) ensure Shipit.internal_hook_receivers = original_receivers @@ -818,7 +818,7 @@ def deliver(event, stack, payload) assert !commits.empty? commits.each { |c| refute_predicate c, :deployable? } - assert_nil @stack.next_expected_commit_to_deploy(commits:) + assert_nil @stack.next_expected_commit_to_deploy(commits: commits) end test "#next_expected_commit_to_deploy returns nil if all deployable commits are active" do @@ -828,7 +828,7 @@ def deliver(event, stack, payload) assert !commits.empty? commits.each { |c| assert_predicate c, :active? } - assert_nil @stack.next_expected_commit_to_deploy(commits:) + assert_nil @stack.next_expected_commit_to_deploy(commits: commits) end test "#next_expected_commit_to_deploy returns nil if there are no commits" do @@ -841,7 +841,7 @@ def deliver(event, stack, payload) assert !commits.empty? - most_recent_limited = @stack.next_expected_commit_to_deploy(commits:) + most_recent_limited = @stack.next_expected_commit_to_deploy(commits: commits) most_recent = commits.find { |c| !c.active? && c.deployable? } assert most_recent.id > most_recent_limited.id @@ -860,7 +860,7 @@ def deliver(event, stack, payload) test "#lock_reverted_commits! locks all commits between the original and reverted commits" do reverted_commit = @stack.undeployed_commits.first revert_author = shipit_users(:bob) - generate_revert_commit(stack: @stack, reverted_commit:, author: revert_author) + generate_revert_commit(stack: @stack, reverted_commit: reverted_commit, author: revert_author) @stack.reload assert_equal( @@ -888,7 +888,7 @@ def deliver(event, stack, payload) test "#lock_reverted_commits! is a no-op if the reverted commit has already shipped" do reverted_commit = shipit_commits(:first) revert_author = shipit_users(:bob) - generate_revert_commit(stack: @stack, reverted_commit:, author: revert_author) + generate_revert_commit(stack: @stack, reverted_commit: reverted_commit, author: revert_author) @stack.reload initial_state = [ @@ -1016,7 +1016,7 @@ def generate_revert_commit(stack:, reverted_commit:, author: reverted_commit.aut stack.commits.create( sha: SecureRandom.hex(20), message: "Revert \"#{reverted_commit.message_header}\"", - author:, + author: author, committer: author, authored_at: Time.zone.now, committed_at: Time.zone.now, diff --git a/test/models/shipit/webhooks/handlers/pull_request/closed_handler_test.rb b/test/models/shipit/webhooks/handlers/pull_request/closed_handler_test.rb index 43673aca2..9018aaef8 100644 --- a/test/models/shipit/webhooks/handlers/pull_request/closed_handler_test.rb +++ b/test/models/shipit/webhooks/handlers/pull_request/closed_handler_test.rb @@ -40,7 +40,7 @@ class ClosedHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_all, ) @@ -53,7 +53,7 @@ class ClosedHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -69,7 +69,7 @@ class ClosedHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -85,7 +85,7 @@ class ClosedHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -101,7 +101,7 @@ class ClosedHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :prevent_with_label, label: "pull-requests-label", ) diff --git a/test/models/shipit/webhooks/handlers/pull_request/labeled_handler_test.rb b/test/models/shipit/webhooks/handlers/pull_request/labeled_handler_test.rb index 078243c9d..ea25cfbcb 100644 --- a/test/models/shipit/webhooks/handlers/pull_request/labeled_handler_test.rb +++ b/test/models/shipit/webhooks/handlers/pull_request/labeled_handler_test.rb @@ -26,7 +26,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase test "ignores Github PullRequest webhooks when the Repository has disabled the Review Stacks feature" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, provisioning_enabled: false, behavior: :allow_with_label, label: "pull-requests-label", @@ -40,7 +40,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase test "ignores Github PullRequest webhooks when the repository allows_all PullRequests to create ReviewStacks" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_all, ) @@ -53,7 +53,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase stack = create_archived_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -69,7 +69,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase test "creates and provisions a new review stack when the repository creates ReviewStacks with allow_with_label and the label is present" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -91,7 +91,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -107,7 +107,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -122,7 +122,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase test "ignores Github PullRequest webhooks when the repository allow_with_label to create ReviewStacks and the label is absent" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -138,7 +138,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -152,7 +152,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -165,7 +165,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase test "ignores Github PullRequest webhooks when the repository prevent_with_label to create ReviewStacks and the label is present" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -179,7 +179,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase stack = create_archived_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -195,7 +195,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase test "creates and provisions a new review stack when the repository creates ReviewStacks with prevent_with_label and the label is absent" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -216,7 +216,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase test "assigns the PullRequest to newly created stacks" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -232,7 +232,7 @@ class LabeledHandlerTest < ActiveSupport::TestCase create_archived_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_with_label, label: "pull-requests-label", ) diff --git a/test/models/shipit/webhooks/handlers/pull_request/opened_handler_test.rb b/test/models/shipit/webhooks/handlers/pull_request/opened_handler_test.rb index 2e2676853..f6675eee3 100644 --- a/test/models/shipit/webhooks/handlers/pull_request/opened_handler_test.rb +++ b/test/models/shipit/webhooks/handlers/pull_request/opened_handler_test.rb @@ -96,7 +96,7 @@ class OpenedHandlerTest < ActiveSupport::TestCase test "only provision stacks for repos with auto-provisioning enabled" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, provisioning_enabled: false, behavior: :allow_all, ) @@ -116,7 +116,7 @@ class OpenedHandlerTest < ActiveSupport::TestCase test "creates stacks for repos that allow_all" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_all, label: "pull-requests-label", ) @@ -129,7 +129,7 @@ class OpenedHandlerTest < ActiveSupport::TestCase test "creates stacks for repos that allow_with_label when label is present" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -144,7 +144,7 @@ class OpenedHandlerTest < ActiveSupport::TestCase test "does not create stacks for repos that allow_with_label when label is absent" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -159,7 +159,7 @@ class OpenedHandlerTest < ActiveSupport::TestCase test "create stacks for repos what prevent_with_label when label is absent" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -174,7 +174,7 @@ class OpenedHandlerTest < ActiveSupport::TestCase test "does not create stacks for repos what prevent_with_label when label is present" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :prevent_with_label, label: "pull-requests-label", ) diff --git a/test/models/shipit/webhooks/handlers/pull_request/reopened_handler_test.rb b/test/models/shipit/webhooks/handlers/pull_request/reopened_handler_test.rb index 1112c63aa..98a601b8b 100644 --- a/test/models/shipit/webhooks/handlers/pull_request/reopened_handler_test.rb +++ b/test/models/shipit/webhooks/handlers/pull_request/reopened_handler_test.rb @@ -47,7 +47,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase stack = create_archived_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_all, ) @@ -60,7 +60,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase test "provisions missing stacks for repos that allow_all" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_all, ) payload = payload_parsed(:pull_request_reopened) @@ -79,7 +79,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase test "auto-created stack should have pull request assigned" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_all, ) payload = payload_parsed(:pull_request_reopened) @@ -93,7 +93,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase stack = create_archived_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -109,7 +109,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase test "provisions missing stacks for repos that allow_with_label when label is present" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -131,7 +131,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase stack = create_archived_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -147,7 +147,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase stack = create_archived_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -163,7 +163,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase test "provisions missing stacks for repos that prevent_with_label when label is absent" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -185,7 +185,7 @@ class ReopenedHandlerTest < ActiveSupport::TestCase stack = create_archived_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :prevent_with_label, label: "pull-requests-label", ) diff --git a/test/models/shipit/webhooks/handlers/pull_request/unlabeled_handler_test.rb b/test/models/shipit/webhooks/handlers/pull_request/unlabeled_handler_test.rb index cc577d6eb..489c5504a 100644 --- a/test/models/shipit/webhooks/handlers/pull_request/unlabeled_handler_test.rb +++ b/test/models/shipit/webhooks/handlers/pull_request/unlabeled_handler_test.rb @@ -24,7 +24,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase test "ignores Github PullRequest webhooks when the Repository has disabled the Review Stacks feature" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, provisioning_enabled: false, behavior: :allow_with_label, label: "pull-requests-label", @@ -45,7 +45,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -59,7 +59,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -72,7 +72,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase test "ignores Github PullRequest webhooks when the repository allow_with_label to create ReviewStacks and the label is absent" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -86,7 +86,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase stack = create_archived_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -102,7 +102,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase test "creates and provisions a new review stack when the repository creates ReviewStacks with allow_with_label and the label is present" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_with_label, label: "pull-requests-label", ) @@ -124,7 +124,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -140,7 +140,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase stack = create_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -155,7 +155,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase test "ignores Github PullRequest webhooks when the repository prevent_with_label to create ReviewStacks and the label is present" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -171,7 +171,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase stack = create_archived_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -187,7 +187,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase test "creates and provisions a new review stack when the repository creates ReviewStacks with prevent_with_label and the label is absent" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -208,7 +208,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase test "assigns the PullRequest to newly created stacks" do repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :prevent_with_label, label: "pull-requests-label", ) @@ -224,7 +224,7 @@ class UnlabeledHandlerTest < ActiveSupport::TestCase create_archived_stack repository = shipit_repositories(:shipit) configure_provisioning_behavior( - repository:, + repository: repository, behavior: :allow_with_label, label: "pull-requests-label", ) diff --git a/test/models/team_test.rb b/test/models/team_test.rb index 3260b41a1..14cda9a3b 100644 --- a/test/models/team_test.rb +++ b/test/models/team_test.rb @@ -35,7 +35,7 @@ class TeamTest < ActiveSupport::TestCase skip unless limit slug = 'a' * 255 - team = new_team(slug:) + team = new_team(slug: slug) response = stub(rels: {}, data: [team]) Shipit.github.api.expects(:org_teams).with('shopify', per_page: 100).returns(response.data) @@ -70,7 +70,7 @@ def new_team(slug: 'new-team') stub( id: 24, name: 'New Team', - slug:, + slug: slug, url: 'https://example.com', description: 'The Best one', organization: 'shopify', diff --git a/test/models/undeployed_commits_test.rb b/test/models/undeployed_commits_test.rb index c6c712482..ddfd6a305 100644 --- a/test/models/undeployed_commits_test.rb +++ b/test/models/undeployed_commits_test.rb @@ -44,7 +44,7 @@ class UndeployedCommitsTest < ActiveSupport::TestCase test "#expected_to_be_deployed? returns true if the stack has continuous deployment enabled, next expected commit to deploy id is greater or equals to the commit id and commit is not active" do commit = shipit_commits(:undeployed_4) next_expected_commit_to_deploy = commit.stack.next_expected_commit_to_deploy - undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy:) + undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy: next_expected_commit_to_deploy) refute_predicate next_expected_commit_to_deploy, :nil? assert_predicate undeployed_commit.stack, :continuous_deployment @@ -57,7 +57,7 @@ class UndeployedCommitsTest < ActiveSupport::TestCase test "#expected_to_be_deployed? returns true if the active task has no commit range" do commit = shipit_commits(:task_no_commits) next_expected_commit_to_deploy = commit.stack.next_expected_commit_to_deploy - undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy:) + undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy: next_expected_commit_to_deploy) refute_predicate next_expected_commit_to_deploy, :nil? assert_predicate undeployed_commit.stack, :continuous_deployment @@ -70,7 +70,7 @@ class UndeployedCommitsTest < ActiveSupport::TestCase test "#expected_to_be_deployed? returns false if the stack has continuous deployment disabled" do commit = shipit_commits(:cyclimse_first) next_expected_commit_to_deploy = commit.stack.next_expected_commit_to_deploy - undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy:) + undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy: next_expected_commit_to_deploy) refute_predicate next_expected_commit_to_deploy, :nil? refute_predicate undeployed_commit.stack, :continuous_deployment @@ -83,7 +83,7 @@ class UndeployedCommitsTest < ActiveSupport::TestCase test "#expected_to_be_deployed? returns false if the commit is part of the active task" do commit = shipit_commits(:undeployed_3) next_expected_commit_to_deploy = commit.stack.next_expected_commit_to_deploy - undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy:) + undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy: next_expected_commit_to_deploy) refute_predicate next_expected_commit_to_deploy, :nil? assert_predicate undeployed_commit.stack, :continuous_deployment @@ -103,7 +103,7 @@ class UndeployedCommitsTest < ActiveSupport::TestCase test "#expected_to_be_deployed? returns false if the commit has an id greater than next commit to deploy" do commit = shipit_commits(:undeployed_7) next_expected_commit_to_deploy = commit.stack.next_expected_commit_to_deploy - undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy:) + undeployed_commit = UndeployedCommit.new(commit, index: 1, next_expected_commit_to_deploy: next_expected_commit_to_deploy) refute_predicate next_expected_commit_to_deploy, :nil? assert_predicate undeployed_commit.stack, :continuous_deployment From 5ed38234def11210cf6fc9782dd041b0477034ec Mon Sep 17 00:00:00 2001 From: Kartiki Sharma Date: Mon, 22 Jan 2024 12:12:31 -0500 Subject: [PATCH 23/23] Fix remaining rubocop errors --- Gemfile | 2 +- Gemfile.lock | 14 +++++++------- dev.yml | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Gemfile b/Gemfile index e6c52fb4c..b30d785cf 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ end group :development, :test do gem 'faker' gem 'webmock' - gem 'rubocop', '1.18.3' + gem 'rubocop', '1.22.3' gem 'rubocop-shopify', require: false end diff --git a/Gemfile.lock b/Gemfile.lock index e95814080..074de1e5e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -213,7 +213,6 @@ GEM marcel (1.0.2) method_source (1.0.0) mini_mime (1.1.5) - mini_portile2 (2.8.5) mini_racer (0.6.4) libv8-node (~> 16.19.0.0) minitest (5.21.2) @@ -262,7 +261,7 @@ GEM paquito (0.11.0) msgpack (>= 1.5.2) parallel (1.24.0) - parser (3.3.0.4) + parser (3.3.0.5) ast (~> 2.4.1) racc pg (1.3.3) @@ -334,13 +333,13 @@ GEM actionpack (>= 5.2) railties (>= 5.2) rexml (3.2.6) - rubocop (1.18.3) + rubocop (1.22.3) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.7.0, < 2.0) + rubocop-ast (>= 1.12.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.30.0) @@ -381,8 +380,9 @@ GEM activesupport (>= 5.2) sprockets (>= 3.0.0) spy (1.0.5) - sqlite3 (1.7.0) - mini_portile2 (~> 2.8.0) + sqlite3 (1.7.0-arm64-darwin) + sqlite3 (1.7.0-x86_64-darwin) + sqlite3 (1.7.0-x86_64-linux) state_machines (0.5.0) state_machines-activemodel (0.8.0) activemodel (>= 5.1) @@ -431,7 +431,7 @@ DEPENDENCIES mysql2 pg pry - rubocop (= 1.18.3) + rubocop (= 1.22.3) rubocop-shopify shipit-engine! simplecov diff --git a/dev.yml b/dev.yml index a255bb899..01b97ad3f 100644 --- a/dev.yml +++ b/dev.yml @@ -8,7 +8,7 @@ up: - packages: - sqlite - ruby: - version: 3.1.0 + version: 3.1.4 - isogun - bundler: without: ci