forked from PagerDuty/chef-sumologic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
63 lines (53 loc) · 1.47 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
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'foodcritic'
desc 'Run all linters on the codebase'
task :linters do
Rake::Task['foodcritic'].invoke
Rake::Task['rubocop'].invoke
end
desc "Run spec tests on the codebase"
task :spec do
Rake::Task['spec'].invoke
end
desc 'Run all test kitchen combinations on the codebase'
task :kitchen do
Rake::Task['berkshelf'].invoke
Rake::Task['kitchen:all'].invoke
end
desc 'Run foodcritic on all cookbooks'
FoodCritic::Rake::LintTask.new do |t|
t.options = {
fail_tags: ['any'],
tags: ['~solo', '~readme', '~FC023']
}
end
desc 'rubocop compliancy checks'
RuboCop::RakeTask.new(:rubocop) do |t|
t.patterns = %w{ */*.rb }
t.fail_on_error = true
end
desc 'Run sepc tests'
RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = "--profile"
t.pattern = %w{ spec/*.rb }
t.fail_on_error = true
end
desc 'Install berkshelf cookbooks locally'
task :berkshelf do |t, args|
require 'berkshelf'
require 'berkshelf/berksfile'
current_dir = File.expand_path('../', __FILE__)
berksfile_path = File.join(current_dir, 'Berksfile')
cookbooks_path = File.join(current_dir, 'cookbooks')
berksfile = Berkshelf::Berksfile.from_file(berksfile_path)
FileUtils.rm_rf(cookbooks_path)
berksfile.vendor(cookbooks_path)
end
begin
require 'kitchen/rake_tasks'
Kitchen::RakeTasks.new
rescue LoadError
puts '>>>>> Kitchen gem not loaded, omitting tasks' unless ENV['CI']
end
task default: [:foodcritic, :rubocop, :spec]