reagan 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/reagan +22 -1
- data/lib/change.rb +16 -6
- data/lib/reagan.rb +9 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0768ae5db6dcb4bdcbbe702be3806dd3ab4a80f
|
4
|
+
data.tar.gz: 402af8fd05ba6df63bfddb6ec7beafb6b0c0bb99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efd32feff08fc2418a95582ffaa0d63ee2ee13c225f4754c79c7e8f4cbfb961cdbb8fe33beabb79d4fd49b258a8e044b6defd8c735a032af12903f4f7fd10925
|
7
|
+
data.tar.gz: 422c0a0347a520847ea2681160f411db829c793764df1d7ddc2702ec730f4cec99f9c8365ff9c7a86484f55d26b40273f66461d04a2e7e65b159d5e3c356e415
|
data/bin/reagan
CHANGED
@@ -20,5 +20,26 @@
|
|
20
20
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
21
21
|
|
22
22
|
require 'reagan'
|
23
|
+
require 'optparse'
|
23
24
|
|
24
|
-
|
25
|
+
options = { :pull => nil, :cookbooks => nil }
|
26
|
+
|
27
|
+
parser = OptionParser.new do |opts|
|
28
|
+
opts.banner = 'Usage: reagan [options]'
|
29
|
+
opts.on('-c', '--cookbooks cookbook', 'Cookbooks to test (comma separated)') do |cookbooks|
|
30
|
+
options[:cookbooks] = cookbooks
|
31
|
+
end
|
32
|
+
|
33
|
+
opts.on('-p', '--pull_num num', 'Pull Number to test') do |pull|
|
34
|
+
options[:pull] = pull
|
35
|
+
end
|
36
|
+
|
37
|
+
opts.on('-h', '--help', 'Displays Help') do
|
38
|
+
puts opts
|
39
|
+
exit
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
parser.parse!
|
44
|
+
|
45
|
+
Reagan.new(options).run
|
data/lib/change.rb
CHANGED
@@ -27,7 +27,8 @@ end
|
|
27
27
|
# determines changed files in the commit
|
28
28
|
class Change < Reagan
|
29
29
|
attr_accessor :files
|
30
|
-
def initialize
|
30
|
+
def initialize(options)
|
31
|
+
@options = options
|
31
32
|
@files = list_files_changed
|
32
33
|
end
|
33
34
|
|
@@ -48,15 +49,24 @@ class Change < Reagan
|
|
48
49
|
files
|
49
50
|
end
|
50
51
|
|
51
|
-
def
|
52
|
-
|
53
|
-
|
52
|
+
def pull_num
|
53
|
+
if @options[:pull]
|
54
|
+
pull = @options[:pull]
|
55
|
+
elsif ENV['ghprbPullId']
|
56
|
+
pull = ENV['ghprbPullId']
|
57
|
+
else
|
58
|
+
fail 'Jenkins ghprbPullId environmental variable not set or --pull option not used. Cannot continue'
|
59
|
+
end
|
60
|
+
pull
|
61
|
+
end
|
54
62
|
|
55
|
-
|
63
|
+
def list_files_changed
|
64
|
+
pull = pull_num
|
65
|
+
puts "Grabbing contents of pull request #{pull}\n"
|
56
66
|
|
57
67
|
gh = Octokit::Client.new(:access_token => @@config['github']['auth_token'])
|
58
68
|
|
59
|
-
pull_files = files_from_pull(gh.pull_request_files(@@config ['github']['repo'],
|
69
|
+
pull_files = files_from_pull(gh.pull_request_files(@@config ['github']['repo'], pull))
|
60
70
|
unique_cookbooks(pull_files)
|
61
71
|
end
|
62
72
|
end
|
data/lib/reagan.rb
CHANGED
@@ -24,8 +24,9 @@ class Reagan
|
|
24
24
|
require 'test_version'
|
25
25
|
|
26
26
|
attr_accessor :config
|
27
|
-
def initialize
|
27
|
+
def initialize(options)
|
28
28
|
@@config = YAML.load_file('/etc/reagan.yml')
|
29
|
+
@options = options
|
29
30
|
end
|
30
31
|
|
31
32
|
# nicely prints marques
|
@@ -37,10 +38,14 @@ class Reagan
|
|
37
38
|
|
38
39
|
# grab the changes and run the tests
|
39
40
|
def run
|
40
|
-
#
|
41
|
-
cookbooks
|
41
|
+
# use passed in list of cookbooks or grab from GH
|
42
|
+
if @options[:cookbooks]
|
43
|
+
cookbooks = @options[:cookbooks].split(',')
|
44
|
+
else
|
45
|
+
cookbooks = Change.new(@options).files
|
46
|
+
end
|
42
47
|
|
43
|
-
pretty_print('The following cookbooks
|
48
|
+
pretty_print('The following cookbooks will be tested')
|
44
49
|
cookbooks.each { |cb| puts cb }
|
45
50
|
|
46
51
|
results = []
|