You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ci.rake 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. desc "Run the Continous Integration tests for Redmine"
  2. task :ci do
  3. # RAILS_ENV and ENV[] can diverge so force them both to test
  4. ENV['RAILS_ENV'] = 'test'
  5. RAILS_ENV = 'test'
  6. Rake::Task["ci:setup"].invoke
  7. Rake::Task["ci:build"].invoke
  8. Rake::Task["ci:teardown"].invoke
  9. end
  10. namespace :ci do
  11. desc "Setup Redmine for a new build"
  12. task :setup do
  13. Rake::Task["tmp:clear"].invoke
  14. Rake::Task["log:clear"].invoke
  15. Rake::Task["db:create:all"].invoke
  16. Rake::Task["db:migrate"].invoke
  17. Rake::Task["db:schema:dump"].invoke
  18. Rake::Task["test:scm:setup:all"].invoke
  19. Rake::Task["test:scm:update"].invoke
  20. end
  21. desc "Build Redmine"
  22. task :build do
  23. Rake::Task["test"].invoke
  24. # Rake::Task["test:ui"].invoke if RUBY_VERSION >= '1.9.3'
  25. end
  26. desc "Finish the build"
  27. task :teardown do
  28. end
  29. end
  30. desc "Creates database.yml for the CI server"
  31. file 'config/database.yml' do
  32. require 'yaml'
  33. database = ENV['DATABASE_ADAPTER']
  34. ruby = ENV['RUBY_VER'].gsub('.', '').gsub('-', '')
  35. branch = ENV['BRANCH'].gsub('.', '').gsub('-', '')
  36. dev_db_name = "ci_#{branch}_#{ruby}_dev"
  37. test_db_name = "ci_#{branch}_#{ruby}_test"
  38. case database
  39. when 'mysql'
  40. dev_conf = {'adapter' => (RUBY_VERSION >= '1.9' ? 'mysql2' : 'mysql'), 'database' => dev_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins', 'encoding' => 'utf8'}
  41. test_conf = dev_conf.merge('database' => test_db_name)
  42. when 'postgresql'
  43. dev_conf = {'adapter' => 'postgresql', 'database' => dev_db_name, 'host' => 'localhost', 'username' => 'jenkins', 'password' => 'jenkins'}
  44. test_conf = dev_conf.merge('database' => test_db_name)
  45. when 'sqlite3'
  46. dev_conf = {'adapter' => 'sqlite3', 'database' => "db/#{dev_db_name}.sqlite3"}
  47. test_conf = dev_conf.merge('database' => "db/#{test_db_name}.sqlite3")
  48. when 'sqlserver'
  49. dev_conf = {'adapter' => 'sqlserver', 'database' => dev_db_name, 'host' => 'mssqlserver', 'port' => 1433, 'username' => 'jenkins', 'password' => 'jenkins'}
  50. test_conf = dev_conf.merge('database' => test_db_name)
  51. else
  52. abort "Unknown database"
  53. end
  54. File.open('config/database.yml', 'w') do |f|
  55. f.write YAML.dump({'development' => dev_conf, 'test' => test_conf})
  56. end
  57. end