roo_on_rails 1.21.0 → 2.1.2
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 +446 -150
- data/.circleci/config.yml.erb +63 -18
- data/.codecov.yml +3 -0
- data/Appraisals +17 -11
- data/CHANGELOG.md +38 -0
- data/README.md +23 -74
- 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 +2 -1
- data/gemfiles/rails_5_2.gemfile +2 -1
- data/gemfiles/{rails_3.gemfile → rails_6.gemfile} +5 -4
- data/lib/roo_on_rails.rb +0 -3
- 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 +26 -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_integration.rb +7 -19
- data/lib/roo_on_rails/version.rb +1 -1
- data/roo_on_rails.gemspec +4 -6
- metadata +24 -68
- 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,15 +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
|
-
|
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']
|
13
34
|
]
|
14
35
|
%>
|
15
36
|
version: 2
|
@@ -17,11 +38,13 @@ jobs:
|
|
17
38
|
<% builds.each do |ruby,variant| %>
|
18
39
|
build_<%= ruby %>_<%= variant %>:
|
19
40
|
docker:
|
20
|
-
- image:
|
41
|
+
- image: ruby:<%= ruby %>-alpine
|
42
|
+
<<: *common_ruby_environment
|
21
43
|
- image: postgres:9.6-alpine
|
22
44
|
environment:
|
23
45
|
PGDATA: /dev/shm/pgdata
|
24
|
-
|
46
|
+
<<: *common_pg_environment_vars
|
47
|
+
- image: redis:4-alpine
|
25
48
|
steps:
|
26
49
|
- checkout
|
27
50
|
|
@@ -33,28 +56,50 @@ jobs:
|
|
33
56
|
ln -s /dev/shm/tmp ~/project/tmp
|
34
57
|
|
35
58
|
- run:
|
36
|
-
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
|
37
65
|
command: |
|
38
|
-
|
39
|
-
|
66
|
+
unset \
|
67
|
+
BUNDLE_APP_CONFIG \
|
68
|
+
GEM_HOME \
|
69
|
+
BUNDLE_PATH \
|
70
|
+
BUNDLE_BIN
|
40
71
|
bundle config --local gemfile $PWD/gemfiles/<%= variant %>.gemfile
|
41
72
|
|
42
73
|
- restore_cache:
|
43
|
-
keys:
|
74
|
+
keys:
|
44
75
|
- v2-bundle-<%= ruby %>-<%= variant %>-{{ .Branch }}
|
45
76
|
- v2-bundle-<%= ruby %>-<%= variant %>
|
46
77
|
- v2-bundle-<%= ruby %>
|
47
78
|
|
48
|
-
- run:
|
49
|
-
name: Install
|
79
|
+
- run:
|
80
|
+
name: Install bundle
|
50
81
|
command: |
|
82
|
+
unset \
|
83
|
+
BUNDLE_APP_CONFIG \
|
84
|
+
GEM_HOME \
|
85
|
+
BUNDLE_PATH \
|
86
|
+
BUNDLE_BIN
|
51
87
|
bundle install --jobs=3 --retry=3 --path=$PWD/vendor/bundle
|
52
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
|
53
93
|
- run:
|
54
94
|
name: Run test suite
|
55
95
|
command: |
|
56
|
-
unset
|
57
|
-
|
96
|
+
unset \
|
97
|
+
RACK_ENV \
|
98
|
+
RAILS_ENV \
|
99
|
+
BUNDLE_APP_CONFIG \
|
100
|
+
GEM_HOME \
|
101
|
+
BUNDLE_PATH \
|
102
|
+
BUNDLE_BIN
|
58
103
|
bundle exec rspec
|
59
104
|
|
60
105
|
- save_cache:
|
data/.codecov.yml
CHANGED
data/Appraisals
CHANGED
@@ -1,31 +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
17
|
gem 'rails', '~> 5.1.0'
|
22
|
-
gem 'sqlite3'
|
18
|
+
gem 'sqlite3', '~> 1.3.6'
|
23
19
|
gem 'pg', '~> 0.18'
|
20
|
+
gem 'rake', '13.0.1'
|
24
21
|
end
|
25
22
|
|
26
23
|
appraise 'rails-5-2' do
|
27
24
|
gem 'rails', '~> 5.2.0'
|
28
25
|
gem 'bootsnap', '>= 1.1.0', require: false
|
29
|
-
gem 'sqlite3'
|
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'
|
30
35
|
gem 'pg', '~> 0.18'
|
36
|
+
gem 'rake', '13.0.1'
|
31
37
|
end
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,41 @@
|
|
1
|
+
# v2.1.2
|
2
|
+
|
3
|
+
Bug fix:
|
4
|
+
|
5
|
+
- fixes PopulateEnvFromJWT caching issue where a key that couldn't be fetched would be cached
|
6
|
+
|
7
|
+
# v2.1.0
|
8
|
+
|
9
|
+
Features:
|
10
|
+
|
11
|
+
- Rails 6 compatibility
|
12
|
+
|
13
|
+
# v2.0.0-pre.2
|
14
|
+
|
15
|
+
Features:
|
16
|
+
|
17
|
+
- Removes routemaster
|
18
|
+
|
19
|
+
# v2.0.0-pre.1
|
20
|
+
|
21
|
+
Features:
|
22
|
+
|
23
|
+
- Remove New Relic
|
24
|
+
|
25
|
+
# v1.23.0 (2019-04-24)
|
26
|
+
|
27
|
+
Features:
|
28
|
+
|
29
|
+
- Setting DATABASE_STATEMENT_TIMEOUT to -1 will prevent the app setting any timeout.
|
30
|
+
Setting timeouts from the app conflicts with PGBouncer and should be disabled if
|
31
|
+
using one.
|
32
|
+
|
33
|
+
# v1.22.0 (2018-08-29)
|
34
|
+
|
35
|
+
Features:
|
36
|
+
|
37
|
+
- Allows specifying `BASE_NEW_RELIC_APP_NAME` instead of `NEW_RELIC_APP_NAME`, which reports to New Relic per Hopper service.
|
38
|
+
|
1
39
|
# v1.21.0 (2018-03-27)
|
2
40
|
|
3
41
|
Features:
|
data/README.md
CHANGED
@@ -17,17 +17,17 @@
|
|
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
|
-
- [HireFire](#hirefire)
|
25
24
|
- [Logging](#logging)
|
26
25
|
- [Identity](#identity)
|
27
26
|
- [Google OAuth authentication](#google-oauth-authentication)
|
28
27
|
- [Datadog Integration](#datadog-integration)
|
29
|
-
|
30
|
-
|
28
|
+
- [Heroku metrics](#heroku-metrics)
|
29
|
+
- [Custom application metrics](#custom-application-metrics)
|
30
|
+
- [API Authentication](#api-authentication)
|
31
31
|
- [Command features](#command-features)
|
32
32
|
- [Usage](#usage)
|
33
33
|
- [Description](#description)
|
@@ -48,11 +48,6 @@ Remove the following gems from your Gemfile, as they're provided and configured
|
|
48
48
|
by `roo_on_rails`:
|
49
49
|
|
50
50
|
- `dotenv`
|
51
|
-
- `newrelic_rpm`
|
52
|
-
|
53
|
-
Remove the following configuration files:
|
54
|
-
|
55
|
-
- `newrelic.yml` or `config/newrelic.yml`
|
56
51
|
|
57
52
|
Also remove any other gem-specific configuration from your repository.
|
58
53
|
|
@@ -62,23 +57,19 @@ And then execute:
|
|
62
57
|
|
63
58
|
Then re-run your test suite to make sure everything is shipshape.
|
64
59
|
|
65
|
-
##
|
60
|
+
## Running specs
|
66
61
|
|
67
|
-
|
62
|
+
To run the specs locally, you will need to run the following command:
|
68
63
|
|
69
|
-
|
64
|
+
```ruby
|
65
|
+
bundle config --local gemfile $PWD/gemfiles/<%= variant %>.gemfile
|
66
|
+
```
|
67
|
+
|
68
|
+
Where `<%= variant %>` is the Rails version you'd like to test (e.g. `rails_5_2`).
|
70
69
|
|
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.
|
70
|
+
`bundle exec rspec` should then work as normal.
|
79
71
|
|
80
|
-
|
81
|
-
our standard settings.
|
72
|
+
## Library usage
|
82
73
|
|
83
74
|
### Rack middleware
|
84
75
|
|
@@ -104,6 +95,11 @@ To do this, you can set the `ROO_ON_RAILS_DISABLE_SSL_ENFORCEMENT` to `YES`.
|
|
104
95
|
The database statement timeout will be set to a low value by default. Use
|
105
96
|
`DATABASE_STATEMENT_TIMEOUT` (milliseconds, default 200) to customise.
|
106
97
|
|
98
|
+
When using a PGBouncer, setting the timeout from the application will cause
|
99
|
+
inconsistent results. The timeout should always be set using the RDS parameter
|
100
|
+
group in thise case. To prevent the app trying to set a timeout, set
|
101
|
+
`DATABASE_STATEMENT_TIMEOUT` to -1.
|
102
|
+
|
107
103
|
For database creation and migration (specifically the `db:create`, `db:migrate`,
|
108
104
|
`db:migrate:down` and `db:rollback` tasks) a much higher statement timeout is
|
109
105
|
set by default. Use `MIGRATION_STATEMENT_TIMEOUT` (milliseconds, default 10000)
|
@@ -138,48 +134,6 @@ NB. If you are migrating to SLA-based queue names, do not set `SIDEKIQ_ENABLED`
|
|
138
134
|
to `true` before your old queues have finished processing (this will prevent
|
139
135
|
Sidekiq from seeing the old queues at all).
|
140
136
|
|
141
|
-
### HireFire
|
142
|
-
|
143
|
-
#### For Web Dynos
|
144
|
-
|
145
|
-
Web dynos can be autoscaled by HireFire _only_ if it has been configured to use the `Web.Logplex.Load` source and the Heroku runtime metrics lab feature has been enabled:
|
146
|
-
|
147
|
-
```bash
|
148
|
-
$ heroku labs:enable log-runtime-metrics -a your-service-name-here
|
149
|
-
```
|
150
|
-
|
151
|
-
You will also need a log drain for HireFire, but the RooOnRails helper below should configure this for you. You can check with
|
152
|
-
|
153
|
-
```bash
|
154
|
-
$ heroku drains | grep hirefire
|
155
|
-
https://logdrain.hirefire.io (d.00000000-0000-0000-0000-000000000000)
|
156
|
-
|
157
|
-
# No drain? Add with:
|
158
|
-
$ heroku drains:add -a your-service-name-here https://logdrain.hirefire.io
|
159
|
-
```
|
160
|
-
|
161
|
-
([HireFire docs for set up](https://help.hirefire.io/guides/logplex/load-logplex))
|
162
|
-
|
163
|
-
#### For Sidekiq Workers
|
164
|
-
|
165
|
-
When `HIREFIRE_TOKEN` is set an endpoint will be mounted at `/hirefire` that
|
166
|
-
reports the required worker count as a function of queue latency. By default we
|
167
|
-
add queue names in the style 'within1day', so if we notice an average latency in
|
168
|
-
that queue of more than an set threshold we'll request one more worker. If we
|
169
|
-
notice less than a threshold we'll request one less worker. These settings can
|
170
|
-
be customised via the following ENV variables
|
171
|
-
|
172
|
-
- `WORKER_INCREASE_THRESHOLD` (default 0.5)
|
173
|
-
- `WORKER_DECREASE_THRESHOLD` (default 0.1)
|
174
|
-
|
175
|
-
When setting the manager up in the HireFire web ui, the following settings must
|
176
|
-
be used:
|
177
|
-
|
178
|
-
- name: 'worker'
|
179
|
-
- type: 'Worker.HireFire.JobQueue'
|
180
|
-
- ratio: 1
|
181
|
-
- decrementable: 'true'
|
182
|
-
|
183
137
|
### Logging
|
184
138
|
|
185
139
|
For clearer and machine-parseable log output, the Rails logger is replaced by an
|
@@ -302,16 +256,6 @@ The following tags will automatically be added to all your metrics and their val
|
|
302
256
|
* `HOPPER_APP_NAME`+`HOPPER_ECS_CLUSTER_NAME` – automatically set by Hopper (e.g. `notifications-staging`);
|
303
257
|
* Defaults to `unknown`.
|
304
258
|
|
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
259
|
### API Authentication
|
316
260
|
|
317
261
|
RooOnRails provides a concern which will make adding rotatable API authentication to your service a breeze:
|
@@ -393,6 +337,11 @@ The command is designed to fix issues in many cases.
|
|
393
337
|
Pull requests are welcome on GitHub at
|
394
338
|
`https://github.com/deliveroo/roo_on_rails`.
|
395
339
|
|
340
|
+
## Releasing
|
341
|
+
|
342
|
+
1. Bump the version number in `lib/roo_on_rails/version.rb
|
343
|
+
1. Add an entry to the changelog
|
344
|
+
1. After merging to master release e.g. `bundle exec rake release`
|
396
345
|
|
397
346
|
## License
|
398
347
|
|
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
data/gemfiles/rails_5_2.gemfile
CHANGED
@@ -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: "../"
|