forked from gooddata/gooddata-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
111 lines (87 loc) · 2.39 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# encoding: UTF-8
require 'rubygems'
require 'bundler/setup'
require 'bundler/gem_tasks'
require 'coveralls/rake/task'
require 'rake/testtask'
require 'rake/notes/rake_task'
require 'rspec/core/rake_task'
require 'yard'
desc "Run Rubocop"
task :cop do
exec "rubocop lib/"
end
Coveralls::RakeTask.new
desc 'Run continuous integration test'
task :ci do
Rake::Task['test:unit'].invoke
unless ENV['TRAVIS'] == 'true' && ENV['TRAVIS_SECURE_ENV_VARS'] == 'false'
Rake::Task['test:integration'].invoke
end
Rake::Task['test:cop'].invoke if RUBY_VERSION.start_with?('2.2') == false
Rake::Task['coveralls:push'].invoke
end
namespace :hook do
hook_path = File.join(File.dirname(__FILE__), '.git', 'hooks', 'pre-commit').to_s
desc 'Installs git pre-commit hook running rubocop'
task :install do |t|
if(File.exist?(hook_path))
puts 'Git pre-commit hook is already installed'
else
File.open(hook_path, 'w') do |file|
file.write("#! /usr/bin/env bash\n")
file.write("\n")
file.write("rake cop\n")
end
system "chmod 755 #{hook_path}"
puts 'Git commit hook was installed'
end
end
desc 'Uninstalls git pre-commit hook'
task :uninstall do |t|
res = File.exist?(hook_path)
if res
puts 'Uninstalling git pre-commit hook'
system "rm #{hook_path}"
puts 'Git pre-commit hook was uninstalled'
else
puts 'Git pre-commit hook is not installed'
end
end
desc 'Checks if is git pre-commit hook installed'
task :check do
res = File.exist?(hook_path)
if res
puts 'Git pre-commit IS installed'
else
puts 'Git pre-commit IS NOT installed'
end
end
end
RSpec::Core::RakeTask.new(:test)
namespace :test do
desc "Run unit tests"
RSpec::Core::RakeTask.new(:unit) do |t|
t.pattern = 'spec/unit/**/*.rb'
end
desc "Run integration tests"
RSpec::Core::RakeTask.new(:integration) do |t|
t.pattern = 'spec/integration/**/*.rb'
end
desc "Run legacy tests"
RSpec::Core::RakeTask.new(:legacy) do |t|
t.pattern = 'test/**/test_*.rb'
end
desc "Run coding style tests"
RSpec::Core::RakeTask.new(:cop) do |t|
Rake::Task['cop'].invoke
end
task :all => [:unit, :integration, :cop]
end
desc "Run all tests"
task :test => 'test:all'
task :usage do
puts "No rake task specified, use rake -T to list them"
end
YARD::Rake::YardocTask.new
task :default => [:usage]