roo_on_rails 1.20.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +398 -282
- data/.circleci/config.yml.erb +63 -21
- data/.codecov.yml +3 -0
- data/Appraisals +24 -11
- data/CHANGELOG.md +39 -0
- data/README.md +20 -31
- data/appraise +1 -1
- data/exe/roo_on_rails +5 -0
- data/gemfiles/rails_4.gemfile +3 -1
- data/gemfiles/rails_5.gemfile +2 -1
- data/gemfiles/rails_5_1.gemfile +3 -2
- data/gemfiles/rails_5_2.gemfile +15 -0
- data/gemfiles/{rails_3.gemfile → rails_6.gemfile} +5 -4
- data/lib/roo_on_rails.rb +1 -4
- data/lib/roo_on_rails/checks/documentation/playbook_template.md +0 -4
- data/lib/roo_on_rails/concerns/require_api_key.rb +0 -1
- data/lib/roo_on_rails/config.rb +0 -8
- data/lib/roo_on_rails/default.env +0 -13
- data/lib/roo_on_rails/rack/populate_env_from_jwt.rb +25 -4
- data/lib/roo_on_rails/railties/database.rb +11 -10
- data/lib/roo_on_rails/railties/env.rb +3 -5
- data/lib/roo_on_rails/railties/google_oauth.rb +4 -6
- data/lib/roo_on_rails/railties/http.rb +34 -32
- data/lib/roo_on_rails/railties/roo_identity.rb +12 -8
- data/lib/roo_on_rails/railties/{sidekiq.rb → sidekiq_integration.rb} +18 -18
- data/lib/roo_on_rails/version.rb +1 -1
- data/roo_on_rails.gemspec +5 -6
- metadata +28 -57
- data/.travis.yml +0 -34
- data/README.routemaster_client.md +0 -103
- data/lib/roo_on_rails/railties/logging.rb +0 -25
- data/lib/roo_on_rails/railties/new_relic.rb +0 -32
- data/lib/roo_on_rails/railties/routemaster.rb +0 -42
- data/lib/roo_on_rails/routemaster/lifecycle_events.rb +0 -64
- data/lib/roo_on_rails/routemaster/publish_lifecycle_events.rb +0 -13
- data/lib/roo_on_rails/routemaster/publisher.rb +0 -74
- data/lib/roo_on_rails/routemaster/publishers.rb +0 -27
- data/lib/roo_on_rails/tasks/newrelic.rake +0 -25
data/.circleci/config.yml.erb
CHANGED
@@ -1,18 +1,36 @@
|
|
1
1
|
# To update the build configuration, edit the "builds" array below and run:
|
2
2
|
# erb .circleci/config.yml.erb > .circleci/config.yml
|
3
|
+
|
4
|
+
|
5
|
+
# The default Ruby containers modify the behaviour of Bundler in a way that breaks
|
6
|
+
# the CI since it makes it harder to run multiple apps in a single container
|
7
|
+
# See https://github.com/docker-library/docs/pull/1221/files for a summary
|
8
|
+
# Unsettting these variables restores the default behaviour:-
|
9
|
+
# * BUNDLE_APP_CONFIG
|
10
|
+
# * GEM_HOME
|
11
|
+
# * BUNDLE_PATH
|
12
|
+
# * BUNDLE_BIN
|
13
|
+
common_ruby_environment: &common_ruby_environment
|
14
|
+
environment:
|
15
|
+
RAILS_ENV: test
|
16
|
+
PGHOST: 127.0.0.1
|
17
|
+
PGUSER: postgres
|
18
|
+
POSTGRES_HOST_AUTH_METHOD: "trust"
|
19
|
+
common_pg_environment_vars: &common_pg_environment_vars
|
20
|
+
POSTGRES_USER: postgres
|
21
|
+
POSTGRES_DB: ror_testapp_test
|
22
|
+
POSTGRES_HOST_AUTH_METHOD: "trust"
|
3
23
|
<%
|
4
24
|
builds = [
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
['2.3.3', 'rails_5_1'],
|
15
|
-
['2.4.0', 'rails_5_1'],
|
25
|
+
['2.4.6', 'rails_4'],
|
26
|
+
['2.4.6', 'rails_5'],
|
27
|
+
['2.4.6', 'rails_5_1'],
|
28
|
+
['2.4.6', 'rails_5_2'],
|
29
|
+
['2.5.5', 'rails_4'],
|
30
|
+
['2.5.5', 'rails_5'],
|
31
|
+
['2.5.5', 'rails_5_1'],
|
32
|
+
['2.5.5', 'rails_5_2'],
|
33
|
+
['2.6.5', 'rails_6']
|
16
34
|
]
|
17
35
|
%>
|
18
36
|
version: 2
|
@@ -20,11 +38,13 @@ jobs:
|
|
20
38
|
<% builds.each do |ruby,variant| %>
|
21
39
|
build_<%= ruby %>_<%= variant %>:
|
22
40
|
docker:
|
23
|
-
- image:
|
41
|
+
- image: ruby:<%= ruby %>-alpine
|
42
|
+
<<: *common_ruby_environment
|
24
43
|
- image: postgres:9.6-alpine
|
25
44
|
environment:
|
26
45
|
PGDATA: /dev/shm/pgdata
|
27
|
-
|
46
|
+
<<: *common_pg_environment_vars
|
47
|
+
- image: redis:4-alpine
|
28
48
|
steps:
|
29
49
|
- checkout
|
30
50
|
|
@@ -36,28 +56,50 @@ jobs:
|
|
36
56
|
ln -s /dev/shm/tmp ~/project/tmp
|
37
57
|
|
38
58
|
- run:
|
39
|
-
name:
|
59
|
+
name: Setup requirements
|
60
|
+
command: |
|
61
|
+
apk add --update git bash build-base postgresql-dev sqlite-dev tzdata nodejs
|
62
|
+
|
63
|
+
- run:
|
64
|
+
name: Configure bundler
|
40
65
|
command: |
|
41
|
-
|
42
|
-
|
66
|
+
unset \
|
67
|
+
BUNDLE_APP_CONFIG \
|
68
|
+
GEM_HOME \
|
69
|
+
BUNDLE_PATH \
|
70
|
+
BUNDLE_BIN
|
43
71
|
bundle config --local gemfile $PWD/gemfiles/<%= variant %>.gemfile
|
44
72
|
|
45
73
|
- restore_cache:
|
46
|
-
keys:
|
74
|
+
keys:
|
47
75
|
- v2-bundle-<%= ruby %>-<%= variant %>-{{ .Branch }}
|
48
76
|
- v2-bundle-<%= ruby %>-<%= variant %>
|
49
77
|
- v2-bundle-<%= ruby %>
|
50
78
|
|
51
|
-
- run:
|
52
|
-
name: Install
|
79
|
+
- run:
|
80
|
+
name: Install bundle
|
53
81
|
command: |
|
82
|
+
unset \
|
83
|
+
BUNDLE_APP_CONFIG \
|
84
|
+
GEM_HOME \
|
85
|
+
BUNDLE_PATH \
|
86
|
+
BUNDLE_BIN
|
54
87
|
bundle install --jobs=3 --retry=3 --path=$PWD/vendor/bundle
|
55
88
|
|
89
|
+
# The default Ruby containers modify the behaviour of Bundler in a way that breaks
|
90
|
+
# the CI since it makes it harder to run multiple apps in a single container
|
91
|
+
# See https://github.com/docker-library/docs/pull/1221/files for a summary
|
92
|
+
# Unsettting the variables restores the default behaviour
|
56
93
|
- run:
|
57
94
|
name: Run test suite
|
58
95
|
command: |
|
59
|
-
unset
|
60
|
-
|
96
|
+
unset \
|
97
|
+
RACK_ENV \
|
98
|
+
RAILS_ENV \
|
99
|
+
BUNDLE_APP_CONFIG \
|
100
|
+
GEM_HOME \
|
101
|
+
BUNDLE_PATH \
|
102
|
+
BUNDLE_BIN
|
61
103
|
bundle exec rspec
|
62
104
|
|
63
105
|
- save_cache:
|
data/.codecov.yml
CHANGED
data/Appraisals
CHANGED
@@ -1,24 +1,37 @@
|
|
1
|
-
appraise 'rails-3' do
|
2
|
-
gem 'rails', '~> 3.2'
|
3
|
-
gem 'sqlite3'
|
4
|
-
gem 'sidekiq', '< 5'
|
5
|
-
gem 'pg', '~> 0.11'
|
6
|
-
end
|
7
|
-
|
8
1
|
appraise 'rails-4' do
|
9
2
|
gem 'rails', '~> 4.2'
|
10
|
-
gem 'sqlite3'
|
3
|
+
gem 'sqlite3', '~> 1.3.6'
|
11
4
|
gem 'pg', '~> 0.11'
|
5
|
+
gem 'sprockets', '~>3.0'
|
6
|
+
gem 'rake', '13.0.1'
|
12
7
|
end
|
13
8
|
|
14
9
|
appraise 'rails-5' do
|
15
10
|
gem 'rails', '~> 5.0.0'
|
16
|
-
gem 'sqlite3'
|
11
|
+
gem 'sqlite3', '~> 1.3.6'
|
17
12
|
gem 'pg', '~> 0.18'
|
13
|
+
gem 'rake', '13.0.1'
|
18
14
|
end
|
19
15
|
|
20
16
|
appraise 'rails-5-1' do
|
21
|
-
gem 'rails', '~> 5.1'
|
22
|
-
gem 'sqlite3'
|
17
|
+
gem 'rails', '~> 5.1.0'
|
18
|
+
gem 'sqlite3', '~> 1.3.6'
|
19
|
+
gem 'pg', '~> 0.18'
|
20
|
+
gem 'rake', '13.0.1'
|
21
|
+
end
|
22
|
+
|
23
|
+
appraise 'rails-5-2' do
|
24
|
+
gem 'rails', '~> 5.2.0'
|
25
|
+
gem 'bootsnap', '>= 1.1.0', require: false
|
26
|
+
gem 'sqlite3', '~> 1.3.6'
|
27
|
+
gem 'pg', '~> 0.18'
|
28
|
+
gem 'rake', '13.0.1'
|
29
|
+
end
|
30
|
+
|
31
|
+
appraise 'rails-6' do
|
32
|
+
gem 'rails', '~> 6.0.3'
|
33
|
+
gem 'bootsnap', '>= 1.1.0', require: false
|
34
|
+
gem 'sqlite3', '~> 1.4'
|
23
35
|
gem 'pg', '~> 0.18'
|
36
|
+
gem 'rake', '13.0.1'
|
24
37
|
end
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,42 @@
|
|
1
|
+
# v2.1.0
|
2
|
+
|
3
|
+
Features:
|
4
|
+
|
5
|
+
- Rails 6 compatibility
|
6
|
+
|
7
|
+
# v2.0.0-pre.2
|
8
|
+
|
9
|
+
Features:
|
10
|
+
|
11
|
+
- Removes routemaster
|
12
|
+
|
13
|
+
# v2.0.0-pre.1
|
14
|
+
|
15
|
+
Features:
|
16
|
+
|
17
|
+
- Remove New Relic
|
18
|
+
|
19
|
+
# v1.23.0 (2019-04-24)
|
20
|
+
|
21
|
+
Features:
|
22
|
+
|
23
|
+
- Setting DATABASE_STATEMENT_TIMEOUT to -1 will prevent the app setting any timeout.
|
24
|
+
Setting timeouts from the app conflicts with PGBouncer and should be disabled if
|
25
|
+
using one.
|
26
|
+
|
27
|
+
# v1.22.0 (2018-08-29)
|
28
|
+
|
29
|
+
Features:
|
30
|
+
|
31
|
+
- Allows specifying `BASE_NEW_RELIC_APP_NAME` instead of `NEW_RELIC_APP_NAME`, which reports to New Relic per Hopper service.
|
32
|
+
|
33
|
+
# v1.21.0 (2018-03-27)
|
34
|
+
|
35
|
+
Features:
|
36
|
+
|
37
|
+
- Rails 5.2 compatibility
|
38
|
+
|
39
|
+
|
1
40
|
# v1.20.0 (2018-03-27)
|
2
41
|
|
3
42
|
Features:
|
data/README.md
CHANGED
@@ -17,17 +17,20 @@
|
|
17
17
|
|
18
18
|
- [Installation](#installation)
|
19
19
|
- [Library usage](#library-usage)
|
20
|
-
- [New Relic configuration](#new-relic-configuration)
|
21
20
|
- [Rack middleware](#rack-middleware)
|
21
|
+
- [Disabling SSL enforcement](#disabling-ssl-enforcement)
|
22
22
|
- [Database configuration](#database-configuration)
|
23
23
|
- [Sidekiq](#sidekiq)
|
24
24
|
- [HireFire](#hirefire)
|
25
|
+
- [For Web Dynos](#for-web-dynos)
|
26
|
+
- [For Sidekiq Workers](#for-sidekiq-workers)
|
25
27
|
- [Logging](#logging)
|
26
28
|
- [Identity](#identity)
|
27
29
|
- [Google OAuth authentication](#google-oauth-authentication)
|
28
30
|
- [Datadog Integration](#datadog-integration)
|
29
|
-
|
30
|
-
|
31
|
+
- [Heroku metrics](#heroku-metrics)
|
32
|
+
- [Custom application metrics](#custom-application-metrics)
|
33
|
+
- [API Authentication](#api-authentication)
|
31
34
|
- [Command features](#command-features)
|
32
35
|
- [Usage](#usage)
|
33
36
|
- [Description](#description)
|
@@ -48,11 +51,6 @@ Remove the following gems from your Gemfile, as they're provided and configured
|
|
48
51
|
by `roo_on_rails`:
|
49
52
|
|
50
53
|
- `dotenv`
|
51
|
-
- `newrelic_rpm`
|
52
|
-
|
53
|
-
Remove the following configuration files:
|
54
|
-
|
55
|
-
- `newrelic.yml` or `config/newrelic.yml`
|
56
54
|
|
57
55
|
Also remove any other gem-specific configuration from your repository.
|
58
56
|
|
@@ -62,23 +60,19 @@ And then execute:
|
|
62
60
|
|
63
61
|
Then re-run your test suite to make sure everything is shipshape.
|
64
62
|
|
65
|
-
##
|
63
|
+
## Running specs
|
66
64
|
|
67
|
-
|
65
|
+
To run the specs locally, you will need to run the following command:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
bundle config --local gemfile $PWD/gemfiles/<%= variant %>.gemfile
|
69
|
+
```
|
68
70
|
|
69
|
-
|
71
|
+
Where `<%= variant %>` is the Rails version you'd like to test (e.g. `rails_5_2`).
|
70
72
|
|
71
|
-
|
72
|
-
otherwise it will abort.
|
73
|
-
2. No `new_relic.yml` file may be presentin your app. Overrides to New Relic settings
|
74
|
-
through [environment
|
75
|
-
variables](https://docs.newrelic.com/docs/agents/ruby-agent/installation-configuration/ruby-agent-configuration)
|
76
|
-
is permitted.
|
77
|
-
3. The `NEW_RELIC_APP_NAME` environment variable must be defined
|
78
|
-
such that the app will be properly registered in New Relic.
|
73
|
+
`bundle exec rspec` should then work as normal.
|
79
74
|
|
80
|
-
|
81
|
-
our standard settings.
|
75
|
+
## Library usage
|
82
76
|
|
83
77
|
### Rack middleware
|
84
78
|
|
@@ -104,6 +98,11 @@ To do this, you can set the `ROO_ON_RAILS_DISABLE_SSL_ENFORCEMENT` to `YES`.
|
|
104
98
|
The database statement timeout will be set to a low value by default. Use
|
105
99
|
`DATABASE_STATEMENT_TIMEOUT` (milliseconds, default 200) to customise.
|
106
100
|
|
101
|
+
When using a PGBouncer, setting the timeout from the application will cause
|
102
|
+
inconsistent results. The timeout should always be set using the RDS parameter
|
103
|
+
group in thise case. To prevent the app trying to set a timeout, set
|
104
|
+
`DATABASE_STATEMENT_TIMEOUT` to -1.
|
105
|
+
|
107
106
|
For database creation and migration (specifically the `db:create`, `db:migrate`,
|
108
107
|
`db:migrate:down` and `db:rollback` tasks) a much higher statement timeout is
|
109
108
|
set by default. Use `MIGRATION_STATEMENT_TIMEOUT` (milliseconds, default 10000)
|
@@ -302,16 +301,6 @@ The following tags will automatically be added to all your metrics and their val
|
|
302
301
|
* `HOPPER_APP_NAME`+`HOPPER_ECS_CLUSTER_NAME` – automatically set by Hopper (e.g. `notifications-staging`);
|
303
302
|
* Defaults to `unknown`.
|
304
303
|
|
305
|
-
### Routemaster Client
|
306
|
-
|
307
|
-
When `ROUTEMASTER_ENABLED` is set to `true` we attempt to configure [`routemaster-client`](https://github.com/deliveroo/routemaster-client) on your application. In order for this to happen, set the following environment variables:
|
308
|
-
|
309
|
-
* `ROUTEMASTER_URL` – the full URL of your Routemaster application (mandatory)
|
310
|
-
* `ROUTEMASTER_UUID` – the UUID of your application, e.g. `logistics-dashboard` (mandatory)
|
311
|
-
* `ROUTEMASTER_VERIFY_SSL` – set to false if your Routemaster application is not served with a valid cert. (optional)
|
312
|
-
|
313
|
-
If you then want to enable the publishing of events onto the event bus, you need to set `ROUTEMASTER_PUBLISHING_ENABLED` to `true` and implement publishers as needed. An example of how to do this is detailed in [`README.routemaster_client.md`](README.routemaster_client.md).
|
314
|
-
|
315
304
|
### API Authentication
|
316
305
|
|
317
306
|
RooOnRails provides a concern which will make adding rotatable API authentication to your service a breeze:
|
data/appraise
CHANGED
data/exe/roo_on_rails
CHANGED
@@ -36,6 +36,11 @@ module RooOnRails
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def run
|
39
|
+
# Force output to be unbuffered, otherwise the CI
|
40
|
+
# tests will fail because the parent app won't see
|
41
|
+
# the log output from the test app
|
42
|
+
$stdout.sync = true
|
43
|
+
$stderr.sync = true
|
39
44
|
_assert_argv_length(0..0)
|
40
45
|
require 'roo_on_rails/sidekiq/loader'
|
41
46
|
RooOnRails::Sidekiq::Loader.run
|
data/gemfiles/rails_4.gemfile
CHANGED
data/gemfiles/rails_5.gemfile
CHANGED
data/gemfiles/rails_5_1.gemfile
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "guard"
|
6
|
+
gem "guard-rspec"
|
7
|
+
gem "appraisal"
|
8
|
+
gem "webmock"
|
9
|
+
gem "pg", "~> 0.18"
|
10
|
+
gem "sqlite3", "~> 1.3.6"
|
11
|
+
gem "rails", "~> 5.2.0"
|
12
|
+
gem "bootsnap", ">= 1.1.0", require: false
|
13
|
+
gem "rake", "13.0.1"
|
14
|
+
|
15
|
+
gemspec path: "../"
|
@@ -6,9 +6,10 @@ gem "guard"
|
|
6
6
|
gem "guard-rspec"
|
7
7
|
gem "appraisal"
|
8
8
|
gem "webmock"
|
9
|
-
gem "pg", "~> 0.
|
10
|
-
gem "sqlite3"
|
11
|
-
gem "rails", "~> 3
|
12
|
-
gem "
|
9
|
+
gem "pg", "~> 0.18"
|
10
|
+
gem "sqlite3", "~> 1.4"
|
11
|
+
gem "rails", "~> 6.0.3"
|
12
|
+
gem "bootsnap", ">= 1.1.0", require: false
|
13
|
+
gem "rake", "13.0.1"
|
13
14
|
|
14
15
|
gemspec path: "../"
|
data/lib/roo_on_rails.rb
CHANGED
@@ -5,14 +5,11 @@ end
|
|
5
5
|
|
6
6
|
if defined?(Rails)
|
7
7
|
require 'dotenv/rails-now'
|
8
|
-
require 'roo_on_rails/railties/logging'
|
9
8
|
require 'roo_on_rails/railties/env'
|
10
|
-
require 'roo_on_rails/railties/new_relic'
|
11
9
|
require 'roo_on_rails/railties/database'
|
12
10
|
require 'roo_on_rails/railties/http'
|
13
|
-
require 'roo_on_rails/railties/
|
11
|
+
require 'roo_on_rails/railties/sidekiq_integration'
|
14
12
|
require 'roo_on_rails/railties/rake_tasks'
|
15
13
|
require 'roo_on_rails/railties/google_oauth'
|
16
|
-
require 'roo_on_rails/railties/routemaster'
|
17
14
|
require 'roo_on_rails/railties/roo_identity'
|
18
15
|
end
|
@@ -20,10 +20,6 @@ As a last resort, in an emergency, the following people have experience working
|
|
20
20
|
|
21
21
|
FIXME: A very brief high-level explanation of what this functional area does
|
22
22
|
|
23
|
-
#### 🚨 FIXME: a New Relic alert which might be raised - named so it can be searched for
|
24
|
-
|
25
|
-
FIXME: A description of the New Relic alert, what it means for the service, and what actions should be taken to remedy the situation.
|
26
|
-
|
27
23
|
#### 🚨 FIXME: an action which might need to be taken during an incident
|
28
24
|
|
29
25
|
FIXME: A description of how to perform this action, and any side-effects that the on-call engineer should be aware of.
|
@@ -58,7 +58,6 @@ module RooOnRails
|
|
58
58
|
def valid?(service_name, client_key)
|
59
59
|
return false unless whitelisted?(service_name)
|
60
60
|
|
61
|
-
NewRelic::Agent.add_custom_attributes(httpBasicUserId: service_name) if defined?(NewRelic)
|
62
61
|
ClientApiKeys.instance.valid?(service_name, client_key)
|
63
62
|
end
|
64
63
|
|