lhc-core-interceptors 2.2.0 → 2.3.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 +4 -4
- data/.gitignore +0 -1
- data/.ruby-version +1 -0
- data/README.md +20 -0
- data/cider-ci.yml +1 -2
- data/cider-ci/bin/bundle +27 -0
- data/cider-ci/bin/ruby_install +8 -0
- data/cider-ci/bin/ruby_version +25 -0
- data/cider-ci/jobs/rspec.yml +17 -41
- data/cider-ci/task_components/bundle.yml +18 -0
- data/cider-ci/task_components/rspec.yml +36 -0
- data/cider-ci/task_components/ruby.yml +15 -0
- data/lib/lhc-core-interceptors/rollbar.rb +18 -0
- data/lib/lhc-core-interceptors/version.rb +1 -1
- data/spec/rollbar/main_spec.rb +46 -0
- metadata +12 -9
- data/cider-ci/jobs/rubocop.yml +0 -55
- data/cider-ci/scripts/bundle.yml +0 -3
- data/cider-ci/scripts/github_comment.yml +0 -6
- data/cider-ci/scripts/rspec.yml +0 -4
- data/cider-ci/scripts/rubocop.yml +0 -5
- data/cider-ci/scripts/ruby-version.yml +0 -2
- data/cider-ci/scripts/tmp-cache.yml +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f9b008ab67152dd009a75908ba53b46e859c3e9
|
4
|
+
data.tar.gz: 894734ee22df57d95f6a5e4b579d8eba39847625
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20f42d9456146fed2455827f7aca139a096a1cad24c8489b3e9c2617c042439fc1fa4b98fafe6be92b34af8ac4cb87186c90871354faac297426baf7e2b291f4
|
7
|
+
data.tar.gz: c39c15d1541a41727342ac0f50c6f17d5c486364db5fa021459ada3026c733a37419cb94d57a677ee1b27233173e4326b8fd69f16259c5b0264b5b9b62db4618
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.2.2
|
data/README.md
CHANGED
@@ -130,6 +130,26 @@ Adds the following header to the request:
|
|
130
130
|
|
131
131
|
Which is the base64 encoded credentials "username:password".
|
132
132
|
|
133
|
+
## Rollbar Interceptor
|
134
|
+
|
135
|
+
Forward errors to rollbar when exceptions occur during http requests.
|
136
|
+
|
137
|
+
```ruby
|
138
|
+
LHC.config.interceptors = [LHC::Rollbar]
|
139
|
+
```
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
LHC.get('http://local.ch')
|
143
|
+
```
|
144
|
+
|
145
|
+
If it raises, it forwards the request and response object to rollbar, which contain all necessary data.
|
146
|
+
|
147
|
+
### Forward additional parameters
|
148
|
+
|
149
|
+
```ruby
|
150
|
+
LHC.get('http://local.ch', rollbar: { tracking_key: 'this particular request' })
|
151
|
+
```
|
152
|
+
|
133
153
|
## License
|
134
154
|
|
135
155
|
[GNU Affero General Public License Version 3.](https://www.gnu.org/licenses/agpl-3.0.en.html)
|
data/cider-ci.yml
CHANGED
data/cider-ci/bin/bundle
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -eux
|
3
|
+
|
4
|
+
export PATH=~/.rubies/$RUBY/bin:$PATH
|
5
|
+
rm -f .bundle/config
|
6
|
+
|
7
|
+
if [ ! -f ~/.rubies/$RUBY/bin/bundle ]; then
|
8
|
+
gem install bundler
|
9
|
+
fi
|
10
|
+
|
11
|
+
sed "s/^source 'https:\/\/rubygems\.intra\.local\.ch'*/source 'http\:\/\/52.29.7.59:9292'/g" Gemfile > Gemfile.tmp
|
12
|
+
mv Gemfile.tmp Gemfile
|
13
|
+
|
14
|
+
DIGEST=$(git ls-tree HEAD --\
|
15
|
+
cider-ci.yml cider-ci Gemfile.lock \
|
16
|
+
| openssl dgst -sha1 | cut -d ' ' -f 2)
|
17
|
+
|
18
|
+
DIGEST=$(echo "$DIGEST $PATH" \
|
19
|
+
| openssl dgst -sha1 | cut -d ' ' -f 2)
|
20
|
+
|
21
|
+
CACHE_SIGNATURE_FILE="/tmp/bundle_cache_signature_${DIGEST}"
|
22
|
+
|
23
|
+
if [ ! -f $CACHE_SIGNATURE_FILE ] ; then
|
24
|
+
bundle install
|
25
|
+
touch $CACHE_SIGNATURE_FILE
|
26
|
+
fi
|
27
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -eux
|
3
|
+
|
4
|
+
if [ -f ./.ruby-version ]; then
|
5
|
+
echo ".ruby-version file found"
|
6
|
+
fi
|
7
|
+
|
8
|
+
if [ ! -f ./.ruby-version ]; then
|
9
|
+
echo ".ruby-version file not found"
|
10
|
+
exit 1
|
11
|
+
fi
|
12
|
+
|
13
|
+
IFS='-' read -ra EXPLODED_RUBY <<< "$RUBY"
|
14
|
+
|
15
|
+
if [ "${#EXPLODED_RUBY[@]}" == "1" ]; then
|
16
|
+
echo 'No engine/version separator "-" found in .ruby-version file.'
|
17
|
+
exit 1
|
18
|
+
fi
|
19
|
+
|
20
|
+
if [ "${#EXPLODED_RUBY[@]}" != "1" ] && [ "${#EXPLODED_RUBY[@]}" != "2" ]; then
|
21
|
+
echo "Unknown format of .ruby-version file"
|
22
|
+
exit 1
|
23
|
+
fi
|
24
|
+
|
25
|
+
echo $RUBY
|
data/cider-ci/jobs/rspec.yml
CHANGED
@@ -1,48 +1,24 @@
|
|
1
1
|
rspec:
|
2
|
-
name: '
|
2
|
+
name: 'rspec'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
run_when:
|
5
|
+
'some HEAD has been updated':
|
6
|
+
type: branch
|
7
|
+
include_match: ^.*$
|
7
8
|
|
8
9
|
context:
|
9
|
-
task-defaults:
|
10
|
-
ports:
|
11
|
-
CAPYBARA_PORT:
|
12
|
-
inet_address: "localhost"
|
13
|
-
min: 8000
|
14
|
-
max: 8999
|
15
|
-
PHANTOMJS_PORT:
|
16
|
-
inet_address: "localhost"
|
17
|
-
min: 44600
|
18
|
-
max: 44999
|
19
10
|
|
20
|
-
|
21
|
-
|
22
|
-
start-when:
|
23
|
-
- script: bundle
|
24
|
-
- script: ruby-version
|
25
|
-
- script: tmp-cache
|
11
|
+
script_defaults:
|
12
|
+
template_environment_variables: true
|
26
13
|
|
14
|
+
task_defaults:
|
15
|
+
max_trials: 2
|
16
|
+
dispatch_storm_delay_duration: 1 Seconds
|
17
|
+
include:
|
18
|
+
- cider-ci/task_components/ruby.yml
|
19
|
+
- cider-ci/task_components/bundle.yml
|
20
|
+
- cider-ci/task_components/rspec.yml
|
27
21
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
- cider-ci/scripts/ruby-version.yml
|
32
|
-
- cider-ci/scripts/rspec.yml
|
33
|
-
|
34
|
-
|
35
|
-
trial-attachments:
|
36
|
-
logs:
|
37
|
-
include-match: log\/.*\.log$
|
38
|
-
content-type: text/plain
|
39
|
-
image-screenshots:
|
40
|
-
include-match: tmp\/capybara\/.*\.png$
|
41
|
-
content-type: image/png
|
42
|
-
html-screenshots:
|
43
|
-
include-match: tmp\/capybara\/.*\.html$
|
44
|
-
content-type: text/html
|
45
|
-
|
46
|
-
_cider-ci_generate-tasks:
|
47
|
-
include-match: spec/.*_spec.rb
|
48
|
-
exclude-match: spec/support/shared/*
|
22
|
+
tasks:
|
23
|
+
all-rspec:
|
24
|
+
name: All rspec tests
|
@@ -0,0 +1,18 @@
|
|
1
|
+
traits:
|
2
|
+
ruby-install: true
|
3
|
+
Bash: true
|
4
|
+
|
5
|
+
trial_attachments:
|
6
|
+
gemfile:
|
7
|
+
include_match: Gemfile
|
8
|
+
content_type: text/plain
|
9
|
+
|
10
|
+
scripts:
|
11
|
+
|
12
|
+
bundle:
|
13
|
+
exclusive_executor_resource: ruby-install_{{$RUBY}}
|
14
|
+
timeout: 20 Minutes
|
15
|
+
body: cider-ci/bin/bundle
|
16
|
+
start_when:
|
17
|
+
'ruby installed':
|
18
|
+
script_key: ruby-install
|
@@ -0,0 +1,36 @@
|
|
1
|
+
ports:
|
2
|
+
CAPYBARA_PORT:
|
3
|
+
min: 8000
|
4
|
+
max: 8999
|
5
|
+
PHANTOMJS_PORT:
|
6
|
+
min: 44600
|
7
|
+
max: 44999
|
8
|
+
|
9
|
+
environment_variables:
|
10
|
+
RUBY:
|
11
|
+
read_and_replace_with: .ruby-version
|
12
|
+
|
13
|
+
scripts:
|
14
|
+
rspec:
|
15
|
+
body: |
|
16
|
+
#!/usr/bin/env bash
|
17
|
+
set -eux
|
18
|
+
mkdir -p tmp/cache
|
19
|
+
export PATH=~/.rubies/$RUBY/bin:$PATH
|
20
|
+
bundle exec rspec
|
21
|
+
|
22
|
+
start_when:
|
23
|
+
'bundled':
|
24
|
+
script_key: bundle
|
25
|
+
|
26
|
+
|
27
|
+
trial_attachments:
|
28
|
+
logs:
|
29
|
+
include_match: log\/.*\.log$
|
30
|
+
content_type: text/plain
|
31
|
+
image-screenshots:
|
32
|
+
include_match: tmp\/capybara\/.*\.png$
|
33
|
+
content_type: image/png
|
34
|
+
html-screenshots:
|
35
|
+
include_match: tmp\/capybara\/.*\.html$
|
36
|
+
content_type: text/html
|
@@ -0,0 +1,15 @@
|
|
1
|
+
environment_variables:
|
2
|
+
RUBY:
|
3
|
+
read_and_replace_with: .ruby-version
|
4
|
+
|
5
|
+
scripts:
|
6
|
+
ruby-version:
|
7
|
+
body: cider-ci/bin/ruby_version
|
8
|
+
ruby-install:
|
9
|
+
exclusive_executor_resource: ruby-install_{{$RUBY}}
|
10
|
+
timeout: 20 Minutes
|
11
|
+
body: cider-ci/bin/ruby_install
|
12
|
+
start_when:
|
13
|
+
'ruby version checked':
|
14
|
+
script_key: ruby-version
|
15
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class LHC::Rollbar < LHC::Interceptor
|
2
|
+
include ActiveSupport::Configurable
|
3
|
+
|
4
|
+
def after_response(response)
|
5
|
+
return unless Object.const_defined?('Rollbar')
|
6
|
+
request = response.request
|
7
|
+
additional_params = request.options.fetch(:rollbar, {})
|
8
|
+
error = LHC::Error.find(response)
|
9
|
+
data = {
|
10
|
+
response: response,
|
11
|
+
request: request
|
12
|
+
}.merge additional_params
|
13
|
+
Rollbar.error(
|
14
|
+
error,
|
15
|
+
data
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe LHC::Rollbar do
|
4
|
+
before(:each) do
|
5
|
+
LHC.config.interceptors = [LHC::Rollbar]
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'does not report if Rollbar is not defined' do
|
9
|
+
stub_request(:get, 'http://local.ch').to_return(status: 400)
|
10
|
+
expect(-> { LHC.get('http://local.ch') })
|
11
|
+
.to raise_error LHC::BadRequest
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'Rollbar is defined' do
|
15
|
+
before(:each) do
|
16
|
+
class Rollbar; end
|
17
|
+
allow(::Rollbar).to receive(:error)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'does report errors to rollbar' do
|
21
|
+
stub_request(:get, 'http://local.ch').to_return(status: 400)
|
22
|
+
expect(-> { LHC.get('http://local.ch') })
|
23
|
+
.to raise_error LHC::BadRequest
|
24
|
+
expect(::Rollbar).to have_received(:error)
|
25
|
+
.with(LHC::BadRequest, hash_including(response: anything, request: anything))
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'additional params' do
|
29
|
+
it 'does report errors to rollbar with additional data' do
|
30
|
+
stub_request(:get, 'http://local.ch')
|
31
|
+
.to_return(status: 400)
|
32
|
+
expect(-> { LHC.get('http://local.ch', rollbar: { additional: 'data' }) })
|
33
|
+
.to raise_error LHC::BadRequest
|
34
|
+
expect(::Rollbar).to have_received(:error)
|
35
|
+
.with(
|
36
|
+
LHC::BadRequest,
|
37
|
+
hash_including(
|
38
|
+
response: anything,
|
39
|
+
request: anything,
|
40
|
+
additional: 'data'
|
41
|
+
)
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhc-core-interceptors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- local.ch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lhc
|
@@ -119,23 +119,24 @@ files:
|
|
119
119
|
- ".gitignore"
|
120
120
|
- ".rubocop.localch.yml"
|
121
121
|
- ".rubocop.yml"
|
122
|
+
- ".ruby-version"
|
122
123
|
- Gemfile
|
123
124
|
- README.md
|
124
125
|
- Rakefile
|
125
126
|
- cider-ci.yml
|
127
|
+
- cider-ci/bin/bundle
|
128
|
+
- cider-ci/bin/ruby_install
|
129
|
+
- cider-ci/bin/ruby_version
|
126
130
|
- cider-ci/jobs/rspec.yml
|
127
|
-
- cider-ci/
|
128
|
-
- cider-ci/
|
129
|
-
- cider-ci/
|
130
|
-
- cider-ci/scripts/rspec.yml
|
131
|
-
- cider-ci/scripts/rubocop.yml
|
132
|
-
- cider-ci/scripts/ruby-version.yml
|
133
|
-
- cider-ci/scripts/tmp-cache.yml
|
131
|
+
- cider-ci/task_components/bundle.yml
|
132
|
+
- cider-ci/task_components/rspec.yml
|
133
|
+
- cider-ci/task_components/ruby.yml
|
134
134
|
- lhc-core-interceptors.gemspec
|
135
135
|
- lib/lhc-core-interceptors.rb
|
136
136
|
- lib/lhc-core-interceptors/auth.rb
|
137
137
|
- lib/lhc-core-interceptors/caching.rb
|
138
138
|
- lib/lhc-core-interceptors/monitoring.rb
|
139
|
+
- lib/lhc-core-interceptors/rollbar.rb
|
139
140
|
- lib/lhc-core-interceptors/version.rb
|
140
141
|
- spec/auth/basic_auth_spec.rb
|
141
142
|
- spec/auth/bearer_spec.rb
|
@@ -185,6 +186,7 @@ files:
|
|
185
186
|
- spec/dummy/tmp/cache/.gitkeep
|
186
187
|
- spec/monitoring/main_spec.rb
|
187
188
|
- spec/rails_helper.rb
|
189
|
+
- spec/rollbar/main_spec.rb
|
188
190
|
- spec/spec_helper.rb
|
189
191
|
- spec/support/cleanup_configuration.rb
|
190
192
|
homepage: https://github.com/local-ch/lhc-core-interceptors
|
@@ -261,5 +263,6 @@ test_files:
|
|
261
263
|
- spec/dummy/tmp/cache/.gitkeep
|
262
264
|
- spec/monitoring/main_spec.rb
|
263
265
|
- spec/rails_helper.rb
|
266
|
+
- spec/rollbar/main_spec.rb
|
264
267
|
- spec/spec_helper.rb
|
265
268
|
- spec/support/cleanup_configuration.rb
|
data/cider-ci/jobs/rubocop.yml
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
rubocop:
|
2
|
-
name: 'Rubocop analysis'
|
3
|
-
|
4
|
-
run-on:
|
5
|
-
- type: branch
|
6
|
-
include-match: ^.*$
|
7
|
-
|
8
|
-
context:
|
9
|
-
task-defaults:
|
10
|
-
environment-variables:
|
11
|
-
GIT_REPOSITORY: local-ch/location-app
|
12
|
-
RESULT_PATH: 'tmp/checkstyle.json'
|
13
|
-
|
14
|
-
scripts:
|
15
|
-
rubocop:
|
16
|
-
start-when:
|
17
|
-
- script: bundle
|
18
|
-
- script: ruby-version
|
19
|
-
- script: tmp-cache
|
20
|
-
|
21
|
-
|
22
|
-
github_comment:
|
23
|
-
start-when:
|
24
|
-
- script: rubocop
|
25
|
-
states: [failed]
|
26
|
-
|
27
|
-
|
28
|
-
_cider-ci_include:
|
29
|
-
- cider-ci/scripts/bundle.yml
|
30
|
-
- cider-ci/scripts/tmp-cache.yml
|
31
|
-
- cider-ci/scripts/ruby-version.yml
|
32
|
-
- cider-ci/scripts/rubocop.yml
|
33
|
-
|
34
|
-
- cider-ci/scripts/github_comment.yml
|
35
|
-
|
36
|
-
|
37
|
-
max-auto-trials: 1
|
38
|
-
|
39
|
-
trial-attachments:
|
40
|
-
logs:
|
41
|
-
include-match: tmp\/checkstyle.json$
|
42
|
-
content-type: application/json
|
43
|
-
|
44
|
-
tree-attachments:
|
45
|
-
logs:
|
46
|
-
include-match: tmp\/checkstyle.json$
|
47
|
-
content-type: application/json
|
48
|
-
|
49
|
-
tasks:
|
50
|
-
rubocop:
|
51
|
-
scripts:
|
52
|
-
rubocop: {}
|
53
|
-
|
54
|
-
github_comment: {}
|
55
|
-
|
data/cider-ci/scripts/bundle.yml
DELETED
data/cider-ci/scripts/rspec.yml
DELETED