continuous4r 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/History.txt +1 -1
  2. data/Manifest.txt +34 -34
  3. data/PostInstall.txt +3 -0
  4. data/README.rdoc +58 -0
  5. data/Rakefile +28 -3
  6. data/lib/changelog_builder.rb +51 -0
  7. data/lib/continuous4r.rb +63 -426
  8. data/lib/dcov_builder.rb +144 -0
  9. data/lib/flay_builder.rb +38 -0
  10. data/lib/flog_builder.rb +120 -0
  11. data/lib/git_extractor.rb +48 -0
  12. data/lib/rcov_builder.rb +23 -0
  13. data/lib/rdoc_builder.rb +33 -0
  14. data/lib/reek_builder.rb +38 -0
  15. data/lib/roodi_builder.rb +41 -0
  16. data/lib/saikuro_builder.rb +20 -0
  17. data/lib/site/body-changelog.rhtml +1 -1
  18. data/lib/site/body-continuous4r-reports.rhtml +40 -47
  19. data/lib/site/body-dcov.rhtml +1 -21
  20. data/lib/site/body-flay.rhtml +16 -0
  21. data/lib/site/body-flog.rhtml +2 -10
  22. data/lib/site/body-rcov.rhtml +2 -3
  23. data/lib/site/body-rdoc.rhtml +1 -1
  24. data/lib/site/body-reek.rhtml +16 -0
  25. data/lib/site/body-roodi.rhtml +16 -0
  26. data/lib/site/body-saikuro.rhtml +32 -0
  27. data/lib/site/body-scm-usage.rhtml +13 -12
  28. data/lib/site/body-stats.rhtml +1 -1
  29. data/lib/site/body-tests.rhtml +1 -1
  30. data/lib/site/body-xdoclet.rhtml +29 -0
  31. data/lib/site/body-zentest.rhtml +1 -1
  32. data/lib/site/flog.html.erb +33 -0
  33. data/lib/site/flog_page.html.erb +74 -0
  34. data/lib/site/header.rhtml +36 -20
  35. data/lib/site/images/added.png +0 -0
  36. data/lib/site/images/deleted.png +0 -0
  37. data/lib/site/images/modified.png +0 -0
  38. data/lib/site/menu-continuous4r-reports.rhtml +4 -14
  39. data/lib/site/{menu-dcov.rhtml → menu-task.rhtml} +3 -5
  40. data/lib/site/style/maven-base.css +3 -0
  41. data/lib/site/syntax_highlighting.css +30 -0
  42. data/lib/stats_builder.rb +18 -0
  43. data/lib/subversion_extractor.rb +29 -19
  44. data/lib/tasks/continuous4r-project.xml +26 -0
  45. data/lib/tasks/continuous4r.rake +23 -0
  46. data/lib/tasks/continuous4r.rb +6 -0
  47. data/lib/tests_builder.rb +21 -0
  48. data/lib/tests_formatter.rb +13 -46
  49. data/lib/utils.rb +47 -0
  50. data/lib/xdoclet_builder.rb +48 -0
  51. data/lib/zen_test_formatter.rb +58 -28
  52. data/lib/zentest_builder.rb +19 -0
  53. data/script/console +10 -0
  54. data/script/console.cmd +1 -0
  55. data/script/destroy +1 -1
  56. data/script/generate +1 -1
  57. data/test/test_continuous4r.rb +1 -1
  58. data/test/test_helper.rb +1 -0
  59. data/website/index.html +141 -363
  60. data/website/index.txt +169 -228
  61. data/website/template.rhtml +2 -2
  62. metadata +66 -46
  63. data/License.txt +0 -20
  64. data/README.txt +0 -1
  65. data/config/hoe.rb +0 -71
  66. data/config/requirements.rb +0 -17
  67. data/lib/capistrano_formatter.rb +0 -19
  68. data/lib/continuous4r/version.rb +0 -9
  69. data/lib/flog_formatter.rb +0 -48
  70. data/lib/heckle_formatter.rb +0 -27
  71. data/lib/httperf_formatter.rb +0 -160
  72. data/lib/site/body-capistrano.rhtml +0 -8
  73. data/lib/site/body-heckle.rhtml +0 -16
  74. data/lib/site/body-httperf.rhtml +0 -8
  75. data/lib/site/body-kwala.rhtml +0 -35
  76. data/lib/site/body-railroad.rhtml +0 -29
  77. data/lib/site/menu-capistrano.rhtml +0 -23
  78. data/lib/site/menu-changelog.rhtml +0 -23
  79. data/lib/site/menu-flog.rhtml +0 -23
  80. data/lib/site/menu-heckle.rhtml +0 -23
  81. data/lib/site/menu-httperf.rhtml +0 -23
  82. data/lib/site/menu-kwala.rhtml +0 -23
  83. data/lib/site/menu-railroad.rhtml +0 -23
  84. data/lib/site/menu-rcov.rhtml +0 -23
  85. data/lib/site/menu-rdoc.rhtml +0 -23
  86. data/lib/site/menu-stats.rhtml +0 -23
  87. data/lib/site/menu-tests.rhtml +0 -23
  88. data/lib/site/menu-zentest.rhtml +0 -23
  89. data/log/debug.log +0 -0
  90. data/script/txt2html +0 -74
  91. data/script/txt2html.cmd +0 -1
  92. data/setup.rb +0 -1585
  93. data/tasks/deployment.rake +0 -34
  94. data/tasks/environment.rake +0 -7
  95. data/tasks/website.rake +0 -17
data/History.txt CHANGED
@@ -1,4 +1,4 @@
1
- == 0.0.1 2007-12-23
1
+ == 0.0.1 2009-02-03
2
2
 
3
3
  * 1 major enhancement:
4
4
  * Initial release
data/Manifest.txt CHANGED
@@ -1,79 +1,62 @@
1
1
  History.txt
2
- License.txt
3
2
  Manifest.txt
4
- README.txt
3
+ PostInstall.txt
4
+ README.rdoc
5
5
  Rakefile
6
- config/hoe.rb
7
- config/requirements.rb
8
- lib/capistrano_formatter.rb
9
6
  lib/continuous4r.rb
10
- lib/flog_formatter.rb
11
- lib/heckle_formatter.rb
12
- lib/httperf_formatter.rb
13
7
  lib/stats_formatter.rb
8
+ lib/git_extractor.rb
14
9
  lib/subversion_extractor.rb
15
10
  lib/tests_formatter.rb
16
11
  lib/zen_test_formatter.rb
17
- lib/continuous4r/version.rb
18
- lib/site/body-capistrano.rhtml
19
12
  lib/site/body-changelog.rhtml
20
13
  lib/site/body-continuous4r-reports.rhtml
21
14
  lib/site/body-dcov.rhtml
22
15
  lib/site/body-dependencies.rhtml
23
16
  lib/site/body-flog.rhtml
24
- lib/site/body-heckle.rhtml
25
- lib/site/body-httperf.rhtml
17
+ lib/site/body-flay.rhtml
26
18
  lib/site/body-issue-tracking.rhtml
27
- lib/site/body-kwala.rhtml
28
19
  lib/site/body-index.rhtml
29
- lib/site/body-railroad.rhtml
30
20
  lib/site/body-rcov.rhtml
31
21
  lib/site/body-rdoc.rhtml
22
+ lib/site/body-reek.rhtml
23
+ lib/site/body-roodi.rhtml
24
+ lib/site/body-saikuro.rhtml
32
25
  lib/site/body-scm-usage.rhtml
33
26
  lib/site/body-stats.rhtml
34
27
  lib/site/body-team-list.rhtml
35
28
  lib/site/body-tests.rhtml
29
+ lib/site/body-xdoclet.rhtml
36
30
  lib/site/body-zentest.rhtml
31
+ lib/site/flog.html.erb
32
+ lib/site/flog_page.html.erb
37
33
  lib/site/header.rhtml
38
- lib/site/menu-capistrano.rhtml
39
- lib/site/menu-changelog.rhtml
40
34
  lib/site/menu-continuous4r-reports.rhtml
41
- lib/site/menu-dcov.rhtml
42
35
  lib/site/menu-dependencies.rhtml
43
- lib/site/menu-flog.rhtml
44
- lib/site/menu-heckle.rhtml
45
- lib/site/menu-httperf.rhtml
46
36
  lib/site/menu-issue-tracking.rhtml
47
- lib/site/menu-kwala.rhtml
48
37
  lib/site/menu-index.rhtml
49
- lib/site/menu-railroad.rhtml
50
- lib/site/menu-rcov.rhtml
51
- lib/site/menu-rdoc.rhtml
52
38
  lib/site/menu-scm-usage.rhtml
53
- lib/site/menu-stats.rhtml
39
+ lib/site/menu-task.rhtml
54
40
  lib/site/menu-team-list.rhtml
55
- lib/site/menu-tests.rhtml
56
- lib/site/menu-zentest.rhtml
41
+ lib/site/images/added.png
57
42
  lib/site/images/continuous4r-logo.png
43
+ lib/site/images/deleted.png
58
44
  lib/site/images/external.png
59
45
  lib/site/images/icon_error_sml.gif
60
46
  lib/site/images/icon_success_sml.gif
47
+ lib/site/images/modified.png
61
48
  lib/site/images/newwindow.png
62
49
  lib/site/style/commons-maven.css
63
50
  lib/site/style/maven-base.css
64
51
  lib/site/style/maven-theme.css
65
52
  lib/site/style/project.css
66
- log/debug.log
53
+ lib/site/syntax_highlighting.css
54
+ script/console
55
+ script/console.cmd
67
56
  script/destroy
68
57
  script/destroy.cmd
69
58
  script/generate
70
59
  script/generate.cmd
71
- script/txt2html
72
- script/txt2html.cmd
73
- setup.rb
74
- tasks/deployment.rake
75
- tasks/environment.rake
76
- tasks/website.rake
77
60
  test/test_continuous4r.rb
78
61
  test/test_helper.rb
79
62
  website/index.html
@@ -81,3 +64,20 @@ website/index.txt
81
64
  website/javascripts/rounded_corners_lite.inc.js
82
65
  website/stylesheets/screen.css
83
66
  website/template.rhtml
67
+ lib/tasks/continuous4r.rake
68
+ lib/tasks/continuous4r.rb
69
+ lib/tasks/continuous4r-project.xml
70
+ lib/changelog_builder.rb
71
+ lib/dcov_builder.rb
72
+ lib/flay_builder.rb
73
+ lib/flog_builder.rb
74
+ lib/rcov_builder.rb
75
+ lib/rdoc_builder.rb
76
+ lib/reek_builder.rb
77
+ lib/roodi_builder.rb
78
+ lib/saikuro_builder.rb
79
+ lib/stats_builder.rb
80
+ lib/tests_builder.rb
81
+ lib/xdoclet_builder.rb
82
+ lib/zentest_builder.rb
83
+ lib/utils.rb
data/PostInstall.txt ADDED
@@ -0,0 +1,3 @@
1
+
2
+ For more information on continuous4r, see http://continuous4r.rubyforge.org
3
+
data/README.rdoc ADDED
@@ -0,0 +1,58 @@
1
+ = continuous4r
2
+
3
+ * http://continuous4r.rubyforge.org
4
+ * http://github.com/vdubois/continuous4r/tree/master
5
+ * http://collaborateurvdu.wordpress.com
6
+
7
+ == DESCRIPTION:
8
+
9
+ Continuous integration tool which regroups in one place tests, quality and analysis tools in a Maven-like website.
10
+
11
+ == FEATURES/PROBLEMS:
12
+
13
+ * See http://continuous4r.rubyforge.org
14
+
15
+ == SYNOPSIS:
16
+
17
+ cd /path/to/rails/app
18
+ add : require 'continuous4r' to your Rakefile
19
+ 'rake continuous4r:init' to create your continuous4r-project.xml file
20
+ edit continuous4r-project.xml to suit your needs
21
+ Type 'rake continuous4r:build' to build
22
+ then open tmp/continuous4r/index.html in your browser
23
+
24
+ == REQUIREMENTS:
25
+
26
+ * RubyGems
27
+ * rails (erb)
28
+ * hpricot
29
+ * XmlElements
30
+
31
+ == INSTALL:
32
+
33
+ * sudo gem install continuous4r
34
+
35
+ == LICENSE:
36
+
37
+ (The MIT License)
38
+
39
+ Copyright (c) 2009 Vincent Dubois
40
+
41
+ Permission is hereby granted, free of charge, to any person obtaining
42
+ a copy of this software and associated documentation files (the
43
+ 'Software'), to deal in the Software without restriction, including
44
+ without limitation the rights to use, copy, modify, merge, publish,
45
+ distribute, sublicense, and/or sell copies of the Software, and to
46
+ permit persons to whom the Software is furnished to do so, subject to
47
+ the following conditions:
48
+
49
+ The above copyright notice and this permission notice shall be
50
+ included in all copies or substantial portions of the Software.
51
+
52
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
53
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
54
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
55
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
56
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
57
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
58
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1,4 +1,29 @@
1
- require 'config/requirements'
2
- require 'config/hoe' # setup Hoe + all gem configuration
1
+ %w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
2
+ require File.dirname(__FILE__) + '/lib/continuous4r'
3
3
 
4
- Dir['tasks/**/*.rake'].each { |rake| load rake }
4
+ # Generate all the Rake tasks
5
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
6
+ $hoe = Hoe.new('continuous4r', Continuous4r::VERSION) do |p|
7
+ p.developer('Vincent Dubois', 'duboisv@hotmail.com')
8
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
9
+ p.post_install_message = 'PostInstall.txt'
10
+ p.rubyforge_name = p.name
11
+ # p.extra_deps = [
12
+ # ['activesupport','>= 2.0.2'],
13
+ # ]
14
+ p.extra_dev_deps = [
15
+ ['newgem', ">= #{::Newgem::VERSION}"]
16
+ ]
17
+
18
+ p.clean_globs |= %w[**/.DS_Store tmp *.log]
19
+ path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
20
+ p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
21
+ p.rsync_args = '-av --delete --ignore-errors'
22
+ end
23
+
24
+ require 'newgem/tasks' # load /tasks/*.rake
25
+
26
+ Dir['tasks/**/*.rake'].each { |t| load t }
27
+
28
+ # TODO - want other tests/tasks run by default? Add them to the list
29
+ # task :default => [:spec, :features]
@@ -0,0 +1,51 @@
1
+ # ===========================================================================
2
+ # Construction de la tache changelog (changements du referentiel de sources)
3
+ # author: Vincent Dubois
4
+ # date: 18 fevrier 2009
5
+ # ===========================================================================
6
+ class ChangelogBuilder
7
+ include Utils
8
+
9
+ # Implementation de la construction de la tache
10
+ def build(project_name, auto_install, proxy_option)
11
+ unless File.exist?(".svn") or File.exist?(".git")
12
+ puts " Only Subversion and Git are supported. The 'changelog' task will be empty."
13
+ break
14
+ end
15
+ # On verifie l'existence de Subversion
16
+ scm_name = "svn"
17
+ if File.exist?(".git")
18
+ scm_name = "git"
19
+ end
20
+ scm_version = Utils.run_command("#{scm_name} --version")
21
+ if scm_version.blank?
22
+ if scm_name == "svn"
23
+ raise " Subversion don't seem to be installed. Go see Subversion website on http://subversion.tigris.org.\n BUILD FAILED"
24
+ else
25
+ raise " Git don't seem to be installed. Go see Git website on http://git-scm.com/.\n BUILD FAILED"
26
+ end
27
+ end
28
+ # Gestion de la derniere version
29
+ # 1 - On verifie le repertoire home/continuous4r
30
+ ENV['HOME'] = ENV['USERPROFILE'] if Config::CONFIG['host_os'] =~ /mswin/ and ENV['HOME'].nil?
31
+ unless File.exist?(ENV["HOME"] + "/.continuous4r")
32
+ Dir.mkdir(ENV["HOME"] + "/.continuous4r")
33
+ end
34
+ # 2 - On verifie le numero de version
35
+ scm_current_version = "1"
36
+ scm_last_version = 1
37
+ if File.exist?(ENV["HOME"] + "/.continuous4r/#{project_name}_#{scm_name}.version")
38
+ scm_current_version = File.read(ENV["HOME"] + "/.continuous4r/#{project_name}_#{scm_name}.version")
39
+ end
40
+ # 3 - On extrait les informations du referentiel
41
+ if scm_name == "svn"
42
+ scm_last_version = SubversionExtractor.extract_changelog(scm_current_version.to_i, "#{Continuous4r::WORK_DIR}/changelog-body.html")
43
+ elsif scm_name == "git"
44
+ scm_last_version = GitExtractor.extract_changelog(scm_current_version.to_i, "#{Continuous4r::WORK_DIR}/changelog-body.html")
45
+ end
46
+ # 4 - On ecrit le nouveau numero de revision
47
+ rev_file = File.open(ENV["HOME"] + "/.continuous4r/#{project_name}_#{scm_name}.version","w")
48
+ rev_file.write(scm_last_version)
49
+ rev_file.close
50
+ end
51
+ end
data/lib/continuous4r.rb CHANGED
@@ -1,30 +1,41 @@
1
- $:.unshift File.dirname(__FILE__)
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+ require File.join(File.dirname(__FILE__), 'tasks', 'continuous4r')
2
4
 
3
5
  require 'rubygems'
4
6
  require 'XmlElements'
5
7
  require 'date'
6
- require 'capistrano_formatter.rb'
7
- require 'heckle_formatter.rb'
8
- require 'httperf_formatter.rb'
8
+ require 'erb'
9
9
  require 'stats_formatter.rb'
10
10
  require 'tests_formatter.rb'
11
11
  require 'zen_test_formatter.rb'
12
12
  require 'subversion_extractor.rb'
13
+ require 'git_extractor.rb'
14
+ require 'utils.rb'
13
15
 
14
16
  # ==============================================================================
15
- # Classe modelisant un fichier de description de projet Ruby/Rails
17
+ # Classe modelisant un fichier de description de projet Ruby on Rails
16
18
  # Author:: Vincent Dubois
17
- # Date : 03 decembre 2007
19
+ # Date : 03 decembre 2007 - version 0.0.1
20
+ # 03 fevrier 2009 - version 0.0.2
18
21
  # ==============================================================================
19
22
  module Continuous4r
23
+ include Utils
24
+ VERSION = '0.0.2'
20
25
 
21
26
  # Support de CruiseControl.rb
22
- WORK_DIR = "#{ENV['CC_BUILD_ARTIFACTS'].nil? ? "continuous4r_build" : "#{ENV['CC_BUILD_ARTIFACTS']}/continuous4r_build"}"
27
+ WORK_DIR = "#{ENV['CC_BUILD_ARTIFACTS'].nil? ? "tmp/continuous4r" : "#{ENV['CC_BUILD_ARTIFACTS']}/continuous4r"}"
23
28
 
29
+ TASKS = ['dcov','rcov','rdoc','stats','changelog','flog','xdoclet','flay','reek','roodi','saikuro','tests','zentest']
30
+
24
31
  # Methode de generation du site au complet
25
32
  def self.generate_site
33
+ tasks = TASKS
26
34
  project = XmlElements.fromString(File.read("#{RAILS_ROOT}/continuous4r-project.xml"))
27
35
  generation_date = DateTime.now
36
+ auto_install = project['auto-install-tools']
37
+ auto_install ||= "false"
38
+
28
39
  puts "====================================================================="
29
40
  puts " Continuous Integration for Ruby, starting website generation..."
30
41
  puts "---------------------------------------------------------------------"
@@ -32,459 +43,85 @@ module Continuous4r
32
43
  puts " Project URL : #{project.url.text}"
33
44
  puts " Generation date : #{generation_date}"
34
45
  puts "---------------------------------------------------------------------"
35
-
46
+
47
+ # Récupération des paramètres de proxy s'ils existent
48
+ proxy_option = ""
49
+ if File.exist?("#{(Config::CONFIG['host_os'] =~ /mswin/ ? ENV['USERPROFILE'] : ENV['HOME'])}/.continuous4r/proxy.yml")
50
+ require 'YAML'
51
+ proxy_options = YAML.load_file("#{(Config::CONFIG['host_os'] =~ /mswin/ ? ENV['USERPROFILE'] : ENV['HOME'])}/.continuous4r/proxy.yml")
52
+ proxy_option = " -p \"http://#{proxy_options['proxy']['login']}:#{proxy_options['proxy']['password']}@#{proxy_options['proxy']['server']}:#{proxy_options['proxy']['port']}\""
53
+ end
54
+
36
55
  # Vérification de présence et de la version de Rubygems
37
56
  puts " Checking presence and version of RubyGems..."
38
- rubygems_version = `gem --version`
57
+ rubygems_version = Utils.run_command("gem --version")
39
58
  if rubygems_version.empty?
40
59
  raise " You don't seem to have RubyGems installed, please go first to http://rubygems.rubyforge.org"
41
60
  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
-
61
+
50
62
  # 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
-
63
+ Utils.verify_gem_presence("hpricot", auto_install, proxy_option)
64
+
60
65
  # Chargement/Vérification des gems nécessaires à l'application
61
66
  puts " Checking gems for this project, please hold on..."
62
67
  project.gems.each('gem') do |gem|
63
68
  puts " Checking for #{gem['name']} gem, version #{gem['version']}..."
64
- gem_version = `gem list|grep #{gem['name']}`
69
+ gem_version = Utils.run_command("gem list #{gem['name']}")
65
70
  if gem_version.empty? or gem_version.index("#{gem['version']}").nil?
66
- gem_installed = `gem install #{gem['name']} --version #{gem['version']} 2>&1`
71
+ if project['auto-install-gems'] == "false"
72
+ raise " The #{gem['name']} gem with version #{gem['version']} is needed. Please run '#{"sudo " unless Config::CONFIG['host_os'] =~ /mswin/}gem install #{gem['name']} --version #{gem['version']}' to install it.\n BUILD FAILED."
73
+ end
74
+ gem_installed = Utils.run_command("#{"sudo " unless Config::CONFIG['host_os'] =~ /mswin/}gem install #{gem['name']} --version #{gem['version']}#{proxy_option} 2>&1")
67
75
  if !gem_installed.index("ERROR").nil?
68
76
  raise " Unable to install #{gem['name']} gem with version #{gem['version']}.\n BUILD FAILED."
69
77
  end
70
78
  end
71
79
  end
72
-
80
+
73
81
  puts "---------------------------------------------------------------------"
74
82
  # Création du répertoire de travail
75
- if File.exist? "#{WORK_DIR}"
76
- `rm -Rf #{WORK_DIR}`
83
+ if File.exist?(WORK_DIR)
84
+ FileUtils.rm_rf(WORK_DIR)
77
85
  end
78
- Dir.mkdir "#{WORK_DIR}"
79
-
80
- auto_install = project.tasks['autoinstall']
81
- auto_install ||= "false"
82
-
86
+ Dir.mkdir WORK_DIR
87
+
83
88
  # 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
89
+ tasks.each do |task|
90
+ self.build_task task, project['name'], auto_install, proxy_option
91
+ puts "\n---------------------------------------------------------------------"
96
92
  end
93
+ puts " All tasks done."
97
94
  puts "\n---------------------------------------------------------------------"
98
95
  # On copie les feuilles de styles
99
- `cp -R #{File.dirname(__FILE__)}/site/style/ #{WORK_DIR}/`
96
+ FileUtils.cp_r("#{File.dirname(__FILE__)}/site/style/", "#{WORK_DIR}/")
100
97
  # 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}/`
98
+ FileUtils.cp_r("#{File.dirname(__FILE__)}/site/images/", "#{WORK_DIR}/")
99
+ FileUtils.copy_file("#{File.dirname(__FILE__)}/site/images/continuous4r-logo.png", "#{WORK_DIR}/continuous4r-logo.png")
103
100
  puts " Building project information page..."
104
- eruby_run "index"
101
+ Utils.erb_run "index", false
105
102
  puts " Building team list page..."
106
- eruby_run "team-list"
103
+ Utils.erb_run "team-list", false
107
104
  puts " Building project dependencies page..."
108
- eruby_run "dependencies"
105
+ Utils.erb_run "dependencies", false
109
106
  puts " Building source control management page..."
110
- eruby_run "scm-usage"
107
+ Utils.erb_run "scm-usage", false
111
108
  puts " Building issue tracking page..."
112
- eruby_run "issue-tracking"
109
+ Utils.erb_run "issue-tracking", false
113
110
  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
111
+ Utils.erb_run "continuous4r-reports", false
112
+ tasks.each do |task|
113
+ puts " Building #{task} page..."
114
+ Utils.erb_run task, true
124
115
  end
125
116
  puts "\n BUILD SUCCESSFUL."
126
117
  puts "====================================================================="
127
118
  end
128
-
119
+
129
120
  # 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
121
+ def self.build_task task, project_name, auto_install, proxy_option
122
+ require "#{task}_builder.rb"
123
+ task_class = Object.const_get("#{task.capitalize}Builder")
124
+ task_builder = task_class.new
125
+ task_builder.build(project_name, auto_install, proxy_option)
489
126
  end
490
127
  end