lobot 1.0.pre → 2.0.0pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/.gitignore +3 -0
  2. data/Gemfile +0 -1
  3. data/Guardfile +10 -0
  4. data/README.md +52 -72
  5. data/Rakefile +2 -6
  6. data/Vagrantfile +15 -0
  7. data/bin/lobot +7 -0
  8. data/chef/cookbooks/pivotal_ci/.gitignore +4 -0
  9. data/chef/cookbooks/pivotal_ci/Gemfile +3 -0
  10. data/chef/cookbooks/pivotal_ci/README.md +3 -0
  11. data/chef/cookbooks/pivotal_ci/attributes/git.rb +1 -1
  12. data/chef/cookbooks/pivotal_ci/attributes/jenkins.rb +2 -3
  13. data/chef/cookbooks/pivotal_ci/attributes/nginx.rb +1 -2
  14. data/chef/cookbooks/pivotal_ci/attributes/ssl.rb +1 -1
  15. data/chef/cookbooks/pivotal_ci/files/default/tests/minitest/default_test.rb +37 -0
  16. data/chef/cookbooks/pivotal_ci/metadata.rb +10 -0
  17. data/chef/cookbooks/pivotal_ci/recipes/id_rsa.rb +5 -2
  18. data/chef/cookbooks/pivotal_ci/recipes/jenkins.rb +1 -1
  19. data/chef/cookbooks/pivotal_ci/recipes/jenkins_config.rb +10 -17
  20. data/chef/cookbooks/pivotal_ci/recipes/nginx.rb +2 -0
  21. data/chef/cookbooks/pivotal_ci/templates/default/jenkins-job-config.xml.erb +11 -3
  22. data/chef/cookbooks/pivotal_ci/templates/default/nginx-htaccess.erb +3 -3
  23. data/chef/cookbooks/pivotal_ci/templates/default/org.jenkinsci.plugins.xvfb.XvfbBuildWrapper.xml.erb +11 -0
  24. data/chef/cookbooks/pivotal_ci/test/kitchen/Kitchenfile +4 -0
  25. data/chef/cookbooks/pivotal_ci/test/kitchen/cookbooks/pivotal_ci_test/attributes/default.rb +3 -0
  26. data/chef/cookbooks/pivotal_ci/test/kitchen/cookbooks/pivotal_ci_test/metadata.rb +10 -0
  27. data/chef/cookbooks/pivotal_ci/test/kitchen/cookbooks/pivotal_ci_test/recipes/default.rb +41 -0
  28. data/lib/generators/lobot/templates/soloistrc +2 -1
  29. data/lib/lobot.rb +1 -12
  30. data/lib/lobot/amazon.rb +91 -0
  31. data/lib/lobot/cli.rb +148 -0
  32. data/lib/lobot/config.rb +80 -0
  33. data/lib/lobot/jenkins.rb +17 -0
  34. data/lib/lobot/sobo.rb +35 -0
  35. data/lib/lobot/tasks/ci.rake +0 -178
  36. data/lib/lobot/version.rb +1 -1
  37. data/lobot.gemspec +19 -15
  38. data/script/bootstrap_server.sh +4 -1
  39. data/spec/lib/lobot/amazon_spec.rb +127 -0
  40. data/spec/lib/lobot/cli_spec.rb +212 -0
  41. data/spec/lib/lobot/config_spec.rb +95 -0
  42. data/spec/lib/lobot/jenkins_spec.rb +14 -0
  43. data/spec/spec_helper.rb +5 -10
  44. metadata +87 -31
  45. data/chef/cookbooks/pivotal_ci/libraries/ci_config.rb +0 -2
  46. data/spec/install_spec.rb +0 -80
@@ -0,0 +1,95 @@
1
+ require "spec_helper"
2
+
3
+ describe Lobot::Config do
4
+ let(:default_config) { Lobot::Config.new }
5
+
6
+ describe "with a file" do
7
+ let(:config_contents) { {ssh_port: 42} }
8
+ let(:tempfile) do
9
+ Tempfile.new('lobot-config').tap do |file|
10
+ file.write YAML.dump(config_contents)
11
+ file.close
12
+ end
13
+ end
14
+
15
+ let(:config) { Lobot::Config.from_file(tempfile.path) }
16
+
17
+ describe ".from_file" do
18
+ it "loads from a yaml file" do
19
+ config.ssh_port.should == 42
20
+ end
21
+ end
22
+
23
+ describe "#save" do
24
+ it "writes the values to the file" do
25
+ config.ssh_port = 20912
26
+ config.save
27
+ config = Lobot::Config.from_file(tempfile.path)
28
+ config.ssh_port.should == 20912
29
+ end
30
+ end
31
+
32
+ describe "soloistrc-specific attributes" do
33
+ let(:recipes) { ["pivotal_workstation::broken_postgres", "pivotal_workstation::janus"] }
34
+ let(:node_attributes) { default_config.node_attributes.merge({"radiator" => {"busted" => "hella"}}) }
35
+ let(:config_contents) { {recipes: recipes, node_attributes: node_attributes} }
36
+
37
+ describe "#recipes" do
38
+ it "preserves the recipes in a config file" do
39
+ config.recipes.should == recipes
40
+ end
41
+ end
42
+
43
+ describe "#soloistrc" do
44
+ it "has recipes" do
45
+ config.soloistrc['recipes'].should == recipes
46
+ end
47
+
48
+ it "has node_attributes" do
49
+ config.soloistrc['node_attributes']['radiator']['busted'].should == "hella"
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ describe "defaults" do
56
+ its(:ssh_port) { should == 22 }
57
+ its(:server_ssh_key) { should =~ /id_rsa$/ }
58
+ its(:github_ssh_key) { should =~ /id_rsa$/ }
59
+ its(:recipes) { should == ["pivotal_ci::jenkins", "pivotal_ci::limited_travis_ci_environment", "pivotal_ci"] }
60
+ its(:cookbook_paths) { should == ['./chef/cookbooks/', './chef/travis-cookbooks/ci_environment'] }
61
+ its(:instance_size) { should == 'c1.medium' }
62
+
63
+ describe "#node_attributes" do
64
+ it "defaults to overwriting the travis build environment" do
65
+ subject.node_attributes.travis_build_environment.to_hash.should == {
66
+ "user" => "jenkins",
67
+ "group" => "nogroup",
68
+ "home" => "/var/lib/jenkins"
69
+ }
70
+ end
71
+ end
72
+
73
+ describe "#soloistrc" do
74
+ it "defaults to recipes and nginx basic auth" do
75
+ subject.soloistrc.should == {
76
+ "recipes" => subject.recipes,
77
+ "cookbook_paths" => subject.cookbook_paths,
78
+ "node_attributes" => {
79
+ "nginx" => {
80
+ "basic_auth_user" => "ci",
81
+ },
82
+ "travis_build_environment" => {
83
+ "user" => "jenkins",
84
+ "group" => "nogroup",
85
+ "home" => "/var/lib/jenkins"
86
+ },
87
+ "jenkins" => {
88
+ "builds" => []
89
+ }
90
+ }
91
+ }
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,14 @@
1
+ require "spec_helper"
2
+
3
+ describe Lobot::Jenkins do
4
+ let(:lobot_config) { Lobot::Config.new }
5
+ let(:jenkins) { Lobot::Jenkins.new(lobot_config) }
6
+
7
+ describe "#jobs" do
8
+ before { jenkins.stub(:api_json).and_return({"jobs" => [{"name" => "meat"}]}) }
9
+
10
+ it "returns the jobs on a running instance" do
11
+ jenkins.jobs.first.name.should == "meat"
12
+ end
13
+ end
14
+ end
@@ -1,11 +1,6 @@
1
- require "rubygems"
1
+ $: << File.expand_path("../../lib", __FILE__)
2
2
 
3
- require 'rails/all'
4
- require 'rails/generators'
5
-
6
- require File.expand_path('../lib/lobot', File.dirname(__FILE__))
7
-
8
- require 'generator_spec/test_case'
9
-
10
- require 'generator_spec'
11
- require File.expand_path('../../lib/generators/lobot/install_generator.rb', __FILE__)
3
+ require "lobot"
4
+ require "lobot/cli"
5
+ require "godot"
6
+ require "tempfile"
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lobot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.pre
5
- prerelease: 4
4
+ version: 2.0.0pre
5
+ prerelease: 5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Matthew Kocher
@@ -12,26 +12,42 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2012-09-30 00:00:00.000000000 Z
15
+ date: 2012-10-29 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: fog
19
19
  requirement: !ruby/object:Gem::Requirement
20
20
  none: false
21
21
  requirements:
22
- - - ! '>='
22
+ - - ~>
23
23
  - !ruby/object:Gem::Version
24
- version: 0.9.0
24
+ version: '1.6'
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
- - - ! '>='
30
+ - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: 0.9.0
32
+ version: '1.6'
33
33
  - !ruby/object:Gem::Dependency
34
- name: capistrano
34
+ name: ci_reporter
35
+ requirement: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ type: :runtime
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ version: '1.7'
49
+ - !ruby/object:Gem::Dependency
50
+ name: thor
35
51
  requirement: !ruby/object:Gem::Requirement
36
52
  none: false
37
53
  requirements:
@@ -47,7 +63,7 @@ dependencies:
47
63
  - !ruby/object:Gem::Version
48
64
  version: '0'
49
65
  - !ruby/object:Gem::Dependency
50
- name: capistrano-ext
66
+ name: hashie
51
67
  requirement: !ruby/object:Gem::Requirement
52
68
  none: false
53
69
  requirements:
@@ -63,7 +79,7 @@ dependencies:
63
79
  - !ruby/object:Gem::Version
64
80
  version: '0'
65
81
  - !ruby/object:Gem::Dependency
66
- name: rvm
82
+ name: net-ssh
67
83
  requirement: !ruby/object:Gem::Requirement
68
84
  none: false
69
85
  requirements:
@@ -79,14 +95,14 @@ dependencies:
79
95
  - !ruby/object:Gem::Version
80
96
  version: '0'
81
97
  - !ruby/object:Gem::Dependency
82
- name: rvm-capistrano
98
+ name: godot
83
99
  requirement: !ruby/object:Gem::Requirement
84
100
  none: false
85
101
  requirements:
86
102
  - - ! '>='
87
103
  - !ruby/object:Gem::Version
88
104
  version: '0'
89
- type: :runtime
105
+ type: :development
90
106
  prerelease: false
91
107
  version_requirements: !ruby/object:Gem::Requirement
92
108
  none: false
@@ -95,46 +111,46 @@ dependencies:
95
111
  - !ruby/object:Gem::Version
96
112
  version: '0'
97
113
  - !ruby/object:Gem::Dependency
98
- name: nokogiri
114
+ name: rspec
99
115
  requirement: !ruby/object:Gem::Requirement
100
116
  none: false
101
117
  requirements:
102
118
  - - ! '>='
103
119
  - !ruby/object:Gem::Version
104
- version: 1.4.4
105
- type: :runtime
120
+ version: '0'
121
+ type: :development
106
122
  prerelease: false
107
123
  version_requirements: !ruby/object:Gem::Requirement
108
124
  none: false
109
125
  requirements:
110
126
  - - ! '>='
111
127
  - !ruby/object:Gem::Version
112
- version: 1.4.4
128
+ version: '0'
113
129
  - !ruby/object:Gem::Dependency
114
- name: ci_reporter
130
+ name: jasmine
115
131
  requirement: !ruby/object:Gem::Requirement
116
132
  none: false
117
133
  requirements:
118
134
  - - ! '>='
119
135
  - !ruby/object:Gem::Version
120
- version: 1.7.0
121
- type: :runtime
136
+ version: '0'
137
+ type: :development
122
138
  prerelease: false
123
139
  version_requirements: !ruby/object:Gem::Requirement
124
140
  none: false
125
141
  requirements:
126
142
  - - ! '>='
127
143
  - !ruby/object:Gem::Version
128
- version: 1.7.0
144
+ version: '0'
129
145
  - !ruby/object:Gem::Dependency
130
- name: headless
146
+ name: guard-rspec
131
147
  requirement: !ruby/object:Gem::Requirement
132
148
  none: false
133
149
  requirements:
134
150
  - - ! '>='
135
151
  - !ruby/object:Gem::Version
136
152
  version: '0'
137
- type: :runtime
153
+ type: :development
138
154
  prerelease: false
139
155
  version_requirements: !ruby/object:Gem::Requirement
140
156
  none: false
@@ -143,7 +159,7 @@ dependencies:
143
159
  - !ruby/object:Gem::Version
144
160
  version: '0'
145
161
  - !ruby/object:Gem::Dependency
146
- name: cucumber
162
+ name: guard-bundler
147
163
  requirement: !ruby/object:Gem::Requirement
148
164
  none: false
149
165
  requirements:
@@ -159,7 +175,7 @@ dependencies:
159
175
  - !ruby/object:Gem::Version
160
176
  version: '0'
161
177
  - !ruby/object:Gem::Dependency
162
- name: rspec
178
+ name: test-kitchen
163
179
  requirement: !ruby/object:Gem::Requirement
164
180
  none: false
165
181
  requirements:
@@ -175,7 +191,7 @@ dependencies:
175
191
  - !ruby/object:Gem::Version
176
192
  version: '0'
177
193
  - !ruby/object:Gem::Dependency
178
- name: generator_spec
194
+ name: pry
179
195
  requirement: !ruby/object:Gem::Requirement
180
196
  none: false
181
197
  requirements:
@@ -191,7 +207,7 @@ dependencies:
191
207
  - !ruby/object:Gem::Version
192
208
  version: '0'
193
209
  - !ruby/object:Gem::Dependency
194
- name: rails
210
+ name: terminal-notifier-guard
195
211
  requirement: !ruby/object:Gem::Requirement
196
212
  none: false
197
213
  requirements:
@@ -207,7 +223,7 @@ dependencies:
207
223
  - !ruby/object:Gem::Version
208
224
  version: '0'
209
225
  - !ruby/object:Gem::Dependency
210
- name: jasmine
226
+ name: rb-fsevent
211
227
  requirement: !ruby/object:Gem::Requirement
212
228
  none: false
213
229
  requirements:
@@ -222,10 +238,27 @@ dependencies:
222
238
  - - ! '>='
223
239
  - !ruby/object:Gem::Version
224
240
  version: '0'
241
+ - !ruby/object:Gem::Dependency
242
+ name: vagrant
243
+ requirement: !ruby/object:Gem::Requirement
244
+ none: false
245
+ requirements:
246
+ - - ~>
247
+ - !ruby/object:Gem::Version
248
+ version: '1.0'
249
+ type: :development
250
+ prerelease: false
251
+ version_requirements: !ruby/object:Gem::Requirement
252
+ none: false
253
+ requirements:
254
+ - - ~>
255
+ - !ruby/object:Gem::Version
256
+ version: '1.0'
225
257
  description: Rails generators that make it easy to spin up a CI instance in the cloud.
226
258
  email:
227
259
  - lobot@pivotallabs.com
228
- executables: []
260
+ executables:
261
+ - lobot
229
262
  extensions: []
230
263
  extra_rdoc_files: []
231
264
  files:
@@ -234,15 +267,22 @@ files:
234
267
  - .rspec
235
268
  - .rvmrc
236
269
  - Gemfile
270
+ - Guardfile
237
271
  - LICENSE.txt
238
272
  - README.md
239
273
  - Rakefile
274
+ - Vagrantfile
275
+ - bin/lobot
276
+ - chef/cookbooks/pivotal_ci/.gitignore
277
+ - chef/cookbooks/pivotal_ci/Gemfile
278
+ - chef/cookbooks/pivotal_ci/README.md
240
279
  - chef/cookbooks/pivotal_ci/attributes/git.rb
241
280
  - chef/cookbooks/pivotal_ci/attributes/jenkins.rb
242
281
  - chef/cookbooks/pivotal_ci/attributes/nginx.rb
243
282
  - chef/cookbooks/pivotal_ci/attributes/ssl.rb
244
283
  - chef/cookbooks/pivotal_ci/files/default/jenkins-ci.org.key
245
- - chef/cookbooks/pivotal_ci/libraries/ci_config.rb
284
+ - chef/cookbooks/pivotal_ci/files/default/tests/minitest/default_test.rb
285
+ - chef/cookbooks/pivotal_ci/metadata.rb
246
286
  - chef/cookbooks/pivotal_ci/recipes/default.rb
247
287
  - chef/cookbooks/pivotal_ci/recipes/fonts.rb
248
288
  - chef/cookbooks/pivotal_ci/recipes/git_config.rb
@@ -256,7 +296,12 @@ files:
256
296
  - chef/cookbooks/pivotal_ci/templates/default/jenkins-job-config.xml.erb
257
297
  - chef/cookbooks/pivotal_ci/templates/default/nginx-conf.erb
258
298
  - chef/cookbooks/pivotal_ci/templates/default/nginx-htaccess.erb
299
+ - chef/cookbooks/pivotal_ci/templates/default/org.jenkinsci.plugins.xvfb.XvfbBuildWrapper.xml.erb
259
300
  - chef/cookbooks/pivotal_ci/templates/default/teamcity-initd.erb
301
+ - chef/cookbooks/pivotal_ci/test/kitchen/Kitchenfile
302
+ - chef/cookbooks/pivotal_ci/test/kitchen/cookbooks/pivotal_ci_test/attributes/default.rb
303
+ - chef/cookbooks/pivotal_ci/test/kitchen/cookbooks/pivotal_ci_test/metadata.rb
304
+ - chef/cookbooks/pivotal_ci/test/kitchen/cookbooks/pivotal_ci_test/recipes/default.rb
260
305
  - ci_build.sh
261
306
  - docs/ci_yml.md
262
307
  - features/ci.feature
@@ -272,13 +317,21 @@ files:
272
317
  - lib/generators/lobot/templates/deploy-ci.rb
273
318
  - lib/generators/lobot/templates/soloistrc
274
319
  - lib/lobot.rb
320
+ - lib/lobot/amazon.rb
321
+ - lib/lobot/cli.rb
322
+ - lib/lobot/config.rb
323
+ - lib/lobot/jenkins.rb
275
324
  - lib/lobot/railtie.rb
276
325
  - lib/lobot/recipes/ci.rb
326
+ - lib/lobot/sobo.rb
277
327
  - lib/lobot/tasks/ci.rake
278
328
  - lib/lobot/version.rb
279
329
  - lobot.gemspec
280
330
  - script/bootstrap_server.sh
281
- - spec/install_spec.rb
331
+ - spec/lib/lobot/amazon_spec.rb
332
+ - spec/lib/lobot/cli_spec.rb
333
+ - spec/lib/lobot/config_spec.rb
334
+ - spec/lib/lobot/jenkins_spec.rb
282
335
  - spec/spec_helper.rb
283
336
  - chef/travis-cookbooks/.gitignore
284
337
  - chef/travis-cookbooks/LICENSE
@@ -932,5 +985,8 @@ test_files:
932
985
  - features/config/secrets.yml.example
933
986
  - features/step_definitions/ci_steps.rb
934
987
  - features/support/env.rb
935
- - spec/install_spec.rb
988
+ - spec/lib/lobot/amazon_spec.rb
989
+ - spec/lib/lobot/cli_spec.rb
990
+ - spec/lib/lobot/config_spec.rb
991
+ - spec/lib/lobot/jenkins_spec.rb
936
992
  - spec/spec_helper.rb
@@ -1,2 +0,0 @@
1
- ci_conf_location = File.expand_path('../../../../../ci.yml', __FILE__)
2
- ::CI_CONFIG = YAML.load_file(ci_conf_location)
@@ -1,80 +0,0 @@
1
- require 'spec_helper'
2
- require "fileutils"
3
-
4
- describe Lobot::InstallGenerator do
5
- include GeneratorSpec::TestCase
6
-
7
- destination File.expand_path("../tmp", __FILE__)
8
-
9
- before do
10
- prepare_destination
11
- end
12
-
13
- after :all do
14
- FileUtils.rm_rf ::File.expand_path("../tmp", __FILE__)
15
- end
16
-
17
- context "without requiring input" do
18
- before do
19
- before_generator
20
- run_generator
21
- end
22
-
23
- let(:before_generator) {}
24
-
25
- context "when no .gitignore exists" do
26
- it "creates .gitignore" do
27
- assert_file ".gitignore", /spec\/reports/
28
- end
29
- end
30
-
31
- context "when there is already a .gitignore" do
32
- let(:before_generator) do
33
- system("touch #{destination_root}/.gitignore")
34
- end
35
-
36
- it "adds spec/reports to the gitignore" do
37
- assert_file ".gitignore", /spec\/reports/
38
- end
39
- end
40
-
41
- it "creates ci.yml" do
42
- assert_file "config/ci.yml", /app_name/
43
- end
44
-
45
- it "creates a ci_build.sh file" do
46
- assert_file "script/ci_build.sh"
47
- end
48
-
49
- it "makes ci_build.sh executable" do
50
- system("test -x #{destination_root}/script/ci_build.sh").should == true
51
- end
52
-
53
- context "Capfile exists" do
54
- it "appends a load path to the Capfile" do
55
- prepare_destination
56
- system("echo 'line 2' > #{destination_root}/Capfile")
57
- run_generator
58
- assert_file "Capfile", "load 'lobot/recipes/ci'\nline 2\n"
59
- end
60
- end
61
-
62
- context "Capfile doesn't exist" do
63
- it "create a Capfile" do
64
- assert_file "Capfile", /load 'lobot\/recipes\/ci'/
65
- end
66
-
67
- it "give you the capify (default) capfile, but commented out" do
68
- assert_file "Capfile", /# load 'deploy'/
69
- end
70
- end
71
-
72
- it "creates config/deploy/ci.rb" do
73
- assert_file "config/deploy/ci.rb", /role :ci, "#\{ci_server\}:#\{ssh_port\}"/
74
- end
75
-
76
- it "creates soloistrc" do
77
- assert_file "soloistrc", /cookbook_paths/
78
- end
79
- end
80
- end