|
| 1 | +require 'pathname' |
| 2 | + |
| 3 | +subprojects = %w| elasticsearch-model elasticsearch-rails | |
| 4 | +__current__ = Pathname( File.expand_path('..', __FILE__) ) |
| 5 | + |
| 6 | +task :default do |
| 7 | + system "rake --tasks" |
| 8 | +end |
| 9 | + |
| 10 | +desc "List all subprojects" |
| 11 | +task :subprojects do |
| 12 | + puts '-'*80 |
| 13 | + subprojects.each do |project| |
| 14 | + commit = `git log --pretty=format:'%h %ar: %s' -1 #{project}` |
| 15 | + version = Gem::Specification::load(__current__.join(project, "#{project}.gemspec").to_s).version.to_s |
| 16 | + puts "[#{version}] \e[1m#{project.ljust(subprojects.map {|s| s.length}.max)}\e[0m | #{commit[ 0..80]}..." |
| 17 | + end |
| 18 | +end |
| 19 | + |
| 20 | +namespace :test do |
| 21 | + desc "Run `bundle install` in all subprojects" |
| 22 | + task :bundle do |
| 23 | + subprojects.each do |project| |
| 24 | + sh "bundle install --gemfile #{__current__.join(project)}/Gemfile" |
| 25 | + puts '-'*80 |
| 26 | + end |
| 27 | + end |
| 28 | + |
| 29 | + desc "Run unit tests in all subprojects" |
| 30 | + task :unit do |
| 31 | + Rake::Task['test:ci_reporter'].invoke if ENV['CI'] |
| 32 | + subprojects.each do |project| |
| 33 | + sh "cd #{__current__.join(project)} && unset BUNDLE_GEMFILE && bundle exec rake test:unit" |
| 34 | + puts '-'*80 |
| 35 | + end |
| 36 | + Rake::Task['test:coveralls'].invoke if ENV['CI'] && defined?(RUBY_VERSION) && RUBY_VERSION > '1.9' |
| 37 | + end |
| 38 | + |
| 39 | + desc "Run integration tests in all subprojects" |
| 40 | + task :integration do |
| 41 | + Rake::Task['test:ci_reporter'].invoke if ENV['CI'] |
| 42 | + subprojects.each do |project| |
| 43 | + sh "cd #{__current__.join(project)} && unset BUNDLE_GEMFILE && bundle exec rake test:integration" |
| 44 | + puts '-'*80 |
| 45 | + end |
| 46 | + Rake::Task['test:coveralls'].invoke if ENV['CI'] && defined?(RUBY_VERSION) && RUBY_VERSION > '1.9' |
| 47 | + end |
| 48 | + |
| 49 | + desc "Run all tests in all subprojects" |
| 50 | + task :all do |
| 51 | + Rake::Task['test:ci_reporter'].invoke if ENV['CI'] |
| 52 | + subprojects.each do |project| |
| 53 | + sh "cd #{__current__.join(project)} && unset BUNDLE_GEMFILE && bundle exec rake test:all" |
| 54 | + puts '-'*80 |
| 55 | + end |
| 56 | + end |
| 57 | + |
| 58 | + task :coveralls do |
| 59 | + require 'coveralls/rake/task' |
| 60 | + Coveralls::RakeTask.new |
| 61 | + Rake::Task['coveralls:push'].invoke |
| 62 | + end |
| 63 | + |
| 64 | + task :ci_reporter do |
| 65 | + ENV['CI_REPORTS'] ||= 'tmp/reports' |
| 66 | + if defined?(RUBY_VERSION) && RUBY_VERSION < '1.9' |
| 67 | + require 'ci/reporter/rake/test_unit' |
| 68 | + Rake::Task['ci:setup:testunit'].invoke |
| 69 | + else |
| 70 | + require 'ci/reporter/rake/minitest' |
| 71 | + Rake::Task['ci:setup:minitest'].invoke |
| 72 | + end |
| 73 | + end |
| 74 | +end |
| 75 | + |
| 76 | +desc "Generate documentation for all subprojects" |
| 77 | +task :doc do |
| 78 | + subprojects.each do |project| |
| 79 | + sh "cd #{__current__.join(project)} && rake doc" |
| 80 | + puts '-'*80 |
| 81 | + end |
| 82 | +end |
| 83 | + |
| 84 | +desc "Release all subprojects to Rubygems" |
| 85 | +task :release do |
| 86 | + subprojects.each do |project| |
| 87 | + sh "cd #{__current__.join(project)} && rake release" |
| 88 | + puts '-'*80 |
| 89 | + end |
| 90 | +end |
0 commit comments