@@ -1,81 +1,61 | |||
|
1 | 1 | desc "Run the Continous Integration tests for Redmine" |
|
2 | 2 | task :ci do |
|
3 | 3 | # RAILS_ENV and ENV[] can diverge so force them both to test |
|
4 | 4 | ENV['RAILS_ENV'] = 'test' |
|
5 | 5 | RAILS_ENV = 'test' |
|
6 | 6 | Rake::Task["ci:setup"].invoke |
|
7 | 7 | Rake::Task["ci:build"].invoke |
|
8 | 8 | Rake::Task["ci:teardown"].invoke |
|
9 | 9 | end |
|
10 | 10 | |
|
11 | # Tasks can be hooked into by redefining them in a plugin | |
|
12 | 11 | namespace :ci do |
|
13 |
desc "Setup Redmine for a new build |
|
|
12 | desc "Setup Redmine for a new build" | |
|
14 | 13 | task :setup do |
|
15 |
Rake::Task[" |
|
|
14 | Rake::Task["log:clear"].invoke | |
|
16 | 15 | Rake::Task["db:create"].invoke |
|
17 | 16 | Rake::Task["db:migrate"].invoke |
|
18 | 17 | Rake::Task["db:schema:dump"].invoke |
|
18 | Rake::Task["test:scm:setup:all"].invoke | |
|
19 | 19 | Rake::Task["test:scm:update"].invoke |
|
20 | 20 | end |
|
21 | 21 | |
|
22 | 22 | desc "Build Redmine" |
|
23 | 23 | task :build do |
|
24 | 24 | Rake::Task["test"].invoke |
|
25 | 25 | end |
|
26 | 26 | |
|
27 | # Use this to cleanup after building or run post-build analysis. | |
|
28 | 27 | desc "Finish the build" |
|
29 | 28 | task :teardown do |
|
30 | 29 | end |
|
30 | end | |
|
31 | 31 | |
|
32 |
|
|
|
33 | task :database do | |
|
34 | path = 'config/database.yml' | |
|
35 | unless File.exists?(path) | |
|
32 | desc "Creates database.yml for the CI server" | |
|
33 | file 'config/database.yml' do | |
|
34 | require 'yaml' | |
|
36 | 35 |
|
|
37 | 36 |
|
|
38 | 37 |
|
|
39 | 38 |
|
|
40 | 39 |
|
|
41 | 40 | |
|
42 | 41 |
|
|
43 | 42 |
|
|
44 | raise "Error creating databases" unless | |
|
45 | system(%|mysql -u jenkins --password=jenkins -e 'create database #{dev_db_name} character set utf8;'|) && | |
|
46 | system(%|mysql -u jenkins --password=jenkins -e 'create database #{test_db_name} character set utf8;'|) | |
|
47 | 43 |
|
|
48 | test_conf = { 'adapter' => (RUBY_VERSION >= '1.9' ? 'mysql2' : 'mysql'), 'database' => test_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins', 'encoding' => 'utf8' } | |
|
44 | test_conf = dev_conf.merge('database' => test_db_name) | |
|
49 | 45 |
|
|
50 | raise "Error creating databases" unless | |
|
51 | system(%|psql -U jenkins -d postgres -c "create database #{dev_db_name} owner jenkins encoding 'UTF8';"|) && | |
|
52 | system(%|psql -U jenkins -d postgres -c "create database #{test_db_name} owner jenkins encoding 'UTF8';"|) | |
|
53 | 46 |
|
|
54 | test_conf = { 'adapter' => 'postgresql', 'database' => test_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins' } | |
|
47 | test_conf = dev_conf.merge('database' => test_db_name) | |
|
55 | 48 |
|
|
56 | 49 |
|
|
57 |
|
|
|
50 | test_conf = dev_conf.merge('database' => "db/#{test_db_name}.sqlite3") | |
|
58 | 51 |
|
|
59 | 52 |
|
|
60 | test_conf = { 'adapter' => 'sqlserver', 'database' => test_db_name, 'host' => 'mssqlserver', 'port' => 1433, 'username' => 'jenkins', 'password' => 'jenkins' } | |
|
53 | test_conf = dev_conf.merge('database' => test_db_name) | |
|
61 | 54 |
|
|
62 |
|
|
|
55 | abort "Unknown database" | |
|
63 | 56 |
|
|
64 | 57 | |
|
65 |
|
|
|
58 | File.open('config/database.yml', 'w') do |f| | |
|
66 | 59 |
|
|
67 | 60 |
|
|
68 | 61 |
|
|
69 | end | |
|
70 | ||
|
71 | desc "Dump the environment information to a BUILD_ENVIRONMENT ENV variable for debugging" | |
|
72 | task :dump_environment do | |
|
73 | ||
|
74 | ENV['BUILD_ENVIRONMENT'] = ['ruby -v', 'gem -v', 'gem list'].collect do |command| | |
|
75 | result = `#{command}` | |
|
76 | "$ #{command}\n#{result}" | |
|
77 | end.join("\n") | |
|
78 | ||
|
79 | end | |
|
80 | end | |
|
81 |
@@ -1,110 +1,111 | |||
|
1 | 1 | ### From http://svn.geekdaily.org/public/rails/plugins/generally_useful/tasks/coverage_via_rcov.rake |
|
2 | 2 | |
|
3 | 3 | namespace :test do |
|
4 | 4 | desc 'Measures test coverage' |
|
5 | 5 | task :coverage do |
|
6 | 6 | rm_f "coverage" |
|
7 | 7 | rm_f "coverage.data" |
|
8 | 8 | rcov = "rcov --rails --aggregate coverage.data --text-summary -Ilib --html --exclude gems/" |
|
9 | 9 | files = %w(unit functional integration).map {|dir| Dir.glob("test/#{dir}/**/*_test.rb")}.flatten.join(" ") |
|
10 | 10 | system("#{rcov} #{files}") |
|
11 | 11 | end |
|
12 | 12 | |
|
13 | 13 | desc 'Run unit and functional scm tests' |
|
14 | 14 | task :scm do |
|
15 | 15 | errors = %w(test:scm:units test:scm:functionals).collect do |task| |
|
16 | 16 | begin |
|
17 | 17 | Rake::Task[task].invoke |
|
18 | 18 | nil |
|
19 | 19 | rescue => e |
|
20 | 20 | task |
|
21 | 21 | end |
|
22 | 22 | end.compact |
|
23 | 23 | abort "Errors running #{errors.to_sentence(:locale => :en)}!" if errors.any? |
|
24 | 24 | end |
|
25 | 25 | |
|
26 | 26 | namespace :scm do |
|
27 | 27 | namespace :setup do |
|
28 | 28 | desc "Creates directory for test repositories" |
|
29 | 29 | task :create_dir do |
|
30 | 30 | FileUtils.mkdir_p Rails.root + '/tmp/test' |
|
31 | 31 | end |
|
32 | 32 | |
|
33 | 33 | supported_scms = [:subversion, :cvs, :bazaar, :mercurial, :git, :darcs, :filesystem] |
|
34 | 34 | |
|
35 | 35 | desc "Creates a test subversion repository" |
|
36 | 36 | task :subversion => :create_dir do |
|
37 | 37 | repo_path = "tmp/test/subversion_repository" |
|
38 | 38 | unless File.exists?(repo_path) |
|
39 | 39 | system "svnadmin create #{repo_path}" |
|
40 | 40 | system "gunzip < test/fixtures/repositories/subversion_repository.dump.gz | svnadmin load #{repo_path}" |
|
41 | 41 | end |
|
42 | 42 | end |
|
43 | 43 | |
|
44 | 44 | desc "Creates a test mercurial repository" |
|
45 | 45 | task :mercurial => :create_dir do |
|
46 | 46 | repo_path = "tmp/test/mercurial_repository" |
|
47 | 47 | unless File.exists?(repo_path) |
|
48 | 48 | bundle_path = "test/fixtures/repositories/mercurial_repository.hg" |
|
49 | 49 | system "hg init #{repo_path}" |
|
50 | 50 | system "hg -R #{repo_path} pull #{bundle_path}" |
|
51 | 51 | end |
|
52 | 52 | end |
|
53 | 53 | |
|
54 | 54 | (supported_scms - [:subversion, :mercurial]).each do |scm| |
|
55 | 55 | desc "Creates a test #{scm} repository" |
|
56 | 56 | task scm => :create_dir do |
|
57 | 57 | unless File.exists?("tmp/test/#{scm}_repository") |
|
58 | 58 | # system "gunzip < test/fixtures/repositories/#{scm}_repository.tar.gz | tar -xv -C tmp/test" |
|
59 | 59 | system "tar -xvz -C tmp/test -f test/fixtures/repositories/#{scm}_repository.tar.gz" |
|
60 | 60 | end |
|
61 | 61 | end |
|
62 | 62 | end |
|
63 | 63 | |
|
64 | 64 | desc "Creates all test repositories" |
|
65 | 65 | task :all => supported_scms |
|
66 | 66 | end |
|
67 | 67 | |
|
68 | 68 | desc "Updates installed test repositories" |
|
69 | 69 | task :update do |
|
70 | 70 | require 'fileutils' |
|
71 | 71 | Dir.glob("tmp/test/*_repository").each do |dir| |
|
72 | 72 | next unless File.basename(dir) =~ %r{^(.+)_repository$} && File.directory?(dir) |
|
73 | 73 | scm = $1 |
|
74 | 74 | next unless fixture = Dir.glob("test/fixtures/repositories/#{scm}_repository.*").first |
|
75 | 75 | next if File.stat(dir).ctime > File.stat(fixture).mtime |
|
76 | 76 | |
|
77 | 77 | FileUtils.rm_rf dir |
|
78 | 78 | Rake::Task["test:scm:setup:#{scm}"].execute |
|
79 | 79 | end |
|
80 | 80 | end |
|
81 | 81 | |
|
82 | 82 | Rake::TestTask.new(:units => "db:test:prepare") do |t| |
|
83 | 83 | t.libs << "test" |
|
84 | 84 | t.verbose = true |
|
85 | 85 | t.test_files = FileList['test/unit/repository*_test.rb'] + FileList['test/unit/lib/redmine/scm/**/*_test.rb'] |
|
86 | 86 | end |
|
87 | 87 | Rake::Task['test:scm:units'].comment = "Run the scm unit tests" |
|
88 | 88 | |
|
89 | 89 | Rake::TestTask.new(:functionals => "db:test:prepare") do |t| |
|
90 | 90 | t.libs << "test" |
|
91 | 91 | t.verbose = true |
|
92 | 92 | t.test_files = FileList['test/functional/repositories*_test.rb'] |
|
93 | 93 | end |
|
94 | 94 | Rake::Task['test:scm:functionals'].comment = "Run the scm functional tests" |
|
95 | 95 | end |
|
96 | 96 | |
|
97 | 97 | Rake::TestTask.new(:rdm_routing) do |t| |
|
98 | 98 | t.libs << "test" |
|
99 | 99 | t.verbose = true |
|
100 | 100 | t.test_files = FileList['test/integration/routing/*_test.rb'] |
|
101 | 101 | end |
|
102 | 102 | Rake::Task['test:rdm_routing'].comment = "Run the routing tests" |
|
103 | 103 | |
|
104 | 104 | Rake::TestTask.new(:ui => "db:test:prepare") do |t| |
|
105 | abort "ruby1.9 is required to run test:ui" if RUBY_VERSION < '1.9' | |
|
105 | 106 | t.libs << "test" |
|
106 | 107 | t.verbose = true |
|
107 | 108 | t.test_files = FileList['test/ui/**/*_test.rb'] |
|
108 | 109 | end |
|
109 | 110 | Rake::Task['test:ui'].comment = "Run the UI tests with Capybara (PhantomJS listening on port 4444 is required)" |
|
110 | 111 | end |
General Comments 0
You need to be logged in to leave comments.
Login now