forked from activewarehouse/activewarehouse
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Rakefile
64 lines (55 loc) · 1.9 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
require 'bundler'
Bundler::GemHelper.install_tasks
require 'rake'
require 'rake/testtask'
require "rspec/core/rake_task"
desc 'Default: run tests and specs.'
task :default => [:test, :spec]
desc 'Test the active_warehouse plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc "Run all specs"
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = 'spec/**/*_spec.rb'
spec.rspec_opts = ['--backtrace']
# unless ENV['NO_RCOV']
# spec.rcov = true
# spec.rcov_dir = '../doc/output/coverage'
# spec.rcov_opts = ['--exclude', 'spec\/spec,bin\/spec,examples,\/var\/lib\/gems,\/Library\/Ruby,\.autotest']
# end
end
def system!(cmd)
puts cmd
raise "Command failed!" unless system(cmd)
end
require 'tasks/standalone_migrations'
# experimental tasks to reproduce the Travis behaviour locally
namespace :ci do
desc "For current RVM, run the tests for one db and one gemfile"
task :run_one, :db, :gemfile do |t, args|
ENV['BUNDLE_GEMFILE'] = File.expand_path(args[:gemfile] || (File.dirname(__FILE__) + '/test/config/gemfiles/Gemfile.rails-3.2.x'))
ENV['DB'] = args[:db] || 'mysql'
system! "bundle install"
system! "bundle exec rake db:create"
system! "bundle exec rake db:create RAILS_ENV=etl_execution"
system! "bundle exec rake db:migrate"
system! "bundle exec rake"
end
desc "For current RVM, run the tests for all the combination in travis configuration"
task :run_matrix do
require 'cartesian'
config = YAML.load_file('.travis.yml')
config['env'].cartesian(config['gemfile']).each do |*x|
env, gemfile = *x.flatten
db = env.gsub('DB=', '')
print [db, gemfile].inspect.ljust(40) + ": "
cmd = "rake \"ci:run_one[#{db},#{gemfile}]\""
result = system "#{cmd} > /dev/null 2>&1"
result = result ? "OK" : "FAILED! - re-run with: #{cmd}"
puts result
end
end
end