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 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. desc "Run the Continuous 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 "Display info about the build environment"
  12. task :about do
  13. puts "Ruby version: #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
  14. end
  15. desc "Setup Redmine for a new build"
  16. task :setup do
  17. Rake::Task["tmp:clear"].invoke
  18. Rake::Task["log:clear"].invoke
  19. Rake::Task["db:create:all"].invoke
  20. Rake::Task["db:migrate"].invoke
  21. Rake::Task["db:schema:dump"].invoke
  22. if scms = ENV['SCMS']
  23. scms.split(',').each do |scm|
  24. Rake::Task["test:scm:setup:#{scm}"].invoke
  25. end
  26. else
  27. Rake::Task["test:scm:setup:all"].invoke
  28. end
  29. Rake::Task["test:scm:update"].invoke
  30. end
  31. desc "Build Redmine"
  32. task :build do
  33. if test_suite = ENV['TEST_SUITE']
  34. Rake::Task["test:#{test_suite}"].invoke
  35. else
  36. Rake::Task["test"].invoke
  37. end
  38. # Rake::Task["test:ui"].invoke
  39. end
  40. desc "Finish the build"
  41. task :teardown do
  42. end
  43. end
  44. desc "Creates database.yml for the CI server"
  45. file 'config/database.yml' do
  46. require 'yaml'
  47. database = ENV['DATABASE_ADAPTER']
  48. ruby = ENV['RUBY_VER'].gsub('.', '').gsub('-', '')
  49. branch = ENV['BRANCH'].gsub('.', '').gsub('-', '')
  50. dev_db_name = "ci_#{branch}_#{ruby}_dev"
  51. test_db_name = "ci_#{branch}_#{ruby}_test"
  52. case database
  53. when /(mysql|mariadb)/
  54. dev_conf = {'adapter' => 'mysql2',
  55. 'database' => dev_db_name, 'host' => 'localhost',
  56. 'encoding' => 'utf8'}
  57. if ENV['RUN_ON_NOT_OFFICIAL']
  58. dev_conf['username'] = 'root'
  59. else
  60. dev_conf['username'] = 'jenkins'
  61. dev_conf['password'] = 'jenkins'
  62. end
  63. test_conf = dev_conf.merge('database' => test_db_name)
  64. when /postgresql/
  65. dev_conf = {'adapter' => 'postgresql', 'database' => dev_db_name,
  66. 'host' => 'localhost'}
  67. if ENV['RUN_ON_NOT_OFFICIAL']
  68. dev_conf['username'] = 'postgres'
  69. else
  70. dev_conf['username'] = 'jenkins'
  71. dev_conf['password'] = 'jenkins'
  72. end
  73. test_conf = dev_conf.merge('database' => test_db_name)
  74. when /sqlite3/
  75. dev_conf = {'adapter' => (Object.const_defined?(:JRUBY_VERSION) ?
  76. 'jdbcsqlite3' : 'sqlite3'),
  77. 'database' => "db/#{dev_db_name}.sqlite3"}
  78. test_conf = dev_conf.merge('database' => "db/#{test_db_name}.sqlite3")
  79. when 'sqlserver'
  80. dev_conf = {'adapter' => 'sqlserver', 'database' => dev_db_name,
  81. 'host' => 'mssqlserver', 'port' => 1433,
  82. 'username' => 'jenkins', 'password' => 'jenkins'}
  83. test_conf = dev_conf.merge('database' => test_db_name)
  84. else
  85. abort "Unknown database"
  86. end
  87. File.open('config/database.yml', 'w') do |f|
  88. f.write YAML.dump({'development' => dev_conf, 'test' => test_conf})
  89. end
  90. end