etsy-deployinator 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +368 -0
  5. data/Rakefile +16 -0
  6. data/bin/deployinator-tailer.rb +78 -0
  7. data/deployinator.gemspec +31 -0
  8. data/lib/deployinator.rb +114 -0
  9. data/lib/deployinator/app.rb +204 -0
  10. data/lib/deployinator/base.rb +58 -0
  11. data/lib/deployinator/config.rb +7 -0
  12. data/lib/deployinator/controller.rb +147 -0
  13. data/lib/deployinator/helpers.rb +610 -0
  14. data/lib/deployinator/helpers/deploy.rb +68 -0
  15. data/lib/deployinator/helpers/dsh.rb +42 -0
  16. data/lib/deployinator/helpers/git.rb +348 -0
  17. data/lib/deployinator/helpers/plugin.rb +50 -0
  18. data/lib/deployinator/helpers/stack-tail.rb +32 -0
  19. data/lib/deployinator/helpers/version.rb +62 -0
  20. data/lib/deployinator/helpers/view.rb +67 -0
  21. data/lib/deployinator/logging.rb +16 -0
  22. data/lib/deployinator/plugin.rb +7 -0
  23. data/lib/deployinator/stack-tail.rb +34 -0
  24. data/lib/deployinator/static/css/diff_style.css +283 -0
  25. data/lib/deployinator/static/css/highlight.css +235 -0
  26. data/lib/deployinator/static/css/style.css +1223 -0
  27. data/lib/deployinator/static/js/flot/jquery.flot.min.js +1 -0
  28. data/lib/deployinator/static/js/flot/jquery.flot.selection.js +299 -0
  29. data/lib/deployinator/static/js/jquery-1.8.3.min.js +2 -0
  30. data/lib/deployinator/static/js/jquery-ui-1.8.24.min.js +5 -0
  31. data/lib/deployinator/static/js/jquery.timed_bar.js +36 -0
  32. data/lib/deployinator/tasks/initialize.rake +84 -0
  33. data/lib/deployinator/tasks/tests.rake +22 -0
  34. data/lib/deployinator/templates/deploys_status.mustache +42 -0
  35. data/lib/deployinator/templates/generic_single_push.mustache +64 -0
  36. data/lib/deployinator/templates/index.mustache +12 -0
  37. data/lib/deployinator/templates/layout.mustache +604 -0
  38. data/lib/deployinator/templates/log.mustache +24 -0
  39. data/lib/deployinator/templates/log_table.mustache +90 -0
  40. data/lib/deployinator/templates/messageboxes.mustache +29 -0
  41. data/lib/deployinator/templates/run_logs.mustache +15 -0
  42. data/lib/deployinator/templates/scroll_control.mustache +8 -0
  43. data/lib/deployinator/templates/stream.mustache +13 -0
  44. data/lib/deployinator/version.rb +3 -0
  45. data/lib/deployinator/views/deploys_status.rb +22 -0
  46. data/lib/deployinator/views/index.rb +14 -0
  47. data/lib/deployinator/views/layout.rb +48 -0
  48. data/lib/deployinator/views/log.rb +12 -0
  49. data/lib/deployinator/views/log_table.rb +35 -0
  50. data/lib/deployinator/views/run_logs.rb +32 -0
  51. data/templates/app.rb.erb +7 -0
  52. data/templates/config.ru.erb +10 -0
  53. data/templates/helper.rb.erb +15 -0
  54. data/templates/stack.rb.erb +17 -0
  55. data/templates/template.mustache +1 -0
  56. data/templates/view.rb.erb +7 -0
  57. data/test/unit/helpers_dsh_test.rb +40 -0
  58. data/test/unit/helpers_test.rb +77 -0
  59. data/test/unit/version_test.rb +104 -0
  60. metadata +245 -0
@@ -0,0 +1,77 @@
1
+ require 'deployinator'
2
+ require 'deployinator/helpers'
3
+ require 'deployinator/helpers/dsh'
4
+
5
+ class HelpersTest < Test::Unit::TestCase
6
+ include Deployinator::Helpers,
7
+ Deployinator::Helpers::DshHelpers
8
+
9
+ def setup
10
+ @jurl = %Q{<a href='https://github.com/example/repo/issues/%s' target='_blank'>%s</a>}
11
+ @issue1 = "ABC-123"
12
+ @issue2 = "DEF-456"
13
+ @issue1_linked = "#{@jurl % ([@issue1] * 2)}"
14
+ @issue2_linked = "#{@jurl % ([@issue2] * 2)}"
15
+ Deployinator.default_user = "testuser"
16
+ Deployinator.deploy_host = "deploytest.vm.ny4dev.etsy.com"
17
+ Deployinator.issue_tracker = proc do |issue|
18
+ "https://github.com/example/repo/issues/#{issue}"
19
+ end
20
+
21
+ # mock out the run_cmd. this should move.
22
+ Deployinator::Helpers.module_eval do
23
+ define_method "run_cmd" do |cmd|
24
+ return { :stdout => cmd, :exit_code => 0 }
25
+ end
26
+ end
27
+ end
28
+
29
+ def test_single_issue_linked
30
+ assert_equal %Q{I #{@issue1_linked}}, hyperlink("I #{@issue1}")
31
+ end
32
+
33
+ def test_multiple_issue_linked
34
+ assert_equal %Q{I #{@issue1_linked}, #{@issue2_linked}}, hyperlink("I #{@issue1}, #{@issue2}")
35
+ end
36
+
37
+ def test_no_issue_linked
38
+ assert_equal %Q{I ABC -123, DEF -456}, hyperlink("I ABC -123, DEF -456")
39
+ end
40
+
41
+ def test_no_message
42
+ assert_equal %Q{}, hyperlink(nil)
43
+ end
44
+
45
+ def test_run_dsh
46
+ assert_equal %Q{ssh testuser@deploytest.vm.ny4dev.etsy.com dsh -g princess -r ssh -F 30 "whoami"},
47
+ run_dsh("princess", "whoami")
48
+ end
49
+
50
+ def test_run_dsh_multiple
51
+ assert_equal %Q{ssh testuser@deploytest.vm.ny4dev.etsy.com dsh -g princess -g p2 -r ssh -F 30 "whoami"},
52
+ run_dsh(["princess", "p2"], "whoami")
53
+ end
54
+
55
+ def test_with_timeout_failed
56
+ res = with_timeout 1 do
57
+ `sleep 2 && echo -n "foo"`
58
+ end
59
+ assert_equal "", res
60
+ end
61
+
62
+ def test_with_timeout_success
63
+ res = with_timeout 3 do
64
+ `sleep 2 && echo -n "foo"`
65
+ end
66
+ assert_equal "foo", res
67
+ end
68
+
69
+ def test_strip_to_nil
70
+ assert_equal(nil, strip_ws_to_nil(nil))
71
+ assert_equal(nil, strip_ws_to_nil(''))
72
+ assert_equal(nil, strip_ws_to_nil(' '))
73
+ assert_equal('host01', strip_ws_to_nil('host01 '))
74
+ assert_equal('host01,host02', strip_ws_to_nil(' host01 , host02 '))
75
+ assert_equal('host01', strip_ws_to_nil('host01'))
76
+ end
77
+ end
@@ -0,0 +1,104 @@
1
+ require 'deployinator/helpers/version'
2
+ require 'test/unit'
3
+ require 'mocha/setup'
4
+
5
+ class VersionTest < Test::Unit::TestCase
6
+
7
+ def test_get_build_from_valid_string
8
+ res = Deployinator::Helpers::VersionHelpers.get_build('c5e3d40-20111227-195028-UTC')
9
+ assert_equal('c5e3d40', res)
10
+ end
11
+
12
+ def test_get_build_from_longer_rev
13
+ res = Deployinator::Helpers::VersionHelpers.get_build('c5e3d4066-20111227-195028-UTC')
14
+ assert_equal('c5e3d4066', res)
15
+ end
16
+
17
+ def test_get_build_from_rev_too_short
18
+ res = Deployinator::Helpers::VersionHelpers.get_build('c5e3d-20111227-195028-UTC')
19
+ assert_equal(nil, res)
20
+ end
21
+
22
+ def test_get_build_from_invalid_string
23
+ res = Deployinator::Helpers::VersionHelpers.get_build('<!DOCTYPE html>
24
+ <html xmlns="http://www.w3.org/1999/xhtml">
25
+ <head>')
26
+ assert_equal(nil, res)
27
+ end
28
+
29
+ def test_get_build_from_nil
30
+ res = Deployinator::Helpers::VersionHelpers.get_build nil
31
+ assert_equal(nil, res)
32
+ end
33
+
34
+ # unit test get_version_by_url with mocked curl_get_url
35
+ def test_get_version_by_url_with_real_version
36
+ Deployinator::Helpers::VersionHelpers.expects(:curl_get_url)
37
+ .with("http://testhost.etsy.com/version.txt")
38
+ .returns("c5e3d40-20111227-195028-UTC")
39
+ res = Deployinator::Helpers::VersionHelpers.get_version_by_url("http://testhost.etsy.com/version.txt")
40
+ assert_equal("c5e3d40-20111227-195028-UTC", res)
41
+ end
42
+
43
+ def test_get_version_by_url_with_invalid_string
44
+ Deployinator::Helpers::VersionHelpers.expects(:curl_get_url)
45
+ .with("http://testhost.etsy.com/version.txt")
46
+ .returns('<!DOCTYPE html>
47
+ <html xmlns="http://www.w3.org/1999/xhtml">
48
+ <head>')
49
+ res = Deployinator::Helpers::VersionHelpers.get_version_by_url("http://testhost.etsy.com/version.txt")
50
+ assert_equal(nil, res)
51
+ end
52
+
53
+ def test_get_version_by_url_with_too_short_format
54
+ Deployinator::Helpers::VersionHelpers.expects(:curl_get_url)
55
+ .with("http://testhost.etsy.com/version.txt")
56
+ .returns("c5e3d40-201127-195028-UTC")
57
+ res = Deployinator::Helpers::VersionHelpers.get_version_by_url("http://testhost.etsy.com/version.txt")
58
+ assert_equal(nil, res)
59
+ end
60
+
61
+ def test_get_version_by_url_with_too_long_format
62
+ Deployinator::Helpers::VersionHelpers.expects(:curl_get_url)
63
+ .with("http://testhost.etsy.com/version.txt")
64
+ .returns("c5e3d40-2011122700-195028-UTC")
65
+ res = Deployinator::Helpers::VersionHelpers.get_version_by_url("http://testhost.etsy.com/version.txt")
66
+ assert_equal(nil, res)
67
+ end
68
+
69
+ # integration testing the get_version method with get_version_by_url
70
+ def test_get_version_with_real_version
71
+ Deployinator::Helpers::VersionHelpers.expects(:curl_get_url)
72
+ .with("http://testhost.etsy.com/version.txt")
73
+ .returns("c5e3d40-20111227-195028-UTC")
74
+ res = Deployinator::Helpers::VersionHelpers.get_version("testhost.etsy.com")
75
+ assert_equal("c5e3d40-20111227-195028-UTC", res)
76
+ end
77
+
78
+ def test_get_version_with_invalid_string
79
+ Deployinator::Helpers::VersionHelpers.expects(:curl_get_url)
80
+ .with("http://testhost.etsy.com/version.txt")
81
+ .returns('<!DOCTYPE html>
82
+ <html xmlns="http://www.w3.org/1999/xhtml">
83
+ <head>')
84
+ res = Deployinator::Helpers::VersionHelpers.get_version("testhost.etsy.com")
85
+ assert_equal(nil, res)
86
+ end
87
+
88
+ def test_get_version_with_too_short_format
89
+ Deployinator::Helpers::VersionHelpers.expects(:curl_get_url)
90
+ .with("http://testhost.etsy.com/version.txt")
91
+ .returns("c5e3d40-201127-195028-UTC")
92
+ res = Deployinator::Helpers::VersionHelpers.get_version("testhost.etsy.com")
93
+ assert_equal(nil, res)
94
+ end
95
+
96
+ def test_get_version_with_too_long_format
97
+ Deployinator::Helpers::VersionHelpers.expects(:curl_get_url)
98
+ .with("http://testhost.etsy.com/version.txt")
99
+ .returns("c5e3d40-2011122700-195028-UTC")
100
+ res = Deployinator::Helpers::VersionHelpers.get_version("testhost.etsy.com")
101
+ assert_equal(nil, res)
102
+ end
103
+
104
+ end
metadata ADDED
@@ -0,0 +1,245 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: etsy-deployinator
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - JPaul
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mocha
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: mustache
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '0.99'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '0.99'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pony
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: tlsmail
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: eventmachine
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: eventmachine-tail
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: em-websocket
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: sinatra
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: 1.4.3
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: 1.4.3
153
+ description: Deployinator as a Gem
154
+ email:
155
+ - jpaul@etsy.com
156
+ executables:
157
+ - deployinator-tailer.rb
158
+ extensions: []
159
+ extra_rdoc_files: []
160
+ files:
161
+ - Gemfile
162
+ - LICENSE.txt
163
+ - README.md
164
+ - Rakefile
165
+ - bin/deployinator-tailer.rb
166
+ - deployinator.gemspec
167
+ - lib/deployinator.rb
168
+ - lib/deployinator/app.rb
169
+ - lib/deployinator/base.rb
170
+ - lib/deployinator/config.rb
171
+ - lib/deployinator/controller.rb
172
+ - lib/deployinator/helpers.rb
173
+ - lib/deployinator/helpers/deploy.rb
174
+ - lib/deployinator/helpers/dsh.rb
175
+ - lib/deployinator/helpers/git.rb
176
+ - lib/deployinator/helpers/plugin.rb
177
+ - lib/deployinator/helpers/stack-tail.rb
178
+ - lib/deployinator/helpers/version.rb
179
+ - lib/deployinator/helpers/view.rb
180
+ - lib/deployinator/logging.rb
181
+ - lib/deployinator/plugin.rb
182
+ - lib/deployinator/stack-tail.rb
183
+ - lib/deployinator/static/css/diff_style.css
184
+ - lib/deployinator/static/css/highlight.css
185
+ - lib/deployinator/static/css/style.css
186
+ - lib/deployinator/static/js/flot/jquery.flot.min.js
187
+ - lib/deployinator/static/js/flot/jquery.flot.selection.js
188
+ - lib/deployinator/static/js/jquery-1.8.3.min.js
189
+ - lib/deployinator/static/js/jquery-ui-1.8.24.min.js
190
+ - lib/deployinator/static/js/jquery.timed_bar.js
191
+ - lib/deployinator/tasks/initialize.rake
192
+ - lib/deployinator/tasks/tests.rake
193
+ - lib/deployinator/templates/deploys_status.mustache
194
+ - lib/deployinator/templates/generic_single_push.mustache
195
+ - lib/deployinator/templates/index.mustache
196
+ - lib/deployinator/templates/layout.mustache
197
+ - lib/deployinator/templates/log.mustache
198
+ - lib/deployinator/templates/log_table.mustache
199
+ - lib/deployinator/templates/messageboxes.mustache
200
+ - lib/deployinator/templates/run_logs.mustache
201
+ - lib/deployinator/templates/scroll_control.mustache
202
+ - lib/deployinator/templates/stream.mustache
203
+ - lib/deployinator/version.rb
204
+ - lib/deployinator/views/deploys_status.rb
205
+ - lib/deployinator/views/index.rb
206
+ - lib/deployinator/views/layout.rb
207
+ - lib/deployinator/views/log.rb
208
+ - lib/deployinator/views/log_table.rb
209
+ - lib/deployinator/views/run_logs.rb
210
+ - templates/app.rb.erb
211
+ - templates/config.ru.erb
212
+ - templates/helper.rb.erb
213
+ - templates/stack.rb.erb
214
+ - templates/template.mustache
215
+ - templates/view.rb.erb
216
+ - test/unit/helpers_dsh_test.rb
217
+ - test/unit/helpers_test.rb
218
+ - test/unit/version_test.rb
219
+ homepage: ''
220
+ licenses: []
221
+ metadata: {}
222
+ post_install_message:
223
+ rdoc_options: []
224
+ require_paths:
225
+ - lib
226
+ required_ruby_version: !ruby/object:Gem::Requirement
227
+ requirements:
228
+ - - '>='
229
+ - !ruby/object:Gem::Version
230
+ version: '0'
231
+ required_rubygems_version: !ruby/object:Gem::Requirement
232
+ requirements:
233
+ - - '>='
234
+ - !ruby/object:Gem::Version
235
+ version: '0'
236
+ requirements: []
237
+ rubyforge_project:
238
+ rubygems_version: 2.0.14
239
+ signing_key:
240
+ specification_version: 4
241
+ summary: Rewrite of deployinator to be a gem
242
+ test_files:
243
+ - test/unit/helpers_dsh_test.rb
244
+ - test/unit/helpers_test.rb
245
+ - test/unit/version_test.rb