roo_on_rails 1.3.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a1d4400e60ae4f708cadcb1ce5cb17190a646b31
4
- data.tar.gz: caf7aa09a3d41c9fa0472a7677b7841b1dc00723
3
+ metadata.gz: 492f0bf2a7f3112cd466416f709a18c3d3f6180d
4
+ data.tar.gz: dd2ca58474719751987b21b17d8d65214ed097ad
5
5
  SHA512:
6
- metadata.gz: 462640e0444ef91fe4e4c32b4fba32242bccd5ea3314c27fe2fcba076158c66928a729af87fb9d0f7a6069a3109933a4515e098ab7987f02578c8a3a32a9d7bc
7
- data.tar.gz: 5caa0d4cbff6756a322bb2063a852c332edd4a5203911f394efe27d712d3a36be7de7e04c8580cce78f5082724a90ef79e29635c07ca30b96f67cc9ad6ba6fd3
6
+ metadata.gz: 3d86029410dca537fd459beb22ee499624c292b02e710627e88a356bb1879949e8e22d1039af3077824d99a7171de76a26534e581d5f36f7483f8ceb2245456e
7
+ data.tar.gz: d4e3b5635b332ae8d0a238a3ceac0c10c8ef665449d136597344207289b508a26fc2dc405209b9d8bac942ec596b1a85b35fc82e4adee7c2740734b5afb936dd
data/.codeclimate.yml ADDED
@@ -0,0 +1,20 @@
1
+ ---
2
+ engines:
3
+ bundler-audit:
4
+ enabled: false
5
+ duplication:
6
+ enabled: true
7
+ config:
8
+ languages:
9
+ - ruby
10
+ fixme:
11
+ enabled: true
12
+ rubocop:
13
+ enabled: true
14
+ ratings:
15
+ paths:
16
+ - Gemfile.lock
17
+ - "**.rb"
18
+ exclude_paths:
19
+ - spec/
20
+ - vendor/
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  /vendor/
11
+ /.idea
data/.rubocop.yml CHANGED
@@ -28,6 +28,14 @@ Metrics/LineLength:
28
28
  Max: 100
29
29
  Exclude:
30
30
  - Gemfile
31
-
31
+
32
32
  Style/Documentation:
33
33
  Enabled: false
34
+
35
+
36
+ Style/FormatString:
37
+ Enabled: false
38
+ Style/DotPosition:
39
+ Enabled: false
40
+ Metrics/AbcSize:
41
+ Max: 30
data/CHANGELOG.md CHANGED
@@ -1,8 +1,21 @@
1
+ # v1.4.0 (2017-06-05)
2
+
3
+ Features:
4
+
5
+ - Adds `newrelic:notice_deployment` rake task (#32)
6
+ - Adds Heroku/Datadog integration checks (#33)
7
+ - Supports Rails apps without ActiveRecord (#26)
8
+
9
+ Fixes:
10
+
11
+ - `roo_on_rails` command only loads the checks harness if necessary (#30)
12
+ - Upgrades outdated `platform-api` gem (#31)
13
+
1
14
  # v1.3.1 (2017-05-05)
2
15
 
3
16
  Features:
4
17
 
5
- - Added Rails 5.1 support (#25)
18
+ - Adds Rails 5.1 support (#25)
6
19
 
7
20
  Fixes:
8
21
 
@@ -15,7 +28,7 @@ Features:
15
28
  - Sets database statement timeout to 200ms by default (#13).
16
29
  - Sets migration statement timeout to 10s by default (#16, #17)
17
30
  - Adds Sidekiq and Hirefire (workers) integration (#11)
18
- - Adds the ability to tag logs with key/value pairs (#20)
31
+ - Adds the ability to tag logs with key/value pairs (#20, #21)
19
32
 
20
33
  Fixes:
21
34
 
@@ -23,6 +36,7 @@ Fixes:
23
36
  - Do not depend on sort order for Codecov GitHub contexts (#12)
24
37
  - Do not add `Rack::SslEnforcer` middleware in test environment (#15)
25
38
  - Fix for "undefined constant: RooOnRails::Rack::Timeout" (#18)
39
+ - Use correct class name in Sidekiq auto-scaling metric (#22)
26
40
 
27
41
  # v1.2.0 (2017-03-21)
28
42
 
@@ -45,7 +59,7 @@ Features:
45
59
 
46
60
  # v1.0.1 (2017-01-20)
47
61
 
48
- Bug fixes:
62
+ Fixes:
49
63
 
50
64
  - Do not load New Relic in test environments (#2, #3)
51
65
 
data/Gemfile CHANGED
@@ -6,3 +6,6 @@ gemspec
6
6
  gem 'guard'
7
7
  gem 'guard-rspec'
8
8
  gem 'appraisal'
9
+
10
+ gem 'pg'
11
+ gem 'sqlite3'
data/README.md CHANGED
@@ -141,9 +141,22 @@ When setting the manager up in the HireFire web ui, the following settings must
141
141
  For clearer and machine-parseable log output, there in an extension to be able to add context to your logs which is output as [logfmt](https://brandur.org/logfmt) key/value pairs after the log message.
142
142
 
143
143
  ```ruby
144
- # in application.rb
144
+ # application.rb
145
145
 
146
- Rails.logger = RooOnRails::ContextLogging.new(ActiveSupport::Logger.new($stdout))
146
+ require 'roo_on_rails/context_logging'
147
+
148
+ class Application < Rails::Application
149
+
150
+ # add this block somewhere within the application class
151
+ logger = config.logger
152
+ if logger.nil?
153
+ logger = ActiveSupport::Logger.new($stdout)
154
+ logger.formatter = config.log_formatter
155
+ end
156
+ logger = ActiveSupport::TaggedLogging.new(logger) unless logger.respond_to?(:tagged)
157
+ config.logger = RooOnRails::ContextLogging.new(logger)
158
+
159
+ end
147
160
  ```
148
161
 
149
162
  You can then add context using the `with` method:
@@ -154,7 +167,7 @@ logger.with(a: 1) { logger.with(b: 2) { logger.info('Stuff') } }
154
167
  logger.with(a: 1, b: 2).info('Stuff')
155
168
  ```
156
169
 
157
- See the [class documentation](/deliveroo/roo_on_rails/tree/master/lib/roo_on_rails/context_logging.rb) for further details.
170
+ See the [class documentation](lib/roo_on_rails/context_logging.rb) for further details.
158
171
 
159
172
  ## Contributing
160
173
 
data/exe/roo_on_rails CHANGED
@@ -1,12 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
+
2
3
  require 'rubygems'
3
4
  require 'roo_on_rails/config'
4
- require 'roo_on_rails/harness'
5
- require 'roo_on_rails/sidekiq/loader'
6
5
 
7
6
  if ARGV.include? 'sidekiq'
7
+ require 'roo_on_rails/sidekiq/loader'
8
8
  RooOnRails::Sidekiq::Loader.run
9
9
  else
10
+ require 'roo_on_rails/harness'
10
11
  module RooOnRails
11
12
  Harness.new(try_fix: true, context: Config.load).run
12
13
  end
@@ -5,8 +5,9 @@ source "https://rubygems.org"
5
5
  gem "guard"
6
6
  gem "guard-rspec"
7
7
  gem "appraisal"
8
- gem "rails", "~> 3.2"
8
+ gem "pg"
9
9
  gem "sqlite3"
10
+ gem "rails", "~> 3.2"
10
11
  gem "sidekiq", "< 5"
11
12
 
12
13
  gemspec path: "../"
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- roo_on_rails (1.3.1)
4
+ roo_on_rails (1.4.0)
5
5
  dotenv-rails (~> 2.1)
6
6
  hashie (~> 3.4)
7
7
  hirefire-resource
8
8
  newrelic_rpm (~> 3.17)
9
9
  octokit
10
- platform-api (~> 0.8)
10
+ platform-api (~> 2.0)
11
11
  rack-ssl-enforcer
12
12
  rack-timeout
13
13
  rails (>= 3.2.22, < 5.2)
@@ -66,7 +66,7 @@ GEM
66
66
  dotenv (= 2.2.1)
67
67
  railties (>= 3.2, < 5.2)
68
68
  erubis (2.7.0)
69
- excon (0.55.0)
69
+ excon (0.56.0)
70
70
  faraday (0.12.1)
71
71
  multipart-post (>= 1.2, < 3)
72
72
  ffi (1.9.18)
@@ -86,12 +86,12 @@ GEM
86
86
  guard-compat (~> 1.1)
87
87
  rspec (>= 2.99.0, < 4.0)
88
88
  hashie (3.5.5)
89
- heroics (0.0.21)
89
+ heroics (0.0.22)
90
90
  erubis (~> 2.0)
91
91
  excon
92
92
  multi_json (>= 1.9.2)
93
93
  hike (1.2.3)
94
- hirefire-resource (0.4.0)
94
+ hirefire-resource (0.4.2)
95
95
  i18n (0.8.1)
96
96
  journey (1.0.4)
97
97
  json (1.8.6)
@@ -106,6 +106,7 @@ GEM
106
106
  memfs (1.0.0)
107
107
  method_source (0.8.2)
108
108
  mime-types (1.25.1)
109
+ moneta (0.8.1)
109
110
  multi_json (1.12.1)
110
111
  multipart-post (2.0.0)
111
112
  nenv (0.3.0)
@@ -115,8 +116,10 @@ GEM
115
116
  shellany (~> 0.0)
116
117
  octokit (4.7.0)
117
118
  sawyer (~> 0.8.0, >= 0.5.3)
118
- platform-api (0.8.0)
119
- heroics (~> 0.0.17)
119
+ pg (0.20.0)
120
+ platform-api (2.0.0)
121
+ heroics (~> 0.0.22)
122
+ moneta (~> 0.8.1)
120
123
  polyglot (0.3.5)
121
124
  pry (0.10.4)
122
125
  coderay (~> 1.1.0)
@@ -212,6 +215,7 @@ DEPENDENCIES
212
215
  guard
213
216
  guard-rspec
214
217
  memfs
218
+ pg
215
219
  pry-byebug
216
220
  rails (~> 3.2)
217
221
  rake (~> 10.0)
@@ -5,8 +5,8 @@ source "https://rubygems.org"
5
5
  gem "guard"
6
6
  gem "guard-rspec"
7
7
  gem "appraisal"
8
- gem "rails", "~> 4.2"
9
- gem "sqlite3"
10
8
  gem "pg"
9
+ gem "sqlite3"
10
+ gem "rails", "~> 4.2"
11
11
 
12
12
  gemspec path: "../"
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- roo_on_rails (1.3.1)
4
+ roo_on_rails (1.4.0)
5
5
  dotenv-rails (~> 2.1)
6
6
  hashie (~> 3.4)
7
7
  hirefire-resource
8
8
  newrelic_rpm (~> 3.17)
9
9
  octokit
10
- platform-api (~> 0.8)
10
+ platform-api (~> 2.0)
11
11
  rack-ssl-enforcer
12
12
  rack-timeout
13
13
  rails (>= 3.2.22, < 5.2)
@@ -73,7 +73,7 @@ GEM
73
73
  dotenv (= 2.2.1)
74
74
  railties (>= 3.2, < 5.2)
75
75
  erubis (2.7.0)
76
- excon (0.55.0)
76
+ excon (0.56.0)
77
77
  faraday (0.12.1)
78
78
  multipart-post (>= 1.2, < 3)
79
79
  ffi (1.9.18)
@@ -95,11 +95,11 @@ GEM
95
95
  guard-compat (~> 1.1)
96
96
  rspec (>= 2.99.0, < 4.0)
97
97
  hashie (3.5.5)
98
- heroics (0.0.21)
98
+ heroics (0.0.22)
99
99
  erubis (~> 2.0)
100
100
  excon
101
101
  multi_json (>= 1.9.2)
102
- hirefire-resource (0.4.0)
102
+ hirefire-resource (0.4.2)
103
103
  i18n (0.8.1)
104
104
  json (2.1.0)
105
105
  listen (3.1.5)
@@ -118,6 +118,7 @@ GEM
118
118
  mime-types-data (3.2016.0521)
119
119
  mini_portile2 (2.1.0)
120
120
  minitest (5.10.1)
121
+ moneta (0.8.1)
121
122
  multi_json (1.12.1)
122
123
  multipart-post (2.0.0)
123
124
  nenv (0.3.0)
@@ -130,8 +131,9 @@ GEM
130
131
  octokit (4.7.0)
131
132
  sawyer (~> 0.8.0, >= 0.5.3)
132
133
  pg (0.20.0)
133
- platform-api (0.8.0)
134
- heroics (~> 0.0.17)
134
+ platform-api (2.0.0)
135
+ heroics (~> 0.0.22)
136
+ moneta (~> 0.8.1)
135
137
  pry (0.10.4)
136
138
  coderay (~> 1.1.0)
137
139
  method_source (~> 0.8.1)
@@ -141,7 +143,7 @@ GEM
141
143
  pry (~> 0.10)
142
144
  public_suffix (2.0.5)
143
145
  rack (1.6.5)
144
- rack-protection (1.5.3)
146
+ rack-protection (2.0.0)
145
147
  rack
146
148
  rack-ssl-enforcer (0.2.9)
147
149
  rack-test (0.6.3)
@@ -5,8 +5,8 @@ source "https://rubygems.org"
5
5
  gem "guard"
6
6
  gem "guard-rspec"
7
7
  gem "appraisal"
8
- gem "rails", "~> 5.0"
9
- gem "sqlite3"
10
8
  gem "pg"
9
+ gem "sqlite3"
10
+ gem "rails", "~> 5.0"
11
11
 
12
12
  gemspec path: "../"
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- roo_on_rails (1.3.1)
4
+ roo_on_rails (1.4.0)
5
5
  dotenv-rails (~> 2.1)
6
6
  hashie (~> 3.4)
7
7
  hirefire-resource
8
8
  newrelic_rpm (~> 3.17)
9
9
  octokit
10
- platform-api (~> 0.8)
10
+ platform-api (~> 2.0)
11
11
  rack-ssl-enforcer
12
12
  rack-timeout
13
13
  rails (>= 3.2.22, < 5.2)
@@ -76,7 +76,7 @@ GEM
76
76
  dotenv (= 2.2.1)
77
77
  railties (>= 3.2, < 5.2)
78
78
  erubis (2.7.0)
79
- excon (0.55.0)
79
+ excon (0.56.0)
80
80
  faraday (0.12.1)
81
81
  multipart-post (>= 1.2, < 3)
82
82
  ffi (1.9.18)
@@ -98,11 +98,11 @@ GEM
98
98
  guard-compat (~> 1.1)
99
99
  rspec (>= 2.99.0, < 4.0)
100
100
  hashie (3.5.5)
101
- heroics (0.0.21)
101
+ heroics (0.0.22)
102
102
  erubis (~> 2.0)
103
103
  excon
104
104
  multi_json (>= 1.9.2)
105
- hirefire-resource (0.4.0)
105
+ hirefire-resource (0.4.2)
106
106
  i18n (0.8.1)
107
107
  json (2.1.0)
108
108
  listen (3.1.5)
@@ -121,6 +121,7 @@ GEM
121
121
  mime-types-data (3.2016.0521)
122
122
  mini_portile2 (2.1.0)
123
123
  minitest (5.10.1)
124
+ moneta (0.8.1)
124
125
  multi_json (1.12.1)
125
126
  multipart-post (2.0.0)
126
127
  nenv (0.3.0)
@@ -134,8 +135,9 @@ GEM
134
135
  octokit (4.7.0)
135
136
  sawyer (~> 0.8.0, >= 0.5.3)
136
137
  pg (0.20.0)
137
- platform-api (0.8.0)
138
- heroics (~> 0.0.17)
138
+ platform-api (2.0.0)
139
+ heroics (~> 0.0.22)
140
+ moneta (~> 0.8.1)
139
141
  pry (0.10.4)
140
142
  coderay (~> 1.1.0)
141
143
  method_source (~> 0.8.1)
@@ -145,7 +147,7 @@ GEM
145
147
  pry (~> 0.10)
146
148
  public_suffix (2.0.5)
147
149
  rack (2.0.1)
148
- rack-protection (1.5.3)
150
+ rack-protection (2.0.0)
149
151
  rack
150
152
  rack-ssl-enforcer (0.2.9)
151
153
  rack-test (0.6.3)
@@ -5,8 +5,8 @@ source "https://rubygems.org"
5
5
  gem "guard"
6
6
  gem "guard-rspec"
7
7
  gem "appraisal"
8
- gem "rails", "~> 5.1"
9
- gem "sqlite3"
10
8
  gem "pg"
9
+ gem "sqlite3"
10
+ gem "rails", "~> 5.1"
11
11
 
12
12
  gemspec path: "../"
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- roo_on_rails (1.3.1)
4
+ roo_on_rails (1.4.0)
5
5
  dotenv-rails (~> 2.1)
6
6
  hashie (~> 3.4)
7
7
  hirefire-resource
8
8
  newrelic_rpm (~> 3.17)
9
9
  octokit
10
- platform-api (~> 0.8)
10
+ platform-api (~> 2.0)
11
11
  rack-ssl-enforcer
12
12
  rack-timeout
13
13
  rails (>= 3.2.22, < 5.2)
@@ -77,7 +77,7 @@ GEM
77
77
  railties (>= 3.2, < 5.2)
78
78
  erubi (1.6.0)
79
79
  erubis (2.7.0)
80
- excon (0.55.0)
80
+ excon (0.56.0)
81
81
  faraday (0.12.1)
82
82
  multipart-post (>= 1.2, < 3)
83
83
  ffi (1.9.18)
@@ -99,11 +99,11 @@ GEM
99
99
  guard-compat (~> 1.1)
100
100
  rspec (>= 2.99.0, < 4.0)
101
101
  hashie (3.5.5)
102
- heroics (0.0.21)
102
+ heroics (0.0.22)
103
103
  erubis (~> 2.0)
104
104
  excon
105
105
  multi_json (>= 1.9.2)
106
- hirefire-resource (0.4.0)
106
+ hirefire-resource (0.4.2)
107
107
  i18n (0.8.1)
108
108
  json (2.1.0)
109
109
  listen (3.1.5)
@@ -122,6 +122,7 @@ GEM
122
122
  mime-types-data (3.2016.0521)
123
123
  mini_portile2 (2.1.0)
124
124
  minitest (5.10.1)
125
+ moneta (0.8.1)
125
126
  multi_json (1.12.1)
126
127
  multipart-post (2.0.0)
127
128
  nenv (0.3.0)
@@ -135,8 +136,9 @@ GEM
135
136
  octokit (4.7.0)
136
137
  sawyer (~> 0.8.0, >= 0.5.3)
137
138
  pg (0.20.0)
138
- platform-api (0.8.0)
139
- heroics (~> 0.0.17)
139
+ platform-api (2.0.0)
140
+ heroics (~> 0.0.22)
141
+ moneta (~> 0.8.1)
140
142
  pry (0.10.4)
141
143
  coderay (~> 1.1.0)
142
144
  method_source (~> 0.8.1)
@@ -146,7 +148,7 @@ GEM
146
148
  pry (~> 0.10)
147
149
  public_suffix (2.0.5)
148
150
  rack (2.0.1)
149
- rack-protection (1.5.3)
151
+ rack-protection (2.0.0)
150
152
  rack
151
153
  rack-ssl-enforcer (0.2.9)
152
154
  rack-test (0.6.3)
@@ -15,7 +15,6 @@ module RooOnRails
15
15
  dependencies.any? ? @requires.merge(dependencies) : @requires
16
16
  end
17
17
 
18
-
19
18
  def initialize(options = {})
20
19
  @options = options.dup
21
20
  @fix = @options.delete(:fix) { false }
@@ -11,7 +11,7 @@ module RooOnRails
11
11
  super(options)
12
12
  @env = @options[:env]
13
13
  end
14
-
14
+
15
15
  def signature
16
16
  super + [@env]
17
17
  end
@@ -4,11 +4,13 @@ require 'roo_on_rails/checks/heroku/app_exists'
4
4
  require 'roo_on_rails/checks/heroku/preboot_enabled'
5
5
  require 'roo_on_rails/checks/heroku/app_exists'
6
6
  require 'roo_on_rails/checks/sidekiq/settings'
7
+ require 'roo_on_rails/checks/heroku/drains_metrics'
7
8
 
8
9
  module RooOnRails
9
10
  module Checks
10
11
  class Environment < EnvSpecific
11
12
  requires GitHub::BranchProtection
13
+ requires Heroku::DrainsMetrics
12
14
  requires Heroku::PrebootEnabled
13
15
  requires Sidekiq::Settings
14
16
 
@@ -14,7 +14,7 @@ module RooOnRails
14
14
  def call
15
15
  status, url = shell.run "git config remote.origin.url"
16
16
  fail! "Origin does not seem to be configured." unless status
17
-
17
+
18
18
  org, repo = url.strip.sub(%r{\.git$}, '').split(%r{[:/]}).last(2)
19
19
  context.git_org = org
20
20
  context.git_repo = repo
@@ -24,4 +24,3 @@ module RooOnRails
24
24
  end
25
25
  end
26
26
  end
27
-
@@ -26,7 +26,8 @@ module RooOnRails
26
26
  options.merge(
27
27
  required_status_checks: fixed_required_status_checks,
28
28
  required_pull_request_reviews: fixed_pull_request_reviews,
29
- restrictions: fixed_restrictions
29
+ restrictions: fixed_restrictions,
30
+ enforce_admins: true
30
31
  )
31
32
  )
32
33
  end
@@ -35,7 +36,9 @@ module RooOnRails
35
36
 
36
37
  def ensure_status_checks!
37
38
  status_checks = protection[:required_status_checks] || {}
38
- fail! 'status checks do not include admins' unless status_checks[:include_admins]
39
+ enforce_admins = protection[:enforce_admins]
40
+ fail! 'status checks are not enforced for admins' unless enforce_admins &&
41
+ enforce_admins[:enabled]
39
42
 
40
43
  contexts = status_checks[:contexts] || []
41
44
  ensure_ci_status_check!(contexts)
@@ -44,7 +47,7 @@ module RooOnRails
44
47
  end
45
48
 
46
49
  def ensure_ci_status_check!(contexts)
47
- fail! 'no CI status check' unless contexts.include?(ci_context)
50
+ fail! 'no continuous integration status check' unless contexts.include?(ci_context)
48
51
  end
49
52
 
50
53
  def ensure_analysis_status_check!(contexts)
@@ -58,20 +61,24 @@ module RooOnRails
58
61
 
59
62
  def ensure_code_reviews!
60
63
  reviews = protection[:required_pull_request_reviews] || {}
61
- fail! 'code reviews do not include admins' unless reviews[:include_admins]
64
+ fail! 'code approvals should be dismissed on push' unless reviews[:dismiss_stale_reviews]
65
+
66
+ users = reviews.dig(:dismissal_restrictions, :users)
67
+ teams = reviews.dig(:dismissal_restrictions, :teams)
68
+ fail! 'review dismissal restrictions should be enabled' if users.nil? || teams.nil?
69
+ fail! 'nobody should be allowed to dismiss reviews' if users.any? || teams.any?
62
70
  end
63
71
 
64
72
  def ensure_no_push!
65
73
  users = protection.dig(:restrictions, :users)
66
74
  teams = protection.dig(:restrictions, :teams)
67
75
  fail! 'push restrictions should be enabled' if users.nil? || teams.nil?
68
- fail! 'no users or teams should be allowed to push to master' if users.any? || teams.any?
76
+ fail! 'nobody should be allowed to push to master' if users.any? || teams.any?
69
77
  end
70
78
 
71
79
  def fixed_required_status_checks
72
80
  status_checks = protection[:required_status_checks] || {}
73
81
  status_checks.merge(
74
- include_admins: true,
75
82
  contexts: (status_checks[:contexts] || []) | [
76
83
  ci_context,
77
84
  analysis_context,
@@ -82,7 +89,10 @@ module RooOnRails
82
89
 
83
90
  def fixed_pull_request_reviews
84
91
  reviews = protection[:required_pull_request_reviews] || {}
85
- reviews.merge(include_admins: true)
92
+ reviews.merge(
93
+ dismiss_stale_reviews: true,
94
+ dismissal_restrictions: { users: [], teams: [] }
95
+ )
86
96
  end
87
97
 
88
98
  def fixed_restrictions
@@ -7,7 +7,7 @@ module RooOnRails
7
7
  module Checks
8
8
  module Heroku
9
9
  # Check if a corresponding app exists on Heroku (for a given environment)
10
- #
10
+ #
11
11
  # Input context
12
12
  # - git_repo: the name of the repository
13
13
  # - heroku.api_client: a connected PlatformAPI client
@@ -31,7 +31,8 @@ module RooOnRails
31
31
  end
32
32
 
33
33
  if matches.many?
34
- final_fail! "multiple matching apps detected: #{candidates.map { |c| bold c}.join(', ')}"
34
+ list = candidates.map { |c| bold c }.join(', ')
35
+ final_fail! "multiple matching apps detected: #{list}"
35
36
  end
36
37
 
37
38
  context.heroku.app![env] = matches.first
@@ -0,0 +1,58 @@
1
+ require 'roo_on_rails/checks/env_specific'
2
+ require 'roo_on_rails/checks/git/origin'
3
+ require 'roo_on_rails/checks/heroku/app_exists'
4
+ require 'roo_on_rails/checks/heroku/metrics_bridge_configured'
5
+ require 'uri'
6
+
7
+ module RooOnRails
8
+ module Checks
9
+ module Heroku
10
+ # Checks that the app is configured to send its logs to the Heroku-Datadog
11
+ # metrics bridge.
12
+ #
13
+ # Input context
14
+ # - heroku.api_client: a connected PlatformAPI client
15
+ # - heroku.app.{env}: an existing app name.
16
+ # - heroku.metric_bridge_token.{env}: the password for the metrics bridge
17
+ class DrainsMetrics < EnvSpecific
18
+ requires Heroku::AppExists, MetricsBridgeConfigured
19
+
20
+ def intro
21
+ "Checking for metrics drain on #{bold app_name}"
22
+ end
23
+
24
+ def call
25
+ url = client.log_drain.list(app_name).
26
+ map { |h| h['url'] }.
27
+ find { |u| u.include? MetricsBridgeConfigured::BRIDGE_APP }
28
+
29
+ fail! 'No matching drain found' if url.nil?
30
+ final_fail! 'Misconfigured drain found' if url != drain_uri
31
+ pass 'Drain is connected'
32
+ end
33
+
34
+ private
35
+
36
+ def fix
37
+ client.log_drain.create(app_name, url: drain_uri)
38
+ end
39
+
40
+ def drain_uri
41
+ 'https://%s:%s@%s.herokuapp.com' % [
42
+ app_name,
43
+ context.heroku.metric_bridge_token![env],
44
+ MetricsBridgeConfigured::BRIDGE_APP
45
+ ]
46
+ end
47
+
48
+ def app_name
49
+ context.heroku.app[env]
50
+ end
51
+
52
+ def client
53
+ context.heroku.api_client
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -27,4 +27,3 @@ module RooOnRails
27
27
  end
28
28
  end
29
29
  end
30
-
@@ -0,0 +1,79 @@
1
+ require 'roo_on_rails/checks/env_specific'
2
+ require 'roo_on_rails/checks/git/origin'
3
+ require 'roo_on_rails/checks/heroku/app_exists'
4
+ require 'securerandom'
5
+ require 'set'
6
+
7
+ module RooOnRails
8
+ module Checks
9
+ module Heroku
10
+ # Checks that the Heroku-Datadog metrics bridge is configured to accept
11
+ # logs from the app.
12
+ #
13
+ # Input context
14
+ # - heroku.api_client: a connected PlatformAPI client
15
+ # - heroku.app.{env}: an existing app name.
16
+ #
17
+ # Output context:
18
+ # - heroku.metric_bridge_token.{env}: the password for the metrics bridge
19
+ class MetricsBridgeConfigured < EnvSpecific
20
+ requires Heroku::AppExists
21
+
22
+ BRIDGE_APP = 'roo-dd-bridge-production'.freeze
23
+
24
+ def intro
25
+ "Checking whether metrics bridge is configured for #{bold app_name}"
26
+ end
27
+
28
+ def call
29
+ config = current_config
30
+ names = config[app_list_var].split(',')
31
+
32
+ fail! 'Bridge does not allow this app' unless names.include? app_name
33
+ fail! 'Bridge lacks credentials for this app' unless config[token_var]
34
+ fail! 'Bridge lacks tags for this app' unless config[tags_var]
35
+
36
+ pass 'Bridge is configured'
37
+ context.heroku.metric_bridge_token![env] = config[token_var]
38
+ end
39
+
40
+ private
41
+
42
+ def fix
43
+ app_list = Set.new current_config.fetch(app_list_var, '').split(',')
44
+ app_list << app_name
45
+ client.config_var.update(
46
+ BRIDGE_APP,
47
+ tags_var => "app:#{app_name}",
48
+ token_var => SecureRandom.hex(16),
49
+ app_list_var => app_list.to_a.join(',')
50
+ )
51
+ end
52
+
53
+ def current_config
54
+ client.config_var.info_for_app(BRIDGE_APP)
55
+ end
56
+
57
+ def app_list_var
58
+ 'ALLOWED_APPS'
59
+ end
60
+
61
+ def tags_var
62
+ '%s_TAGS' % app_name.upcase
63
+ end
64
+
65
+ def token_var
66
+ '%s_PASSWORD' % app_name.upcase
67
+ end
68
+
69
+ def app_name
70
+ context.heroku.app[env]
71
+ end
72
+
73
+ def client
74
+ context.heroku.api_client
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -10,7 +10,7 @@ module RooOnRails
10
10
  # - heroku.app.{env}: an existing app name.
11
11
  class PrebootEnabled < EnvSpecific
12
12
  requires Git::Origin, Heroku::AppExists
13
-
13
+
14
14
  def intro
15
15
  "Checking preboot status on #{bold app_name}"
16
16
  end
@@ -20,4 +20,3 @@ module RooOnRails
20
20
  end
21
21
  end
22
22
  end
23
-
@@ -4,4 +4,3 @@ module RooOnRails
4
4
  FinalFailure = Class.new(Failure)
5
5
  end
6
6
  end
7
-
@@ -1,8 +1,8 @@
1
1
  module RooOnRails
2
2
  module Railties
3
3
  class Database < Rails::Railtie
4
- if ActiveRecord::VERSION::MAJOR >= 4
5
- initializer 'roo_on_rails.database', after: 'active_record.initialize_database' do
4
+ initializer 'roo_on_rails.database', after: 'active_record.initialize_database' do
5
+ ActiveSupport.on_load :active_record do
6
6
  $stderr.puts 'initializer roo_on_rails.database'
7
7
 
8
8
  config = ActiveRecord::Base.configurations[Rails.env]
@@ -1,27 +1,29 @@
1
- namespace :db do
2
- desc 'Prints out the database statement timeout'
3
- task statement_timeout: :environment do
4
- result = ActiveRecord::Base.connection.execute('SHOW statement_timeout').first
5
- puts result['statement_timeout']
6
- end
1
+ if defined?(ActiveRecord)
2
+ namespace :db do
3
+ desc 'Prints out the database statement timeout'
4
+ task statement_timeout: :environment do
5
+ result = ActiveRecord::Base.connection.execute('SHOW statement_timeout').first
6
+ puts result['statement_timeout']
7
+ end
7
8
 
8
- namespace :migrate do
9
- task extend_statement_timeout: :environment do
10
- if ActiveRecord::VERSION::MAJOR >= 4
11
- config = ActiveRecord::Base.configurations[Rails.env]
12
- config['variables'] ||= {}
13
- config['variables']['statement_timeout'] = ENV.fetch('MIGRATION_STATEMENT_TIMEOUT', 10_000)
14
- ActiveRecord::Base.establish_connection
9
+ namespace :migrate do
10
+ task extend_statement_timeout: :environment do
11
+ if ActiveRecord::VERSION::MAJOR >= 4
12
+ config = ActiveRecord::Base.configurations[Rails.env]
13
+ config['variables'] ||= {}
14
+ config['variables']['statement_timeout'] = ENV.fetch('MIGRATION_STATEMENT_TIMEOUT', 10_000)
15
+ ActiveRecord::Base.establish_connection
16
+ end
15
17
  end
16
18
  end
17
19
  end
18
- end
19
20
 
20
- %i[
21
- db:create
22
- db:migrate
23
- db:migrate:down
24
- db:rollback
25
- ].each do |task|
26
- Rake::Task[task].enhance(%i[db:migrate:extend_statement_timeout])
21
+ %i[
22
+ db:create
23
+ db:migrate
24
+ db:migrate:down
25
+ db:rollback
26
+ ].each do |task|
27
+ Rake::Task[task].enhance(%i[db:migrate:extend_statement_timeout])
28
+ end
27
29
  end
@@ -0,0 +1,25 @@
1
+ namespace :newrelic do
2
+ desc 'Notifies New Relic that a deployment has occurred'
3
+ task notice_deployment: :environment do
4
+ begin
5
+ require 'newrelic_rpm'
6
+ require 'new_relic/cli/command'
7
+
8
+ appname = ENV.fetch('NEW_RELIC_APP_NAME')
9
+
10
+ Rails.logger.info("Notifying New Relic of deployment to #{appname}")
11
+ NewRelic::Cli::Deployments.new(
12
+ environment: Rails.env.to_s,
13
+ revision: ENV.fetch('SOURCE_VERSION', 'unknown'),
14
+ changelog: '',
15
+ description: '',
16
+ appname: appname,
17
+ user: '',
18
+ license_key: ENV.fetch('NEW_RELIC_LICENSE_KEY')
19
+ ).run
20
+ rescue => e
21
+ Rails.logger.error("Failed to notify New Relic (#{e.class.name}: #{e.message})")
22
+ Rails.logger.info(e.backtrace.take(10).join("\n"))
23
+ end
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module RooOnRails
2
- VERSION = '1.3.1'
2
+ VERSION = '1.4.0'.freeze
3
3
  end
data/roo_on_rails.gemspec CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_runtime_dependency 'dotenv-rails', '~> 2.1'
25
25
  spec.add_runtime_dependency 'newrelic_rpm', '~> 3.17'
26
26
  spec.add_runtime_dependency 'rails', '>= 3.2.22', '< 5.2'
27
- spec.add_runtime_dependency 'platform-api', '~> 0.8'
27
+ spec.add_runtime_dependency 'platform-api', '~> 2.0'
28
28
  spec.add_runtime_dependency 'hashie', '~> 3.4'
29
29
  spec.add_runtime_dependency 'rack-timeout'
30
30
  spec.add_runtime_dependency 'rack-ssl-enforcer'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roo_on_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Letessier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-05 00:00:00.000000000 Z
11
+ date: 2017-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv-rails
@@ -64,14 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '0.8'
67
+ version: '2.0'
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '0.8'
74
+ version: '2.0'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: hashie
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -276,6 +276,7 @@ executables:
276
276
  extensions: []
277
277
  extra_rdoc_files: []
278
278
  files:
279
+ - ".codeclimate.yml"
279
280
  - ".codecov.yml"
280
281
  - ".gitignore"
281
282
  - ".rspec"
@@ -311,7 +312,9 @@ files:
311
312
  - lib/roo_on_rails/checks/github/token.rb
312
313
  - lib/roo_on_rails/checks/helpers.rb
313
314
  - lib/roo_on_rails/checks/heroku/app_exists.rb
315
+ - lib/roo_on_rails/checks/heroku/drains_metrics.rb
314
316
  - lib/roo_on_rails/checks/heroku/login.rb
317
+ - lib/roo_on_rails/checks/heroku/metrics_bridge_configured.rb
315
318
  - lib/roo_on_rails/checks/heroku/preboot_enabled.rb
316
319
  - lib/roo_on_rails/checks/heroku/token.rb
317
320
  - lib/roo_on_rails/checks/heroku/toolbelt_installed.rb
@@ -336,6 +339,7 @@ files:
336
339
  - lib/roo_on_rails/sidekiq/settings.rb
337
340
  - lib/roo_on_rails/sidekiq/sla_metric.rb
338
341
  - lib/roo_on_rails/tasks/db.rake
342
+ - lib/roo_on_rails/tasks/newrelic.rake
339
343
  - lib/roo_on_rails/version.rb
340
344
  - roo_on_rails.gemspec
341
345
  homepage: https://github.com/deliveroo/roo_on_rails