-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
76 lines (63 loc) · 2.03 KB
/
Rakefile
File metadata and controls
76 lines (63 loc) · 2.03 KB
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
# frozen_string_literal: true
require 'rspec/core/rake_task'
# syntax/lint checks: RuboCop & Foodcritic
namespace :lint do # rubocop:disable Metrics/BlockLength
require 'rubocop/rake_task'
require 'foodcritic'
desc 'Run Ruby syntax/lint checks'
RuboCop::RakeTask.new(:ruby) do |task|
task.requires = ['rubocop/formatter/checkstyle_formatter']
task.options = [
'-c', './.rubocop.yml',
'--require', 'rubocop/formatter/checkstyle_formatter',
'--format', 'RuboCop::Formatter::CheckstyleFormatter',
'--out', 'reports/checkstyle.xml',
'--format', 'p',
'--display-cop-names',
'--extra-details',
'--display-style-guide'
]
tasks.options << '--no-color' if ENV['user'] == 'jenkins'
task.fail_on_error = true
end
desc 'Run Chef syntax/lint checks'
FoodCritic::Rake::LintTask.new(:chef) do |task|
task.options = {
tags: ['~FC037'],
fail_tags: ['any']
}
end
desc 'Clean previous linter reports'
task :clean do
puts "Cleaning: #{reports}"
FileUtils.rm_rf(reports) if File.exist?(reports)
end
end
desc 'Run all syntax/lint checks'
task lint: ['lint:ruby', 'lint:chef']
# unit testing: ChefSpec
desc 'Run RSpec and ChefSpec unit tests'
RSpec::Core::RakeTask.new(:unit) do |rspec|
rspec.rspec_opts = '--color --format documentation --format html --out reports/rspec_results.html --format RspecJunitFormatter --out reports/rspec_results.xml'
end
# integration testing: Test Kitchen
namespace :integration do
require 'kitchen'
desc 'Run Test Kitchen integration tests with Vagrant'
task :vagrant do
Kitchen.logger = Kitchen.default_file_logger
Kitchen::Config.new.instances.each do |instance|
instance.test(:always)
end
end
end
desc 'Publish package'
task package: ['package:local']
task default: %w(lint unit)
desc 'Run all integration tests'
task integration: ['integration:vagrant']
desc 'Run all CI validations'
task ci: %w(lint unit integration)
# Default cookbooks task
desc 'Run all jenkins tests'
task jenkins: %w(lint unit)