loadrunner 0.3.1 → 0.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 +4 -4
- data/README.md +24 -23
- data/lib/load_runner/runner.rb +10 -13
- data/lib/load_runner/server.rb +3 -2
- data/lib/load_runner/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d79a3a28613d0ed9bb71220d16f44796bdf2e4b4b20eeb2c463df46ac8b10837
|
4
|
+
data.tar.gz: 82a2d95737162857f764a7ab87745fcc504fb8544066ec3037c7b1985a2e1891
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61a9ca38c6a7a2622d30e5e089fe4b442d6c74355f11592310945da3298241349328787c18758a303956e1477779216a367a3c438049c01be21ccaafd89acbc7
|
7
|
+
data.tar.gz: d47d260866de2fb6909142b9887563ef0826b8598fa7879454807f8d2c43edd1db2191d07a35370e2d13c98cbaa53edb970fb02d4fd2c8019f571b08fe0d6781
|
data/README.md
CHANGED
@@ -35,21 +35,18 @@ $ gem install loadrunner
|
|
35
35
|
Getting Started
|
36
36
|
--------------------------------------------------
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
# Verify the handler was executed
|
52
|
-
$ cat output.txt
|
38
|
+
1. Download the [handlers](handlers) directory from this repository, as an
|
39
|
+
exmaple. This directory contains several handler examples.
|
40
|
+
2. Make sure that all files within that folder are executables.
|
41
|
+
3. Start the server (from the `handlers` **parent** directory):
|
42
|
+
`loadrunner server`
|
43
|
+
4. In another terminal, send a sample webhook event:
|
44
|
+
`loadrunner event localhost:3000/payload myrepo push master
|
45
|
+
|
46
|
+
The server should respond with a detailed JSON response, specifying what
|
47
|
+
handlers were executed (`executed_handlers`) and what handlers *could have
|
48
|
+
been* executed, if they were defined in the handlers folder
|
49
|
+
(`matching_handlers`).
|
53
50
|
```
|
54
51
|
|
55
52
|
|
@@ -64,15 +61,19 @@ $ loadrunner --help
|
|
64
61
|
Building Handlers
|
65
62
|
--------------------------------------------------
|
66
63
|
|
67
|
-
When running the server, it will look for handlers
|
68
|
-
directory, using one of these format:
|
64
|
+
When running the server, it will look for handlers (executable scripts) in
|
65
|
+
the `./handlers` directory, using one of these format:
|
69
66
|
|
67
|
+
handlers/global
|
68
|
+
handlers/<repo name>/global
|
70
69
|
handlers/<repo name>/<event type>
|
71
70
|
handlers/<repo name>/<event type>@branch=<branch name>
|
72
71
|
handlers/<repo name>/<event type>@tag=<branch name>
|
73
72
|
|
74
73
|
For example:
|
75
74
|
|
75
|
+
handlers/global
|
76
|
+
handlers/myrepo/global
|
76
77
|
handlers/myrepo/push
|
77
78
|
handlers/myrepo/push@branch=master
|
78
79
|
handlers/myrepo/push@tag=release
|
@@ -88,12 +89,12 @@ executables.
|
|
88
89
|
|
89
90
|
These environment variables are available to your handlers:
|
90
91
|
|
91
|
-
- `
|
92
|
-
- `
|
93
|
-
- `
|
94
|
-
- `
|
95
|
-
- `
|
96
|
-
- `
|
92
|
+
- `LOADRUNNER_REPO`
|
93
|
+
- `LOADRUNNER_EVENT`
|
94
|
+
- `LOADRUNNER_BRANCH`
|
95
|
+
- `LOADRUNNER_REF`
|
96
|
+
- `LOADRUNNER_TAG`
|
97
|
+
- `LOADRUNNER_PAYLOAD` - the entire JSON string as received from GitHub, or the client.
|
97
98
|
|
98
99
|
|
99
100
|
|
data/lib/load_runner/runner.rb
CHANGED
@@ -3,9 +3,10 @@ module LoadRunner
|
|
3
3
|
# Executes event handlers
|
4
4
|
class Runner
|
5
5
|
attr_reader :opts
|
6
|
-
attr_accessor :response
|
6
|
+
attr_accessor :response, :handlers_dir
|
7
7
|
|
8
8
|
def initialize(opts)
|
9
|
+
@handlers_dir = 'handlers'
|
9
10
|
@opts = opts
|
10
11
|
end
|
11
12
|
|
@@ -13,12 +14,12 @@ module LoadRunner
|
|
13
14
|
# populates the `#response` object, and returns true on success.
|
14
15
|
def execute
|
15
16
|
set_environment_vars
|
16
|
-
|
17
|
+
|
17
18
|
@response = opts.dup
|
18
19
|
handlers = locate_handlers
|
20
|
+
@response[:matching_handlers] = matching_handlers
|
19
21
|
|
20
22
|
if handlers.empty?
|
21
|
-
@response[:matching_handlers] = matching_handlers
|
22
23
|
@response[:error] = "Could not find any handler to process this webhook. Please implement one of the 'matching_handlers'."
|
23
24
|
return false
|
24
25
|
else
|
@@ -28,14 +29,6 @@ module LoadRunner
|
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
31
|
-
def handlers_dir
|
32
|
-
@handlers_dir ||= 'handlers'
|
33
|
-
end
|
34
|
-
|
35
|
-
def handlers_dir=(path)
|
36
|
-
@handlers_dir = path
|
37
|
-
end
|
38
|
-
|
39
32
|
private
|
40
33
|
|
41
34
|
# Find all handlers that fit the payload meta data.
|
@@ -65,12 +58,16 @@ module LoadRunner
|
|
65
58
|
# Set all payload meta data as environment variables so that the
|
66
59
|
# handler can use them.
|
67
60
|
def set_environment_vars
|
68
|
-
opts.each { |key, value| ENV[key.to_s.upcase] = value }
|
61
|
+
opts.each { |key, value| ENV["LOADRUNNER_#{key.to_s.upcase}"] = value }
|
69
62
|
end
|
70
63
|
|
71
64
|
def matching_handlers
|
72
65
|
base = "#{handlers_dir}/#{opts[:repo]}/#{opts[:event]}"
|
73
|
-
handlers = [
|
66
|
+
handlers = [
|
67
|
+
"#{handlers_dir}/global",
|
68
|
+
"#{handlers_dir}/#{opts[:repo]}/global",
|
69
|
+
"#{base}"
|
70
|
+
]
|
74
71
|
|
75
72
|
handlers.tap do |h|
|
76
73
|
h << "#{base}@branch=#{opts[:branch]}" if opts[:branch]
|
data/lib/load_runner/server.rb
CHANGED
@@ -28,8 +28,9 @@ module LoadRunner
|
|
28
28
|
opts = {}
|
29
29
|
opts[:repo] = payload.dig(:repository, :name)
|
30
30
|
opts[:event] = request.env['HTTP_X_GITHUB_EVENT']
|
31
|
-
opts[:
|
32
|
-
opts[:
|
31
|
+
opts[:ref] = payload[:ref]
|
32
|
+
opts[:branch] = payload[:ref] =~ /refs\/heads/ ? payload[:ref].sub('refs/heads/', '') : nil
|
33
|
+
opts[:tag] = payload[:ref] =~ /refs\/tags/ ? payload[:ref].sub('refs/tags/', '') : nil
|
33
34
|
opts[:payload] = json_string
|
34
35
|
|
35
36
|
runner = Runner.new opts
|
data/lib/load_runner/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loadrunner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.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: 2018-06-
|
11
|
+
date: 2018-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: super_docopt
|