puppet-community-rangefinder-webhook 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +45 -1
- data/bin/rangefinder-webhook +24 -11
- data/lib/rangefinder/webhook.rb +4 -1
- data/lib/rangefinder/webhook/version.rb +2 -2
- 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: 319aee1e86528e1bbb04db33413c8bbcb80bc98cbffa6d73ad1f9b9eca25ae3e
|
4
|
+
data.tar.gz: 22cea689b62bfe35abc5118763c1a5c17ca34a9ee97776a1a7561070429d9f86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae34ea922dae618cf9cfbc621ec42cd2b91f1f5d97e808ed56bd692737d2358fed6c24fa410db58223a853a6b860d8d87658245a5cbfc778f43d9d9724d9528b
|
7
|
+
data.tar.gz: 2eebbfd33d9544e40213c8ce8aa77a936e2ecd9a737f612b3f5e84a2dd53cb45695ac852d9a3845ee64d136e3457311ae023f648ca2e21e2b632bc527a04db71
|
data/README.md
CHANGED
@@ -5,9 +5,13 @@ file changes. This GitHub integration allows us to tie it to pull requests
|
|
5
5
|
and provide impact prediction reports as comments when a PR is filed.
|
6
6
|
|
7
7
|
It's still fairly young in its development, so please don't hesitate to
|
8
|
-
file issues either here or on the
|
8
|
+
file issues either here or on the
|
9
9
|
[Rangefinder tool](https://github.com/puppetlabs/puppet-community-rangefinder) itself.
|
10
10
|
|
11
|
+
See my [blog post](https://binford2k.com/2020/04/30/downstream-impact-of-pull-requests/)
|
12
|
+
for more information on this tool.
|
13
|
+
|
14
|
+
|
11
15
|
## Installation
|
12
16
|
|
13
17
|
1. Visit its [GitHub app page](https://github.com/apps/puppet-community-rangefinder).
|
@@ -18,14 +22,54 @@ file issues either here or on the
|
|
18
22
|
![install app](public/install_app.png)
|
19
23
|
![select repos](public/select_repos.png)
|
20
24
|
|
25
|
+
|
26
|
+
## Running your own server
|
27
|
+
|
28
|
+
This is a fairly complex configuration. You'll need to register both Google Cloud
|
29
|
+
and GitHub apps, and configure Rangefinder itself.
|
30
|
+
|
31
|
+
* Register a new GitHub app following the instructions at:
|
32
|
+
* https://developer.github.com/apps/building-github-apps/creating-a-github-app/
|
33
|
+
* Generate a new GitHub private key:
|
34
|
+
* https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/
|
35
|
+
* Create a new Google Cloud service account:
|
36
|
+
* https://cloud.google.com/docs/authentication/getting-started
|
37
|
+
|
38
|
+
Use that information to generate your configuration file. The `:gcloud` key will
|
39
|
+
be passed directly through to the [Rangefinder config](https://github.com/puppetlabs/puppet-community-rangefinder#configuration).
|
40
|
+
If you're using the official Puppet public BigQuery dataset, then you should use
|
41
|
+
the values provided in the example below.
|
42
|
+
|
43
|
+
The configuration file location defaults to the first found of
|
44
|
+
|
45
|
+
1. `~/.rangefinder.conf`
|
46
|
+
2. `/etc/rangefinder/config.yaml`
|
47
|
+
|
48
|
+
### Example configuration:
|
49
|
+
|
50
|
+
``` yaml
|
51
|
+
---
|
52
|
+
:gcloud:
|
53
|
+
:dataset: community
|
54
|
+
:project: dataops-puppet-public-data
|
55
|
+
:keyfile: <your service account credentials>
|
56
|
+
:github:
|
57
|
+
:app_identifier: <your app id>
|
58
|
+
:private_key_file: <your private key file>
|
59
|
+
:webhook_secret: <your webhook secret>
|
60
|
+
```
|
61
|
+
|
62
|
+
|
21
63
|
## Limitations
|
22
64
|
|
23
65
|
This is super early in development and has not yet been battle tested.
|
24
66
|
|
67
|
+
|
25
68
|
## Disclaimer
|
26
69
|
|
27
70
|
I take no liability for the use of this tool.
|
28
71
|
|
72
|
+
|
29
73
|
Contact
|
30
74
|
-------
|
31
75
|
|
data/bin/rangefinder-webhook
CHANGED
@@ -64,14 +64,14 @@ optparse = OptionParser.new { |opts|
|
|
64
64
|
exit
|
65
65
|
end
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
|
67
|
+
# Another typical switch to print the version.
|
68
|
+
opts.on_tail("--version", "Show version") do
|
69
|
+
require 'rangefinder/webhook/version'
|
70
70
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
puts "Rangefinder: #{Rangefinder::VERSION}"
|
72
|
+
puts "Webhook Server: #{Rangefinder::Webhook::VERSION}"
|
73
|
+
exit
|
74
|
+
end
|
75
75
|
}
|
76
76
|
optparse.parse!
|
77
77
|
|
@@ -80,10 +80,17 @@ options = defaults.merge(config.merge(options))
|
|
80
80
|
$logger = Logger.new(options[:logfile])
|
81
81
|
$logger.level = loglevel
|
82
82
|
|
83
|
-
options
|
84
|
-
|
85
|
-
|
86
|
-
|
83
|
+
unless options.include? :github
|
84
|
+
url = 'https://developer.github.com/apps/building-github-apps/creating-a-github-app/'
|
85
|
+
raise "Please register a new GitHub app and configure Rangefinder. See #{url}"
|
86
|
+
end
|
87
|
+
unless options[:github].include? :private_key_file
|
88
|
+
url = 'https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/'
|
89
|
+
raise "Please generate a new GitHub private key. See #{url}"
|
90
|
+
end
|
91
|
+
unless options.include? :gcloud
|
92
|
+
url = 'https://cloud.google.com/docs/authentication/getting-started'
|
93
|
+
raise "Please create a new Google Cloud service account and configure Rangefinder. See #{url}"
|
87
94
|
end
|
88
95
|
|
89
96
|
# These options should either both be nil or both be Strings
|
@@ -91,6 +98,12 @@ unless ssl_opts[:cert_chain_file].class == ssl_opts[:private_key_file].class
|
|
91
98
|
raise 'You must specify both the certificate and key file!'
|
92
99
|
end
|
93
100
|
|
101
|
+
if ssl_opts[:cert_chain_file] and ssl_opts[:private_key_file]
|
102
|
+
options[:ssl] = true
|
103
|
+
end
|
104
|
+
|
105
|
+
options[:github][:private_key_file] = File.expand_path(options[:github][:private_key_file])
|
106
|
+
|
94
107
|
if ARGV.first == 'shell'
|
95
108
|
require 'pry'
|
96
109
|
binding.pry
|
data/lib/rangefinder/webhook.rb
CHANGED
@@ -53,7 +53,10 @@ class Rangefinder::Webhook < Sinatra::Base
|
|
53
53
|
when 'pull_request'
|
54
54
|
case @payload['action']
|
55
55
|
when 'opened', 'reopened'
|
56
|
-
|
56
|
+
# spawn a worker thread so we can return immediately
|
57
|
+
Thread.new do
|
58
|
+
scan_for_impact(@payload)
|
59
|
+
end
|
57
60
|
else
|
58
61
|
$logger.info "Unhandled PR action: #{@payload['action']}"
|
59
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-community-rangefinder-webhook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Ford
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|