continuous4r 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/History.txt +4 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +83 -0
  4. data/README.txt +1 -0
  5. data/Rakefile +4 -0
  6. data/config/hoe.rb +71 -0
  7. data/config/requirements.rb +17 -0
  8. data/lib/capistrano_formatter.rb +19 -0
  9. data/lib/continuous4r/version.rb +9 -0
  10. data/lib/continuous4r.rb +490 -0
  11. data/lib/flog_formatter.rb +48 -0
  12. data/lib/heckle_formatter.rb +27 -0
  13. data/lib/httperf_formatter.rb +160 -0
  14. data/lib/site/body-capistrano.rhtml +8 -0
  15. data/lib/site/body-changelog.rhtml +8 -0
  16. data/lib/site/body-continuous4r-reports.rhtml +83 -0
  17. data/lib/site/body-dcov.rhtml +27 -0
  18. data/lib/site/body-dependencies.rhtml +52 -0
  19. data/lib/site/body-flog.rhtml +15 -0
  20. data/lib/site/body-heckle.rhtml +16 -0
  21. data/lib/site/body-httperf.rhtml +8 -0
  22. data/lib/site/body-index.rhtml +71 -0
  23. data/lib/site/body-issue-tracking.rhtml +38 -0
  24. data/lib/site/body-kwala.rhtml +35 -0
  25. data/lib/site/body-railroad.rhtml +29 -0
  26. data/lib/site/body-rcov.rhtml +23 -0
  27. data/lib/site/body-rdoc.rhtml +12 -0
  28. data/lib/site/body-scm-usage.rhtml +37 -0
  29. data/lib/site/body-stats.rhtml +8 -0
  30. data/lib/site/body-team-list.rhtml +73 -0
  31. data/lib/site/body-tests.rhtml +8 -0
  32. data/lib/site/body-zentest.rhtml +8 -0
  33. data/lib/site/header.rhtml +41 -0
  34. data/lib/site/images/continuous4r-logo.png +0 -0
  35. data/lib/site/images/external.png +0 -0
  36. data/lib/site/images/icon_error_sml.gif +0 -0
  37. data/lib/site/images/icon_success_sml.gif +0 -0
  38. data/lib/site/images/newwindow.png +0 -0
  39. data/lib/site/menu-capistrano.rhtml +23 -0
  40. data/lib/site/menu-changelog.rhtml +23 -0
  41. data/lib/site/menu-continuous4r-reports.rhtml +31 -0
  42. data/lib/site/menu-dcov.rhtml +23 -0
  43. data/lib/site/menu-dependencies.rhtml +19 -0
  44. data/lib/site/menu-flog.rhtml +23 -0
  45. data/lib/site/menu-heckle.rhtml +23 -0
  46. data/lib/site/menu-httperf.rhtml +23 -0
  47. data/lib/site/menu-index.rhtml +19 -0
  48. data/lib/site/menu-issue-tracking.rhtml +19 -0
  49. data/lib/site/menu-kwala.rhtml +23 -0
  50. data/lib/site/menu-railroad.rhtml +23 -0
  51. data/lib/site/menu-rcov.rhtml +23 -0
  52. data/lib/site/menu-rdoc.rhtml +23 -0
  53. data/lib/site/menu-scm-usage.rhtml +19 -0
  54. data/lib/site/menu-stats.rhtml +23 -0
  55. data/lib/site/menu-team-list.rhtml +19 -0
  56. data/lib/site/menu-tests.rhtml +23 -0
  57. data/lib/site/menu-zentest.rhtml +23 -0
  58. data/lib/site/style/commons-maven.css +113 -0
  59. data/lib/site/style/maven-base.css +151 -0
  60. data/lib/site/style/maven-theme.css +100 -0
  61. data/lib/site/style/project.css +1 -0
  62. data/lib/stats_formatter.rb +51 -0
  63. data/lib/subversion_extractor.rb +64 -0
  64. data/lib/tests_formatter.rb +65 -0
  65. data/lib/zen_test_formatter.rb +48 -0
  66. data/log/debug.log +0 -0
  67. data/script/destroy +14 -0
  68. data/script/destroy.cmd +1 -0
  69. data/script/generate +14 -0
  70. data/script/generate.cmd +1 -0
  71. data/script/txt2html +74 -0
  72. data/script/txt2html.cmd +1 -0
  73. data/setup.rb +1585 -0
  74. data/tasks/deployment.rake +34 -0
  75. data/tasks/environment.rake +7 -0
  76. data/tasks/website.rake +17 -0
  77. data/test/test_continuous4r.rb +11 -0
  78. data/test/test_helper.rb +2 -0
  79. data/website/index.html +411 -0
  80. data/website/index.txt +298 -0
  81. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  82. data/website/stylesheets/screen.css +138 -0
  83. data/website/template.rhtml +48 -0
  84. metadata +141 -0
@@ -0,0 +1,490 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+
3
+ require 'rubygems'
4
+ require 'XmlElements'
5
+ require 'date'
6
+ require 'capistrano_formatter.rb'
7
+ require 'heckle_formatter.rb'
8
+ require 'httperf_formatter.rb'
9
+ require 'stats_formatter.rb'
10
+ require 'tests_formatter.rb'
11
+ require 'zen_test_formatter.rb'
12
+ require 'subversion_extractor.rb'
13
+
14
+ # ==============================================================================
15
+ # Classe modelisant un fichier de description de projet Ruby/Rails
16
+ # Author:: Vincent Dubois
17
+ # Date : 03 decembre 2007
18
+ # ==============================================================================
19
+ module Continuous4r
20
+
21
+ # Support de CruiseControl.rb
22
+ WORK_DIR = "#{ENV['CC_BUILD_ARTIFACTS'].nil? ? "continuous4r_build" : "#{ENV['CC_BUILD_ARTIFACTS']}/continuous4r_build"}"
23
+
24
+ # Methode de generation du site au complet
25
+ def self.generate_site
26
+ project = XmlElements.fromString(File.read("#{RAILS_ROOT}/continuous4r-project.xml"))
27
+ generation_date = DateTime.now
28
+ puts "====================================================================="
29
+ puts " Continuous Integration for Ruby, starting website generation..."
30
+ puts "---------------------------------------------------------------------"
31
+ puts " Project name : #{project['name']}"
32
+ puts " Project URL : #{project.url.text}"
33
+ puts " Generation date : #{generation_date}"
34
+ puts "---------------------------------------------------------------------"
35
+
36
+ # Vérification de présence et de la version de Rubygems
37
+ puts " Checking presence and version of RubyGems..."
38
+ rubygems_version = `gem --version`
39
+ if rubygems_version.empty?
40
+ raise " You don't seem to have RubyGems installed, please go first to http://rubygems.rubyforge.org"
41
+ end
42
+
43
+ # Vérification de la présence d'eRuby
44
+ puts " Checking presence of eRuby for website build..."
45
+ eruby_version = `eruby --version`
46
+ if eruby_version.empty?
47
+ raise " You don't seem to have eRuby installed, please go first to http://www.eruby.info/"
48
+ end
49
+
50
+ # Verification de la presence d'hpricot
51
+ hpricot_version = `gem list|grep hpricot`
52
+ if hpricot_version.empty?
53
+ puts " Installing Hpricot..."
54
+ hpricot_installed = system("sudo gem install hpricot")
55
+ if !hpricot_installed
56
+ raise " Install for Hpricot failed with command 'sudo gem install hpricot'\n BUILD FAILED."
57
+ end
58
+ end
59
+
60
+ # Chargement/Vérification des gems nécessaires à l'application
61
+ puts " Checking gems for this project, please hold on..."
62
+ project.gems.each('gem') do |gem|
63
+ puts " Checking for #{gem['name']} gem, version #{gem['version']}..."
64
+ gem_version = `gem list|grep #{gem['name']}`
65
+ if gem_version.empty? or gem_version.index("#{gem['version']}").nil?
66
+ gem_installed = `gem install #{gem['name']} --version #{gem['version']} 2>&1`
67
+ if !gem_installed.index("ERROR").nil?
68
+ raise " Unable to install #{gem['name']} gem with version #{gem['version']}.\n BUILD FAILED."
69
+ end
70
+ end
71
+ end
72
+
73
+ puts "---------------------------------------------------------------------"
74
+ # Création du répertoire de travail
75
+ if File.exist? "#{WORK_DIR}"
76
+ `rm -Rf #{WORK_DIR}`
77
+ end
78
+ Dir.mkdir "#{WORK_DIR}"
79
+
80
+ auto_install = project.tasks['autoinstall']
81
+ auto_install ||= "false"
82
+
83
+ # Construction des taches
84
+ begin
85
+ project.tasks.each('task') do |task|
86
+ self.build_task task, project['name'], project.scm, auto_install
87
+ puts "\n---------------------------------------------------------------------"
88
+ end
89
+ puts " All tasks done."
90
+ rescue Exception => e
91
+ if e.to_s == "no childs named 'task' found!"
92
+ puts " No task to build."
93
+ else
94
+ raise e
95
+ end
96
+ end
97
+ puts "\n---------------------------------------------------------------------"
98
+ # On copie les feuilles de styles
99
+ `cp -R #{File.dirname(__FILE__)}/site/style/ #{WORK_DIR}/`
100
+ # On copie les images
101
+ `cp -R #{File.dirname(__FILE__)}/site/images/ #{WORK_DIR}/`
102
+ `cp #{File.dirname(__FILE__)}/site/images/continuous4r-logo.png #{WORK_DIR}/`
103
+ puts " Building project information page..."
104
+ eruby_run "index"
105
+ puts " Building team list page..."
106
+ eruby_run "team-list"
107
+ puts " Building project dependencies page..."
108
+ eruby_run "dependencies"
109
+ puts " Building source control management page..."
110
+ eruby_run "scm-usage"
111
+ puts " Building issue tracking page..."
112
+ eruby_run "issue-tracking"
113
+ puts " Building project reports page..."
114
+ eruby_run "continuous4r-reports"
115
+ begin
116
+ project.tasks.each('task') do |task|
117
+ puts " Building #{task['name']} page..."
118
+ eruby_run task['name']
119
+ end
120
+ rescue Exception => e
121
+ unless e.to_s == "no childs named 'task' found!"
122
+ raise e
123
+ end
124
+ end
125
+ puts "\n BUILD SUCCESSFUL."
126
+ puts "====================================================================="
127
+ end
128
+
129
+ # Methode qui permet de construire une tache de nom donne
130
+ def self.build_task task, project_name, scm, auto_install
131
+ case task['name']
132
+ # ==========================================================================
133
+ # Construction de la tache dcov (couverture rdoc)
134
+ # ==========================================================================
135
+ when 'dcov'
136
+ # On verifie la presence de dcov
137
+ dcov_version = `gem list|grep dcov`
138
+ if dcov_version.empty?
139
+ if auto_install == "true"
140
+ puts " Installing dcov..."
141
+ dcov_installed = system("sudo gem install dcov")
142
+ if !dcov_installed
143
+ raise " Install for dcov failed with command 'sudo gem install dcov'\n BUILD FAILED."
144
+ end
145
+ else
146
+ raise " You don't seem to have dcov installed. You can install it with 'gem install dcov'.\n BUILD FAILED."
147
+ end
148
+ end
149
+ # On lance la generation
150
+ puts " Building dcov rdoc coverage report..."
151
+ dcov_pass = system("dcov -p #{task.params.pattern['value']}")
152
+ if !dcov_pass
153
+ raise " Execution of dcov failed with command 'dcov -p #{task.params.pattern['value']}'.\n BUILD FAILED."
154
+ end
155
+ # ==========================================================================
156
+ # Construction de la tache rcov (couverture des tests sur le code)
157
+ # ==========================================================================
158
+ when 'rcov'
159
+ # On verifie la presence de rcov
160
+ rcov_version = `gem list|grep rcov`
161
+ if rcov_version.empty?
162
+ if auto_install == "true"
163
+ puts " Installing rcov..."
164
+ rcov_installed = system("sudo gem install rcov")
165
+ if !rcov_installed
166
+ raise " Install for rcov failed with command 'sudo gem install rcov'\n BUILD FAILED."
167
+ end
168
+ else
169
+ raise " You don't seem to have rcov installed. You can install it with 'gem install rcov'.\n BUILD FAILED."
170
+ end
171
+ end
172
+ # On lance la generation
173
+ puts " Building rcov code coverage report..."
174
+ rcov_pass = system("rcov --rails --exclude rcov,rubyforge #{task.params.file['path']}")
175
+ if !rcov_pass
176
+ raise " Execution of rcov failed with command 'rcov --rails --exclude rcov,rubyforge #{task.params.file['path']}'.\n BUILD FAILED."
177
+ end
178
+ # On recupere le rapport genere
179
+ Dir.mkdir "#{WORK_DIR}/rcov"
180
+ `cp #{task.params.reports['path']}/* #{WORK_DIR}/rcov`
181
+ # ==========================================================================
182
+ # Construction de la tache rdoc (apidoc)
183
+ # ==========================================================================
184
+ when 'rdoc'
185
+ # On lance la generation
186
+ puts " Building rdoc api and rdoc generation report..."
187
+ File.delete("rdoc.log") if File.exist?("rdoc.log")
188
+ rdoc_pass = system("rake doc:reapp > rdoc.log")
189
+ if !rdoc_pass
190
+ raise " Execution of rdoc failed with command 'rake doc:reapp'.\n BUILD FAILED."
191
+ end
192
+ # On recupere la documentation et le fichier de log generes
193
+ Dir.mkdir "#{WORK_DIR}/rdoc"
194
+ `cp -R doc/app/ #{WORK_DIR}/rdoc`
195
+ `cp rdoc.log #{WORK_DIR}/rdoc`
196
+ # ==========================================================================
197
+ # Construction de la tache flog (complexite du code ruby)
198
+ # ==========================================================================
199
+ when 'flog'
200
+ # On verifie la presence de flog
201
+ flog_version = `gem list|grep flog`
202
+ if flog_version.empty?
203
+ if auto_install == "true"
204
+ puts " Installing flog..."
205
+ flog_installed = system("sudo gem install flog")
206
+ if !flog_installed
207
+ raise " Install for flog failed with command 'sudo gem install flog'\n BUILD FAILED."
208
+ end
209
+ else
210
+ raise " You don't seem to have flog installed. You can install it with 'gem install flog'.\n BUILD FAILED."
211
+ end
212
+ end
213
+ # On lance la generation
214
+ puts " Building flog code complexity analysis report..."
215
+ flog_pass = system("find app -name \\*.rb | xargs flog > flog.log")
216
+ if !flog_pass
217
+ raise " Execution of flog failed with command 'find app -name \\*.rb | xargs flog > flog.log'.\n BUILD FAILED."
218
+ end
219
+ # On recupere le fichier de log genere
220
+ Dir.mkdir "#{WORK_DIR}/flog"
221
+ `cp flog.log #{WORK_DIR}/flog`
222
+ # ==========================================================================
223
+ # Construction de la tache kwala (métriques et rapports de qualite ruby)
224
+ # ==========================================================================
225
+ when 'kwala'
226
+ # On verifie la presence de kwala
227
+ kwala_result = `kwala`
228
+ if kwala_result.empty?
229
+ raise " You don't seem to have kwala installed. please go first to http://kwala.rubyforge.org/."
230
+ end
231
+ # On lance la generation
232
+ puts " Building kwala code reports..."
233
+ actions = ""
234
+ task.params.actions.each('action') do |action|
235
+ actions = actions + " -a #{action.text}"
236
+ end
237
+ if actions.empty?
238
+ raise " You must specify at least one action for your kwala task."
239
+ end
240
+ kwala_pass = system("kwala -p #{project_name} -d . -o #{WORK_DIR}/kwala #{actions}")
241
+ if !kwala_pass
242
+ raise " Execution of kwala failed with command 'kwala -p #{project_name} -d . -o #{WORK_DIR}/kwala #{actions}'.\n BUILD FAILED."
243
+ end
244
+ # ==========================================================================
245
+ # Construction de la tache railroad (graphes modeles et controleurs)
246
+ # ==========================================================================
247
+ when 'railroad'
248
+ # On verifie la presence de railroad
249
+ railroad_version = `gem list|grep railroad`
250
+ if railroad_version.empty?
251
+ if auto_install == "true"
252
+ puts " Installing railroad..."
253
+ railroad_installed = system("sudo gem install railroad")
254
+ if !railroad_installed
255
+ raise " Install for railroad failed with command 'sudo gem install railroad'\n BUILD FAILED."
256
+ end
257
+ else
258
+ raise " You don't seem to have railroad installed. You can install it with 'gem install railroad'.\n BUILD FAILED."
259
+ end
260
+ end
261
+ # On lance la generation
262
+ puts " Building railroad graphs..."
263
+ if task.params.generate.text == "all" or task.params.generate.text == "models"
264
+ railroad_pass = system("railroad -i -a -M | dot -Tsvg > models.svg")
265
+ if !railroad_pass
266
+ raise " Execution of railroad failed with command 'railroad -i -a -M | dot -Tsvg > models.svg'.\n BUILD FAILED."
267
+ end
268
+ end
269
+ if task.params.generate.text == "all" or task.params.generate.text == "controllers"
270
+ railroad_pass = system("railroad -i -a -C | dot -Tsvg > controllers.svg")
271
+ if !railroad_pass
272
+ raise " Execution of railroad failed with command 'railroad -i -a -C | dot -Tsvg > controllers.svg'.\n BUILD FAILED."
273
+ end
274
+ end
275
+ # TODO Verifier tout ceci.
276
+ `for file in *.svg
277
+ do
278
+ /bin/mv $file $file.old
279
+ sed 's/font-size:14.00/font-size:11.00/g' < $file.old > $file
280
+ done
281
+ rm *.svg.old`
282
+ # On recupere les graphes generes
283
+ Dir.mkdir "#{WORK_DIR}/railroad"
284
+ `cp *.svg #{WORK_DIR}/railroad`
285
+ # ==========================================================================
286
+ # Construction de la tache stress (montee en charge de l'application)
287
+ # ==========================================================================
288
+ when 'httperf'
289
+ # On verifie la presence de httperf
290
+ httperf_version = `httperf --version`
291
+ if httperf_version.empty?
292
+ raise " You don't seem to have httperf installed. You can install it whith 'sudo apt-get install httperf', or go download it on http://www.hpl.hp.com/research/linux/httperf/."
293
+ end
294
+ # On verifie la presence de mongrel (on ne va pas stresser l'application
295
+ # avec webrick, tout de meme).
296
+ mongrel_version = `gem list|grep mongrel`
297
+ if mongrel_version.empty? or mongrel_version.match(/mongrel /).nil?
298
+ if auto_install == "true"
299
+ puts " Installing Mongrel..."
300
+ mongrel_installed = system("sudo gem install railroad")
301
+ if !mongrel_installed
302
+ raise " Install for Mongrel failed with command 'sudo gem install mongrel'\n BUILD FAILED."
303
+ end
304
+ else
305
+ raise " You don't seem to have mongrel installed. You can install it with 'gem install mongrel'.\n BUILD FAILED."
306
+ end
307
+ end
308
+ Dir.mkdir "#{WORK_DIR}/httperf"
309
+ # On demarre la ou les instances de mongrel
310
+ puts " Starting server instance(s) for application stressing..."
311
+ task.params.ports.each('port') do |port|
312
+ mongrel_start_log = `mongrel_rails start -e production -l #{WORK_DIR}/httperf/mongrel_#{port.text}.log -p #{port.text} -d -P log/mongrel_#{port.text}.pid`
313
+ if !mongrel_start_log.empty?
314
+ raise "BUILD FAILED."
315
+ end
316
+ end
317
+ fork { sleep(3) }
318
+ # On stresse l'application
319
+ if File.exist?("httperf.html")
320
+ File.delete("httperf.html")
321
+ end
322
+ task.params.processes.each('process') do |process|
323
+ params = ""
324
+ if !process['requests'].nil? and !process['requests'].empty?
325
+ params = params + " --num-conns=#{process['requests']}"
326
+ end
327
+ if !process['sessions'].nil? and !process['sessions'].empty?
328
+ params = params + " --wsess=#{process['sessions']}"
329
+ end
330
+ if !process['rate'].nil? and !process['rate'].empty?
331
+ params = params + " --rate=#{process['rate']}"
332
+ end
333
+ if !process['timeout'].nil? and !process['timeout'].empty?
334
+ params = params + " --timeout=#{process['timeout']}"
335
+ end
336
+ httperf_results = `httperf --port #{process['port']} --server 127.0.0.1 --uri #{process['url']}#{params}`
337
+ h = File.open("httperf.html", "a")
338
+ h.write(HttperfFormatter.new(httperf_results, process.description.text).to_html)
339
+ h.close
340
+ end
341
+ # On arrete la ou les instances de mongrel
342
+ puts "\n Stopping server instance(s)..."
343
+ task.params.ports.each('port') do |port|
344
+ puts `mongrel_rails stop -P log/mongrel_#{port.text}.pid`
345
+ end
346
+ # ==========================================================================
347
+ # Construction de la tache heckle (eprouvage des tests)
348
+ # ==========================================================================
349
+ when 'heckle'
350
+ # On verifie la presence de heckle
351
+ heckle_result = `heckle`
352
+ if heckle_result.empty?
353
+ if auto_install == "true"
354
+ puts " Installing heckle..."
355
+ heckle_installed = system("sudo gem install heckle")
356
+ if !heckle_installed
357
+ raise " Install for heckle failed with command 'sudo gem install heckle'\n BUILD FAILED."
358
+ end
359
+ else
360
+ raise " You don't seem to have heckle installed. You can install it with 'gem install heckle'.\n BUILD FAILED."
361
+ end
362
+ end
363
+ # On lance la generation
364
+ puts " Building heckle reports..."
365
+ heckle_report = File.open("heckle.html", "w")
366
+ heckle_report.write(HeckleFormatter.new(task.params).to_html)
367
+ heckle_report.close
368
+ # ==========================================================================
369
+ # Construction de la tache stats (statistiques code Ruby)
370
+ # ==========================================================================
371
+ when 'stats'
372
+ # On lance la generation
373
+ puts " Building stats report..."
374
+ stats_result = `rake stats`
375
+ stats_report = File.open("stats.html", "w")
376
+ stats_report.write(StatsFormatter.new(stats_result).to_html)
377
+ stats_report.close
378
+ # ==========================================================================
379
+ # Construction de la tache tests (tests unitaires, toutes categories)
380
+ # ==========================================================================
381
+ when 'tests'
382
+ # On lance la generation
383
+ puts " Building tests report..."
384
+ if File.exist?("tests.html")
385
+ File.delete("tests.html")
386
+ end
387
+ tests_report = File.open("tests.html", "a")
388
+ tests_report.write(TestsFormatter.new(task.params).to_html)
389
+ tests_report.close
390
+ # ==========================================================================
391
+ # Construction de la tache zentest (manques dans les tests unitaires)
392
+ # ==========================================================================
393
+ when 'zentest'
394
+ # On vérifie la presence de ZenTest
395
+ zentest_result = `zentest`
396
+ if zentest_result.empty?
397
+ if auto_install == "true"
398
+ puts " Installing ZenTest..."
399
+ zentest_installed = system("sudo gem install ZenTest")
400
+ if !zentest_installed
401
+ raise " Install for ZenTest failed with command 'sudo gem install ZenTest'.\n BUILD FAILED."
402
+ end
403
+ else
404
+ raise " You don't seem to have ZenTest installed. You can install it with 'gem install ZenTest'.\n BUILD FAILED."
405
+ end
406
+ end
407
+ # On lance la generation
408
+ puts " Building ZenTest report..."
409
+ zentest_report = File.open("zentest.html", "w")
410
+ zentest_report.write(ZenTestFormatter.new(task.params).to_html)
411
+ zentest_report.close
412
+ # ==========================================================================
413
+ # Construction de la tache capistrano (logs des deploiements effectues)
414
+ # ==========================================================================
415
+ when 'capistrano'
416
+ # On vérifie la presence de Capistrano
417
+ cap_result = `cap --version`
418
+ if cap_result.empty?
419
+ raise " You don't seem to have Capistrano installed. You can install it with 'gem install capistrano'."
420
+ end
421
+ # On lance la generation
422
+ puts " Building Capistrano log report..."
423
+ capistrano_report = File.open("capistrano.html", "w")
424
+ task.params.each('runner') do |runner|
425
+ if File.exist?("capistrano.log")
426
+ File.delete("capistrano.log")
427
+ end
428
+ capistrano_pass = system("cap #{runner['task']} 2> capistrano.log")
429
+ if !capistrano_pass
430
+ capistrano_report.close
431
+ raise(" Capistrano deployment with command \'cap #{runner['task']}\' did not pass.\n BUILD FAILED.")
432
+ else
433
+ capistrano_report.write(CapistranoFormatter.new(runner['task'],File.read("capistrano.log")).to_html)
434
+ end
435
+ end
436
+ capistrano_report.close
437
+ # ===========================================================================
438
+ # Construction de la tache changelog (changements du referentiel de sources)
439
+ # ===========================================================================
440
+ when 'changelog'
441
+ unless scm.repository_type.text == "svn"
442
+ raise " Only Subversion is supported at the moment. You need to deactivate the 'changelog' task.\n BUILD FAILED."
443
+ end
444
+ # On verifie l'existence de Subversion
445
+ svn_version = `svn --version`
446
+ if svn_version.empty?
447
+ raise " Subversion don't seem to be installed. Go see Subversion website on http://subversion.tigris.org.\n BUILD FAILED"
448
+ end
449
+ # Gestion de la derniere version
450
+ # 1 - On verifie le repertoire home/continuous4r
451
+ unless File.exist?(ENV["HOME"] + "/.continuous4r")
452
+ Dir.mkdir(ENV["HOME"] + "/.continuous4r")
453
+ end
454
+ # 2 - On verifie le numero de version
455
+ scm_current_version = scm['min_revision']
456
+ scm_current_version ||= "1"
457
+ scm_last_version = 1
458
+ if File.exist?(ENV["HOME"] + "/.continuous4r/#{project_name}_#{scm.repository_type.text}.version")
459
+ scm_current_version = File.read(ENV["HOME"] + "/.continuous4r/#{project_name}_#{scm.repository_type.text}.version")
460
+ end
461
+ # 3 - On extrait les informations du referentiel
462
+ case scm.repository_type.text
463
+ when "svn"
464
+ scm_last_version = SubversionExtractor.extract_changelog(scm_current_version.to_i,scm,"changelog.html")
465
+ end
466
+ # 4 - On ecrit le nouveau numero de revision
467
+ rev_file = File.open(ENV["HOME"] + "/.continuous4r/#{project_name}_#{scm.repository_type.text}.version","w")
468
+ rev_file.write(scm_last_version)
469
+ rev_file.close
470
+ else
471
+ raise " Don't know how to build '#{task['name']}' task."
472
+ end
473
+ end
474
+
475
+ # Methode qui permet de construire une page avec eruby, et de lever une exception au besoin
476
+ def self.eruby_run page
477
+ command = "eruby #{File.dirname(__FILE__)}/site/header.rhtml >> #{WORK_DIR}/#{page}.html"
478
+ if !system(command)
479
+ raise "BUILD FAILED."
480
+ end
481
+ command = "eruby #{File.dirname(__FILE__)}/site/menu-#{page}.rhtml >> #{WORK_DIR}/#{page}.html"
482
+ if !system(command)
483
+ raise "BUILD FAILED."
484
+ end
485
+ command = "eruby #{File.dirname(__FILE__)}/site/body-#{page}.rhtml >> #{WORK_DIR}/#{page}.html"
486
+ if !system(command)
487
+ raise "BUILD FAILED."
488
+ end
489
+ end
490
+ end
@@ -0,0 +1,48 @@
1
+ # ================================================
2
+ # Classe de formatage de resultat renvoye par flog
3
+ # Author: Vincent Dubois
4
+ # ================================================
5
+ class FlogFormatter
6
+ attr_accessor :results
7
+
8
+ # Constructeur
9
+ def initialize results
10
+ self.results = results
11
+ end
12
+
13
+ # Methode qui permet de fabriquer le flux HTML a partir du flux console flog
14
+ def to_html
15
+ lines = self.results.split(/$/)
16
+ total_score = lines[0].split(" = ")[1]
17
+ html = "<h3>Total score : #{total_score}</h3>"
18
+ # On supprime les deux premieres lignes (total et ligne vide) et la derniere (ligne vide)
19
+ lines.delete_at(0)
20
+ lines.delete_at(0)
21
+ lines.delete_at(lines.length-1)
22
+ begin
23
+ lines.each_with_index do |line, index|
24
+ html = html + format_line(line, index)
25
+ end
26
+ rescue Exception => e
27
+ raise " Unable to format flog results. Exception is : #{e.to_s}"
28
+ end
29
+ html = html + "</tbody></table>"
30
+ end
31
+
32
+ # Méthode qui permet de formater une ligne de resultat
33
+ def format_line line, index
34
+ html = ""
35
+ if line[1..1] != ' '
36
+ if index != 0
37
+ html = html + "</tbody></table><br/>"
38
+ end
39
+ html = html + "<table class='bodyTable'><thead><th>Element</th><th>Score</th></thead><tbody>"
40
+ total_score = line.split(': ')[1]
41
+ total_score = total_score.split(/\(|\)/)
42
+ html = html + "<tr class='#{index % 2 == 0 ? "a" : "b"}'><td><b>#{line.split(': ')[0]}</b></td><td><b>#{total_score}</b></td></tr>"
43
+ else
44
+ html = html + "<tr class='#{index % 2 == 0 ? "a" : "b"}'><td>&#160;&#160;&#160;&#160;&#160;#{line.split(': ')[1]}</td><td>#{line.split(': ')[0]}</td></tr>"
45
+ end
46
+ return html
47
+ end
48
+ end
@@ -0,0 +1,27 @@
1
+ require 'rubygems'
2
+ require 'XmlElements'
3
+ # =====================================================
4
+ # Classe de formatage des resultats renvoyes par heckle
5
+ # Author: Vincent Dubois
6
+ # =====================================================
7
+ class HeckleFormatter
8
+ attr_accessor :params
9
+
10
+ # Constructeur
11
+ def initialize params
12
+ self.params = params
13
+ end
14
+
15
+ # Methode qui permet de fabriquer le flux HTML a partir des flux console heckle
16
+ def to_html
17
+ html = "<table class='bodyTable'><thead><th>Testing element</th><th>Pass</th><th>Result</th></thead><tbody>"
18
+ i = 0
19
+ self.params.each('test') do |test|
20
+ puts " Running heckle on #{test['class']} against #{test['test_pattern']}..."
21
+ pass = system("heckle #{test['class']} -t #{test['test_pattern']} > heckle.log")
22
+ html = html + "<tr class='#{ i % 2 == 0 ? 'a' : 'b'}'><td><strong>#{test['class']}</strong> against <strong>#{test['test_pattern']}</strong></td><td style='text-align: center;'><img src='images/icon_#{pass ? 'success' : 'error'}_sml.gif'/></td><td><pre>#{File.read("heckle.log")}</pre></td></tr>"
23
+ i = i + 1
24
+ end
25
+ html = html + "</tbody></table>"
26
+ end
27
+ end