forked from computerlyrik/chef-caddy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
78 lines (65 loc) · 1.97 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
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'foodcritic'
require 'kitchen'
require 'emeril/rake_tasks'
desc 'Cleans the workspace and the bundle dir !!!!, bundle install required afterwards.'
task :clean do
rm_rf %w(.bundle build berks-cookbooks Berksfile.lock .kitchen .vagrant .rakeTasks)
end
desc 'Run all style checks'
task style: ['style:chef', 'style:ruby']
desc 'Run all tests'
task test: ['test:unit', 'test:kitchen']
desc 'Regenerate README.md'
task :doc do
`bundle exec knife cookbook doc .`
end
desc 'Run all regular tasks'
task default: %w(style test)
namespace :style do
desc 'Run Ruby style checks'
RuboCop::RakeTask.new(:ruby) do |task|
task.patterns = ['**/*.rb']
# don't abort rake on failure
task.fail_on_error = false
end
desc 'Run Chef style checks'
FoodCritic::Rake::LintTask.new(:chef) do |t|
t.options = {
tags: %w(~FC015 ~FC009 ~FC021 ~FC064),
fail_tags: ['correctness']
}
end
end
namespace :test do
desc 'Run Test Kitchen with Vagrant'
task :kitchen do
Kitchen.logger = Kitchen.default_file_logger
Kitchen::Config.new.instances.each do |instance|
instance.test(:always)
end
end
desc 'Runs specs with chefspec.'
RSpec::Core::RakeTask.new(:unit, [:recipe, :output_file]) do |t, args|
args.with_defaults(recipe: '*', output_file: nil)
t.verbose = false
t.fail_on_error = false
t.rspec_opts = '--color --format progress --format RspecJunitFormatter --out build/chefspec-reports.xml'
t.ruby_opts = '-W0' # it supports ruby options too
t.pattern = "spec/#{args.recipe}_spec.rb"
end
end
desc 'Releases Cookbook'
Emeril::RakeTasks.new do |t|
# turn on debug logging
t.config[:logger].level = :debug
# set a category for this cookbook
t.config[:category] = 'Applications'
# currently we don't have a supermarket
t.config[:publish_to_supermarket] = false
end
desc 'share cookbook to supermarket'
task :share do
`knife supermarket share caddy`
end