integrity 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/README.markdown +66 -0
  2. data/Rakefile +165 -0
  3. data/VERSION.yml +4 -0
  4. data/app.rb +138 -0
  5. data/bin/integrity +4 -0
  6. data/config/config.sample.ru +31 -0
  7. data/config/config.sample.yml +38 -0
  8. data/config/thin.sample.yml +13 -0
  9. data/integrity.gemspec +76 -0
  10. data/lib/integrity.rb +80 -0
  11. data/lib/integrity/build.rb +61 -0
  12. data/lib/integrity/core_ext/object.rb +6 -0
  13. data/lib/integrity/core_ext/string.rb +5 -0
  14. data/lib/integrity/helpers.rb +16 -0
  15. data/lib/integrity/helpers/authorization.rb +33 -0
  16. data/lib/integrity/helpers/breadcrumbs.rb +20 -0
  17. data/lib/integrity/helpers/forms.rb +28 -0
  18. data/lib/integrity/helpers/pretty_output.rb +45 -0
  19. data/lib/integrity/helpers/rendering.rb +14 -0
  20. data/lib/integrity/helpers/resources.rb +13 -0
  21. data/lib/integrity/helpers/urls.rb +47 -0
  22. data/lib/integrity/installer.rb +132 -0
  23. data/lib/integrity/migrations.rb +157 -0
  24. data/lib/integrity/notifier.rb +50 -0
  25. data/lib/integrity/notifier/base.rb +55 -0
  26. data/lib/integrity/project.rb +117 -0
  27. data/lib/integrity/project_builder.rb +47 -0
  28. data/lib/integrity/scm.rb +19 -0
  29. data/lib/integrity/scm/git.rb +83 -0
  30. data/lib/integrity/scm/git/uri.rb +57 -0
  31. data/public/buttons.css +82 -0
  32. data/public/reset.css +7 -0
  33. data/public/spinner.gif +0 -0
  34. data/test/helpers.rb +47 -0
  35. data/test/helpers/acceptance.rb +127 -0
  36. data/test/helpers/acceptance/git_helper.rb +99 -0
  37. data/test/helpers/acceptance/textfile_notifier.rb +26 -0
  38. data/test/helpers/expectations.rb +5 -0
  39. data/test/helpers/expectations/be_a.rb +23 -0
  40. data/test/helpers/expectations/change.rb +90 -0
  41. data/test/helpers/expectations/have.rb +105 -0
  42. data/test/helpers/expectations/have_tag.rb +128 -0
  43. data/test/helpers/expectations/predicates.rb +37 -0
  44. data/test/helpers/fixtures.rb +83 -0
  45. data/views/_build_info.haml +18 -0
  46. data/views/build.haml +2 -0
  47. data/views/error.haml +36 -0
  48. data/views/home.haml +23 -0
  49. data/views/integrity.sass +387 -0
  50. data/views/layout.haml +28 -0
  51. data/views/new.haml +51 -0
  52. data/views/not_found.haml +31 -0
  53. data/views/notifier.haml +7 -0
  54. data/views/project.builder +21 -0
  55. data/views/project.haml +28 -0
  56. data/views/unauthorized.haml +38 -0
  57. metadata +258 -0
@@ -0,0 +1,37 @@
1
+ module Matchy::Expectations
2
+ class PredicateExpectation < Base
3
+ def initialize(predicate, *arguments)
4
+ @test_case = arguments.pop
5
+ @predicate = predicate
6
+ @arguments = arguments
7
+ end
8
+
9
+ def matches?(receiver)
10
+ @receiver = receiver
11
+ @receiver.send("#{@predicate}?", *@arguments)
12
+ end
13
+
14
+ def failure_message
15
+ message = "Expected #{@receiver.inspect} to be #{@predicate}"
16
+ message << " with #{@arguments.map {|e| e.inspect }.join(", ")}" unless @arguments.empty?
17
+ message
18
+ end
19
+
20
+ def negative_failure_message
21
+ message = "Expected #{@receiver.inspect} not to be #{@predicate}"
22
+ message << " with #{@arguments.map {|e| e.inspect }.join(", ")}" unless @arguments.empty?
23
+ message
24
+ end
25
+ end
26
+
27
+ module TestCaseExtensions
28
+ def method_missing(method, *args, &block)
29
+ if method.to_s =~ /^be_(.*)/
30
+ args << self
31
+ Matchy::Expectations::PredicateExpectation.new($1, *args)
32
+ else
33
+ super
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,83 @@
1
+ require 'rubygems'
2
+ require 'dm-sweatshop'
3
+
4
+ include DataMapper::Sweatshop::Unique
5
+
6
+ class Array
7
+ def pick
8
+ self[rand(self.length)]
9
+ end
10
+ end
11
+
12
+ def commit_metadata
13
+ meta_data = <<-EOS
14
+ ---
15
+ :author: #{/\w+ \w+ <\w+@example.org>/.gen}
16
+ :message: >-
17
+ #{/\w+/.gen}
18
+ :date: #{unique {|i| Time.mktime(2008, 12, 15, 18, (59 - i) % 60) }}
19
+ EOS
20
+ end
21
+
22
+ def create_notifier!(name)
23
+ klass = Class.new(Integrity::Notifier::Base) do
24
+ def self.to_haml; ""; end
25
+ def deliver!; nil; end
26
+ end
27
+
28
+ unless Integrity::Notifier.const_defined?(name)
29
+ Integrity::Notifier.const_set(name, klass)
30
+ end
31
+ end
32
+
33
+
34
+ Integrity::Project.fixture do
35
+ { :name => (name = unique { /\w+/.gen }),
36
+ :uri => "git://github.com/#{/\w+/.gen}/#{name}.git",
37
+ :branch => ["master", "test-refactoring", "lh-34"].pick,
38
+ :command => ["rake", "make", "ant -buildfile test.xml"].pick,
39
+ :public => [true, false].pick,
40
+ :building => [true, false].pick }
41
+ end
42
+
43
+ Integrity::Project.fixture(:integrity) do
44
+ { :name => "Integrity",
45
+ :uri => "git://github.com/foca/integrity.git",
46
+ :branch => "master",
47
+ :command => "rake",
48
+ :public => true,
49
+ :building => false }
50
+ end
51
+
52
+ Integrity::Project.fixture(:my_test_project) do
53
+ { :name => "My Test Project",
54
+ :uri => Integrity.root / "my-test-project",
55
+ :branch => "master",
56
+ :command => "./test",
57
+ :public => true,
58
+ :building => false }
59
+ end
60
+
61
+ Integrity::Build.fixture do
62
+ { :output => /[:paragraph:]/.gen,
63
+ :successful => true,
64
+ :created_at => unique {|i| Time.mktime(2008, 12, 15, 18, (59 - i) % 60) },
65
+ :commit_identifier => Digest::SHA1.hexdigest(/[:paragraph:]/.gen),
66
+ :commit_metadata => commit_metadata }
67
+ end
68
+
69
+ Integrity::Notifier.fixture(:irc) do
70
+ create_notifier! "IRC"
71
+
72
+ { :project => Integrity::Project.generate,
73
+ :name => "IRC",
74
+ :config => { :uri => "irc://irc.freenode.net/integrity" }}
75
+ end
76
+
77
+ Integrity::Notifier.fixture(:twitter) do
78
+ create_notifier! "Twitter"
79
+
80
+ { :project => Integrity::Project.generate,
81
+ :name => "Twitter",
82
+ :config => { :email => "foo@example.org", :pass => "secret" }}
83
+ end
@@ -0,0 +1,18 @@
1
+ %h1<
2
+ &== Built #{build.short_commit_identifier} #{build.successful? ? "successfully" : "and failed"}
3
+ %blockquote
4
+ %p&= build.commit_message
5
+ %p.meta<
6
+ %span.who<
7
+ &== by: #{build.commit_author.name}
8
+ |
9
+ %span.when{ :title => build.commited_at.iso8601 }<
10
+ &= pretty_date build.commited_at
11
+ |
12
+ %span.what<
13
+ &== commit: #{build.commit_identifier}
14
+
15
+ %h2 Build Output:
16
+ %pre.output
17
+ :preserve
18
+ #{bash_color_codes h(build.output)}
data/views/build.haml ADDED
@@ -0,0 +1,2 @@
1
+ #build{ :class => @build.status }
2
+ = partial(:build_info, :build => @build)
data/views/error.haml ADDED
@@ -0,0 +1,36 @@
1
+ .error
2
+ %h1
3
+ Whatever you do, DON'T PANIC!
4
+
5
+ %dl
6
+ %dt This is what happened:
7
+ %dd
8
+ %strong&= @error.message
9
+ %pre.backtrace= @error.backtrace.join("\n")
10
+ %dd
11
+ %strong Query parameters:
12
+ %pre.query_params= params.inspect
13
+
14
+ %dt What can I do?
15
+ %dd
16
+ Is your
17
+ %a{ :href => project_url(@project, :edit) } config
18
+ ok?
19
+ Need
20
+ %a{ :href => "http://integrityapp.com/configure" } help?
21
+ Remember to restart Integrity.
22
+ If you think everything is fine,
23
+ then drop by our irc channel:
24
+ %a{ :href => "irc://irc.freenode.org:6667/integrity" } #integrity
25
+ on freenode, and we'll try to help.
26
+
27
+ %dt
28
+ What the hell is
29
+ = succeed "?" do
30
+ %strong Integrity
31
+ %dd
32
+ Integrity is your friendly
33
+ %a{ :href => "http://en.wikipedia.org/wiki/Continuous_integration" } Continuous Integration
34
+ server. If you want to know more about us, check our website at
35
+ = succeed "." do
36
+ %a{ :href => "http://integrityapp.com" } integrityapp.com
data/views/home.haml ADDED
@@ -0,0 +1,23 @@
1
+ - if @projects.empty?
2
+ .blank_slate
3
+ %p None yet, huh?
4
+ %h1
5
+ Why don't you
6
+ = succeed "?" do
7
+ %a{ :href => "/new" } create your first project
8
+ - else
9
+ %ul#projects
10
+ - @projects.each do |project|
11
+ %li{ :class => cycle("even", "odd") + (project.building? ? ' building' : '') + (project.last_build ? (project.last_build.successful? ? ' success' : ' failed') : '') }
12
+ %a{ :href => project_path(project) }&= project.name
13
+ .meta
14
+ - if project.building?
15
+ Building!
16
+ - elsif project.last_build.nil?
17
+ Never built yet
18
+ - else
19
+ == Built #{project.last_build.short_commit_identifier}
20
+ = pretty_date(project.last_build.created_at)
21
+ = project.last_build.successful? ? "successfully" : "and failed"
22
+ %p#new
23
+ %a{ :href => "/new" } Add a new project
@@ -0,0 +1,387 @@
1
+ !default_fonts = "Helvetica Neue, Helvetica, Arial, sans-serif"
2
+ !nice_fonts = "Georgia, Times New Roman, serif"
3
+ !monospace_fonts = "Monaco, Deja Vu Sans Mono, Inconsolata, Consolas, monospace"
4
+
5
+ !page_bg = #e0e0e0
6
+ !content_bg = #eee
7
+ !header_bg = #fff
8
+ !text_color = #333
9
+ !light_color = #999
10
+ !title_color = #4e4e4e
11
+ !link_color = #ed1556
12
+ !link_bg = #fff
13
+ !rule_color = #c0c0c0
14
+ !watermark = #ccc
15
+ !quote_bg = #fff
16
+ !success_bg = #bbf8aa
17
+ !success_color = #337022
18
+ !failed_bg = #fba
19
+ !failed_color = #f10
20
+
21
+ html
22
+ :background-color = !page_bg
23
+
24
+ body
25
+ :font-size 100%
26
+ :font-family = !default_fonts
27
+ :color = !text_color
28
+
29
+ a
30
+ :color = !link_color
31
+ :text-decoration none
32
+ &:hover
33
+ :color = !link_bg
34
+ :background-color = !link_color
35
+
36
+ #header, #content, #footer
37
+ :width 40em
38
+ :margin 0 auto
39
+ :background = !content_bg
40
+ :padding 0 2em
41
+ :z-index 0
42
+ :position relative
43
+ :font-size 1em
44
+
45
+ #header
46
+ :background = !header_bg
47
+ h1
48
+ :font-weight bold
49
+ :font-size 1.5em
50
+ address.watermark
51
+ :position absolute
52
+ :font-weight bold
53
+ :right 3em
54
+ :top 0
55
+ :font-size .75em
56
+ :color = !watermark
57
+ a
58
+ :color = !watermark
59
+ :font-weight bold
60
+ :font-size 2em
61
+ &:hover
62
+ :background transparent
63
+ :color = !watermark - #222
64
+
65
+ #content
66
+ :padding-top 1em
67
+ :padding-bottom 2em
68
+
69
+ strong
70
+ :font-weight bold
71
+ em
72
+ :font-style italic
73
+
74
+ h1, h2, h3, h4, h5, h6
75
+ :color = !title_color
76
+ h1
77
+ :font-size 2em
78
+ :font-weight bold
79
+ :margin-bottom .75em
80
+ :padding .25em 0
81
+ :line-height 1.2
82
+ :border-bottom = 1px solid !rule_color
83
+ h2
84
+ :font-weight bold
85
+ :font-size 1.5em
86
+ :margin 1em 0 .2em
87
+ h3
88
+ :font-weight bold
89
+ :font-size 1.25em
90
+ :margin .25em 0
91
+ h4, h5, h6
92
+ :font-weight bold
93
+ :margin-top .5em
94
+
95
+ code, pre, textarea, input
96
+ :font-family = !monospace_fonts
97
+ pre
98
+ margin .5em :0
99
+ padding .5em
100
+
101
+ form
102
+ p
103
+ :margin-top 1em
104
+ :position relative
105
+ &.checkbox label
106
+ :margin-top 0 !important
107
+ input.text, textarea
108
+ :width 30em
109
+ :padding .2em .4em
110
+ :color = !title_color
111
+ :height 1.4em
112
+ label
113
+ :float left
114
+ :display block
115
+ :margin-top .5em
116
+ :width 8em
117
+ :margin-right .75em
118
+ .with_errors
119
+ label
120
+ :background red
121
+ :color white
122
+ :position relative
123
+ :top -.7em
124
+ &.required
125
+ label
126
+ :position static
127
+ :margin-right .25em
128
+ :padding 0 .2em
129
+ input, textarea
130
+ :border 2px solid #f22
131
+ :background #fee
132
+ :color = !text_color - #111
133
+ .required
134
+ label
135
+ :float none
136
+ :display block
137
+ :width auto
138
+ :position relative
139
+ :font-weight bold
140
+ :margin-top 1em
141
+ :text-indent -.65em
142
+ &:before
143
+ :content "* "
144
+ :color = !link_color
145
+ input.text
146
+ :width 25.6em
147
+ :font-size 24px
148
+ :font-weight bold
149
+ .normal
150
+ :margin-top 2em
151
+ h2.notifier label
152
+ :float none
153
+ :width auto
154
+ :margin-right 0
155
+ .warning
156
+ :font-size .5em
157
+ :font-weight normal
158
+ :color = !light_color
159
+ fieldset
160
+ :padding-bottom 1em
161
+ :margin-left 1.35em
162
+ :border-bottom = 1px solid !rule_color
163
+ :margin-bottom 1em
164
+ h3
165
+ :margin-top 1em
166
+ :margin-bottom 0
167
+ p.normal
168
+ :margin-top 1em
169
+ p label
170
+ :width 6.7em
171
+ p.submit
172
+ :margin-top 2em
173
+ &:after
174
+ :display block
175
+ :clear both
176
+ :float none
177
+ :content "."
178
+ :text-indent -9999em
179
+ :text-align left
180
+ &.destroy
181
+ :margin-top 0
182
+ button
183
+ :float none
184
+ :display inline
185
+
186
+ .blank_slate, .error
187
+ p
188
+ :position relative
189
+ :top .3em
190
+ h1
191
+ :border-width 0
192
+ :margin 0
193
+ :padding 0
194
+ button
195
+ :float none
196
+ :border 0 none
197
+ :background transparent
198
+ :display inline
199
+ :color = !link_color
200
+ :padding 0.25em 0
201
+ :margin 0
202
+ &:hover
203
+ :background = !link_color
204
+ :color = !link_bg
205
+
206
+ .error
207
+ dt
208
+ :margin
209
+ :top 1.4em
210
+ :bottom .3em
211
+ :font
212
+ :size 1.75em
213
+ :family = !nice_fonts
214
+ dd
215
+ :line-height 1.4
216
+
217
+ .backtrace
218
+ :margin 1em 0
219
+ :overflow scroll
220
+ :height 30em
221
+ :border = 1px solid !rule_color
222
+ :line-height 1.6
223
+
224
+ #projects
225
+ :margin 1em 0 2em
226
+ :border-top = 1px solid !rule_color
227
+ li
228
+ :position relative
229
+ :border-bottom = 1px solid !rule_color
230
+ &.odd
231
+ :background = !content_bg - #080808
232
+ &.building
233
+ :background transparent url(/spinner.gif) no-repeat scroll right
234
+ a
235
+ :font-size 2em
236
+ :padding .25em
237
+ :line-height 1.2
238
+ :font-weight bold
239
+ :display block
240
+ &.success
241
+ :color = !success_color
242
+ &.failed
243
+ :color = !failed_color
244
+ .meta
245
+ :position absolute
246
+ :right .6em
247
+ :top 1.5em
248
+ :font-size 0.8em
249
+ :color = !light_color
250
+ :text-align right
251
+ &.building .meta
252
+ :right 1.6em
253
+ &.success .meta
254
+ :color = !success_color
255
+ &.failed .meta
256
+ :color = !failed_color
257
+
258
+
259
+ #previous_builds
260
+ li
261
+ a
262
+ :display block
263
+ :padding .25em
264
+ :margin-bottom .25em
265
+ :border
266
+ :width 1px
267
+ :style solid
268
+ strong
269
+ :font-size 1.3em
270
+ .attribution
271
+ :font-size .9em
272
+
273
+ #projects, #previous_builds
274
+ li
275
+ &.success a
276
+ :background-color = !success_bg
277
+ :border-color = !success_bg - #222
278
+ :color = !success_color
279
+ .attribution
280
+ :color = !success_bg - #444
281
+ &:hover
282
+ :background-color = !success_bg + #222
283
+ &.failed a
284
+ :background-color = !failed_bg
285
+ :border-color = !failed_bg - #222
286
+ :color = !failed_color
287
+ .attribution
288
+ :color = !failed_bg - #444
289
+ &:hover
290
+ :background-color = !failed_bg + #222
291
+
292
+
293
+ #build, #last_build
294
+ h1, blockquote
295
+ :border
296
+ :width 0 1px
297
+ :style solid
298
+ h1
299
+ :border-top-width 1px
300
+ blockquote
301
+ :bottom-bottom-width 1px
302
+ :line-height 1.4
303
+
304
+ &.success
305
+ h1, blockquote
306
+ :background-color = !success_bg
307
+ :border-color = (!success_bg - #222) (!success_bg + #111) (!success_bg + #111) (!success_bg - #222)
308
+ h1
309
+ :color = !success_color
310
+ .meta
311
+ :color = !success_bg - #444
312
+
313
+ &.failed
314
+ h1, blockquote
315
+ :background-color = !failed_bg
316
+ :border-color = (!failed_bg - #222) (!failed_bg + #111) (!failed_bg + #111) (!failed_bg - #222)
317
+ h1
318
+ :color = !failed_color
319
+ .meta
320
+ :color = !failed_bg - #444
321
+
322
+ h1
323
+ :margin-top .5em
324
+ :margin-bottom 0
325
+ :padding .25em
326
+ :color = !success_color
327
+
328
+ blockquote
329
+ :padding .75em
330
+ :margin-bottom 2em
331
+ .meta
332
+ :margin-top 1em
333
+ :display block
334
+ :font-size .9em
335
+
336
+ pre.output
337
+ :background #111
338
+ :color #fff
339
+ :padding .5em
340
+ :overflow auto
341
+ :max-height 50em
342
+ :font-size .825em
343
+
344
+ .color30
345
+ :color #333
346
+ .color31
347
+ :color #e33
348
+ .color32
349
+ :color #3e3
350
+ .color33
351
+ :color #ee3
352
+ .color34
353
+ :color #33e
354
+ .color35
355
+ :color #e3e
356
+ .color36
357
+ :color #3ee
358
+ .color37
359
+ :color #fff
360
+
361
+ #push_path
362
+ :display block
363
+ :margin
364
+ :top 1em
365
+ :left 2em
366
+
367
+ a
368
+ &.success
369
+ :color = !success_bg
370
+ &:hover
371
+ :background-color = !success_bg
372
+ :color white
373
+ &.failed
374
+ :color = !failed_bg
375
+ &:hover
376
+ :background-color = !failed_bg
377
+ :color white
378
+
379
+ #footer
380
+ :padding 1.5em 2.5em
381
+ :border-top 1px solid #ccc
382
+ :font-size .8em
383
+ :width 50em !important
384
+ :color #666
385
+ :text-align right
386
+ strong
387
+ :font-weight bold