loadrunner 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +23 -5
- data/bin/loadrunner +1 -1
- data/lib/load_runner/client.rb +3 -3
- data/lib/load_runner/command_line.rb +19 -33
- data/lib/load_runner/docopt.txt +9 -6
- data/lib/load_runner/server.rb +1 -1
- data/lib/load_runner/server_base.rb +2 -0
- data/lib/load_runner/version.rb +1 -1
- data/lib/loadrunner.rb +2 -0
- metadata +31 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e03188ae2b98426dceaa6986c04cc177fd52756d7842440b17567912a6076959
|
4
|
+
data.tar.gz: 534fe583d3b7ade5df62bc79ebc46fc8083eb515f157e054dbede9619d3e8152
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baa121b508967453f6fa27c758e07791de8fdadec5380b422b1ecf407eb85ed5a07f4e3b5148be9ca3c960f7fea0ad88d2380d0a8a527b61c9f0cb4e09616d8e
|
7
|
+
data.tar.gz: f6cda33832faf0e4ec94102e68fbb16eb6882050bb7c6145d271e97899d5711a925a238db7db7d1111560a09ff0d4fb663f4df08de7106ee75d927f7c59ab713
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
LoadRunner - GitHub Webhook Server and Event Simulator
|
2
2
|
======================================================
|
3
3
|
|
4
|
-
[![Gem](https://
|
5
|
-
[![
|
6
|
-
[![
|
7
|
-
[![
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/loadrunner.svg)](https://badge.fury.io/rb/loadrunner)
|
5
|
+
[![Build Status](https://travis-ci.org/DannyBen/loadrunner.svg?branch=master)](https://travis-ci.org/DannyBen/loadrunner)
|
6
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/f1aae46eaf6365ea2ec7/maintainability)](https://codeclimate.com/github/DannyBen/loadrunner/maintainability)
|
7
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/f1aae46eaf6365ea2ec7/test_coverage)](https://codeclimate.com/github/DannyBen/loadrunner/test_coverage)
|
8
8
|
|
9
9
|
---
|
10
10
|
|
@@ -14,7 +14,7 @@ statuses.
|
|
14
14
|
It provides these features:
|
15
15
|
|
16
16
|
- A webserver that responds to GitHub webhook events and can run any
|
17
|
-
arbitrary script
|
17
|
+
arbitrary script written in any language.
|
18
18
|
- A command line utility for testing your webhook server configuration by
|
19
19
|
sending simulated events.
|
20
20
|
- A command line utility for sending status updates to pull requests.
|
@@ -35,6 +35,7 @@ Getting Started
|
|
35
35
|
$ mkdir -p handlers/myrepo
|
36
36
|
$ echo "#\!/usr/bin/env bash" > handlers/myrepo/push
|
37
37
|
$ echo "echo hello > output.txt" >> handlers/myrepo/push
|
38
|
+
$ chmod +x handlers/myrepo/push
|
38
39
|
|
39
40
|
# Start the server
|
40
41
|
$ loadrunner server
|
@@ -51,4 +52,21 @@ For more options, see the [documentation][1] or run
|
|
51
52
|
$ loadrunner --help
|
52
53
|
|
53
54
|
|
55
|
+
Running with Docker
|
56
|
+
--------------------------------------------------
|
57
|
+
|
58
|
+
You can run both the server and the client using Docker.
|
59
|
+
|
60
|
+
# Server
|
61
|
+
$ docker run -p3000:3000 dannyben/loadrunner server
|
62
|
+
|
63
|
+
# Client
|
64
|
+
$ docker run dannyben/loadrunner send http://webhook.server.com/payload repo push
|
65
|
+
|
66
|
+
If you wish to connect the client to the server you are running through Docker,
|
67
|
+
you can do something like this:
|
68
|
+
|
69
|
+
$ docker run --network host dannyben/loadrunner send http://localhost:3000/payload repo push
|
70
|
+
|
71
|
+
|
54
72
|
[1]: http://www.rubydoc.info/gems/loadrunner
|
data/bin/loadrunner
CHANGED
data/lib/load_runner/client.rb
CHANGED
@@ -9,7 +9,7 @@ module LoadRunner
|
|
9
9
|
|
10
10
|
def initialize(opts={})
|
11
11
|
@secret_token = opts[:secret_token]
|
12
|
-
@base_url = opts[:base_url] || 'localhost:3000'
|
12
|
+
@base_url = opts[:base_url] || 'localhost:3000/payload'
|
13
13
|
self.class.base_uri base_url
|
14
14
|
end
|
15
15
|
|
@@ -19,7 +19,7 @@ module LoadRunner
|
|
19
19
|
# * +ref+: ref ID (for example +ref/heads/branchname+)
|
20
20
|
# * +branch+: branch name
|
21
21
|
# * +tag+: tag name
|
22
|
-
def
|
22
|
+
def send_event(event=:push, opts={})
|
23
23
|
payload = build_payload opts
|
24
24
|
send_payload event, payload
|
25
25
|
end
|
@@ -28,7 +28,7 @@ module LoadRunner
|
|
28
28
|
def send_payload(event, payload)
|
29
29
|
@payload = payload.is_a?(String) ? payload : payload.to_json
|
30
30
|
headers = headers event
|
31
|
-
self.class.post "
|
31
|
+
self.class.post "", body: @payload, headers: headers
|
32
32
|
end
|
33
33
|
|
34
34
|
private
|
@@ -1,41 +1,19 @@
|
|
1
|
-
require '
|
2
|
-
require 'docopt'
|
1
|
+
require 'super_docopt'
|
3
2
|
require 'colsole'
|
4
3
|
|
5
4
|
module LoadRunner
|
6
5
|
|
7
6
|
# Handles the command line interface
|
8
|
-
class CommandLine
|
9
|
-
include Singleton
|
7
|
+
class CommandLine < SuperDocopt::Base
|
10
8
|
include Colsole
|
11
9
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
# and shows usage patterns / help otherwise.
|
16
|
-
def execute(argv=[])
|
17
|
-
doc = File.read File.dirname(__FILE__) + '/docopt.txt'
|
18
|
-
begin
|
19
|
-
@args = Docopt::docopt(doc, argv: argv, version: VERSION)
|
20
|
-
handle
|
21
|
-
rescue Docopt::Exit => e
|
22
|
-
puts e.message
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
# Called when the arguments match one of the usage patterns. Will
|
29
|
-
# delegate action to other, more specialized methods.
|
30
|
-
def handle
|
31
|
-
return send if args['send']
|
32
|
-
return status if args['status']
|
33
|
-
return server if args['server']
|
34
|
-
end
|
10
|
+
version VERSION
|
11
|
+
docopt File.expand_path 'docopt.txt', __dir__
|
12
|
+
subcommands [{'send' => 'send_event'}, 'status', 'server']
|
35
13
|
|
36
|
-
def
|
14
|
+
def send_event
|
37
15
|
client = Client.new client_opts
|
38
|
-
response = client.
|
16
|
+
response = client.send_event args['EVENT'], payload_opts
|
39
17
|
show response
|
40
18
|
end
|
41
19
|
|
@@ -54,10 +32,12 @@ module LoadRunner
|
|
54
32
|
}
|
55
33
|
|
56
34
|
response = api.status args['REPO'], args['SHA'], opts
|
57
|
-
|
35
|
+
|
58
36
|
show response
|
59
37
|
end
|
60
38
|
|
39
|
+
private
|
40
|
+
|
61
41
|
def client_opts
|
62
42
|
{
|
63
43
|
base_url: args['URL'],
|
@@ -71,7 +51,7 @@ module LoadRunner
|
|
71
51
|
def payload_opts
|
72
52
|
result = { repo: args['REPO'] }
|
73
53
|
|
74
|
-
ref = args['REF']
|
54
|
+
ref = args['REF'] || 'master'
|
75
55
|
ref = "refs/tags/#{$1}" if ref =~ /^tag=(.+)/
|
76
56
|
ref = "refs/heads/#{$1}" if ref =~ /^branch=(.+)/
|
77
57
|
ref = "refs/heads/#{ref}" if ref !~ /^refs/
|
@@ -82,13 +62,19 @@ module LoadRunner
|
|
82
62
|
|
83
63
|
# Print the response json to stdout, and the response code to stderr.
|
84
64
|
def show(response)
|
85
|
-
puts
|
65
|
+
puts json_generate(response)
|
86
66
|
|
87
67
|
if response.respond_to? :code
|
88
68
|
code = response.code.to_s
|
89
69
|
color = code =~ /^2\d\d/ ? :txtgrn : :txtred
|
90
|
-
say
|
70
|
+
say "!#{color}!Response Code: #{code}"
|
91
71
|
end
|
92
72
|
end
|
73
|
+
|
74
|
+
def json_generate(object)
|
75
|
+
JSON.pretty_generate(JSON.parse object.to_s)
|
76
|
+
rescue
|
77
|
+
object.to_s
|
78
|
+
end
|
93
79
|
end
|
94
80
|
end
|
data/lib/load_runner/docopt.txt
CHANGED
@@ -58,15 +58,18 @@ Options:
|
|
58
58
|
A short description of the status.
|
59
59
|
|
60
60
|
Environment Variables:
|
61
|
-
GITHUB_SECRET_TOKEN=
|
62
|
-
Set Your GitHub secret token.
|
61
|
+
GITHUB_SECRET_TOKEN=y0urk3y
|
62
|
+
Set Your GitHub secret token as set in your webhook.
|
63
|
+
|
64
|
+
GITHUB_ACCESS_TOKEN=y0urAPIk3y
|
65
|
+
Set Your GitHub API token (needed only for status updates).
|
63
66
|
|
64
67
|
Examples:
|
65
68
|
# Simulate push events
|
66
|
-
loadrunner send localhost:3000 my_repo push master
|
67
|
-
loadrunner send localhost:3000 my_repo push branch=master
|
68
|
-
loadrunner send localhost:3000 my_repo push tag=staging
|
69
|
-
loadrunner send localhost:3000 my_repo push refs/tags/staging
|
69
|
+
loadrunner send localhost:3000/payload my_repo push master
|
70
|
+
loadrunner send localhost:3000/payload my_repo push branch=master
|
71
|
+
loadrunner send localhost:3000/payload my_repo push tag=staging
|
72
|
+
loadrunner send localhost:3000/payload my_repo push refs/tags/staging
|
70
73
|
|
71
74
|
# Start the server
|
72
75
|
loadrunner server
|
data/lib/load_runner/server.rb
CHANGED
@@ -15,7 +15,7 @@ module LoadRunner
|
|
15
15
|
|
16
16
|
signature = request.env['HTTP_X_HUB_SIGNATURE']
|
17
17
|
state = verify_signature payload_body, signature
|
18
|
-
|
18
|
+
|
19
19
|
halt 401, halt_messages[state] if state != :ok
|
20
20
|
|
21
21
|
push = ActiveSupport::HashWithIndifferentAccess.new JSON.parse payload_body
|
@@ -13,7 +13,9 @@ module LoadRunner
|
|
13
13
|
set :server, :puma
|
14
14
|
|
15
15
|
configure :development do
|
16
|
+
# :nocov: - this is not covered in CI, but is covered in dev
|
16
17
|
register Sinatra::Reloader if defined? Sinatra::Reloader
|
18
|
+
# :nocov:
|
17
19
|
end
|
18
20
|
|
19
21
|
# Since we cannot use any config values in the main body of the class,
|
data/lib/load_runner/version.rb
CHANGED
data/lib/loadrunner.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loadrunner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: super_docopt
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.1'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: httparty
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +52,20 @@ dependencies:
|
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sinatra-contrib
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: puma
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,20 +178,6 @@ dependencies:
|
|
150
178
|
- - "~>"
|
151
179
|
- !ruby/object:Gem::Version
|
152
180
|
version: '9.0'
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: sinatra-contrib
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - "~>"
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '2.0'
|
160
|
-
type: :development
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - "~>"
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '2.0'
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
182
|
name: rack-test
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -232,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
232
246
|
version: '0'
|
233
247
|
requirements: []
|
234
248
|
rubyforge_project:
|
235
|
-
rubygems_version: 2.6
|
249
|
+
rubygems_version: 2.7.6
|
236
250
|
signing_key:
|
237
251
|
specification_version: 4
|
238
252
|
summary: GitHub Webhook Server and Simulator
|