forked from voxpupuli/puppet-unbound
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
66 lines (55 loc) · 1.57 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
# Thank rtyler for donating some code.
#
# https://gist.github.com/rtyler/3041462
#
LINT_IGNORES = ['rvm']
namespace :ci do
task :all do
Rake::Task['ci:validate'].invoke
Rake::Task['ci:spec'].invoke
Rake::Task['ci:lint'].invoke
end
desc "Validate the manifests"
task :validate do
FileList['**/*.pp'].each do |puppet_file|
puts "Validating code parsing for #{puppet_file}"
%x{puppet parser validate #{puppet_file}}
end
end
desc "Run spec tests"
task :spec do
puts "Executing spec tests"
%x{bundle exec rspec}
end
desc "Check puppet module code style."
task :lint do
begin
require 'puppet-lint'
rescue LoadError
fail 'Cannot load puppet-lint, did you install it?'
end
success = true
linter = PuppetLint.new
linter.configuration.log_format =
'%{path}:%{linenumber}:%{check}:%{KIND}:%{message}'
lintrc = ".puppet-lintrc"
if File.file?(lintrc)
File.read(lintrc).each_line do |line|
check = line.sub(/--no-([a-zA-Z0-9_]*)-check/, '\1').chomp
linter.configuration.send("disable_#{check}")
end
end
FileList['**/*.pp'].each do |puppet_file|
if puppet_file.start_with? 'modules'
parts = puppet_file.split('/')
module_name = parts[1]
next if LINT_IGNORES.include? module_name
end
puts "Evaluating code style for #{puppet_file}"
linter.file = puppet_file
linter.run
success = false if linter.errors?
end
abort "Checking puppet module code style FAILED" if success.is_a?(FalseClass)
end
end