reagan 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/bin/reagan +22 -1
  3. data/lib/change.rb +16 -6
  4. data/lib/reagan.rb +9 -4
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02c3bd10ce4bddde059363830e05d2176836bca5
4
- data.tar.gz: 7fb0f5239c5be78c0df12f6fdcfe1f482472fb8d
3
+ metadata.gz: a0768ae5db6dcb4bdcbbe702be3806dd3ab4a80f
4
+ data.tar.gz: 402af8fd05ba6df63bfddb6ec7beafb6b0c0bb99
5
5
  SHA512:
6
- metadata.gz: a1409c348a81dc77f64468905626e58d3d987280c0c16d4d555b6beb3434753fb74cf4439e3f89a47e1dd4d07c534f91e9e9ecd4ea92243b3ed9fc2bc7294dbd
7
- data.tar.gz: 1bad65512d3cb2f3d4a2320a5e5aa28d3b39e55f3e315e070b5182ee23bc86001dc725a84396c46c7257e7c65f9c3775524c4898497d045fb712694e6d50c129
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
- Reagan.new.run
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 list_files_changed
52
- # make sure the Github Pull Request plugin was used to pass in the pull ID
53
- fail 'ghprbPullId environmental variable not set. Cannot continue' unless ENV['ghprbPullId']
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
- puts "Grabbing contents of pull request #{ENV['ghprbPullId']}\n"
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'], ENV['ghprbPullId']))
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
- # grab all cookbooks changed
41
- cookbooks = Change.new.files
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 were changed')
48
+ pretty_print('The following cookbooks will be tested')
44
49
  cookbooks.each { |cb| puts cb }
45
50
 
46
51
  results = []
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reagan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Smith