50 lines
1.4 KiB
Ruby
50 lines
1.4 KiB
Ruby
require 'rubygems'
|
|
require 'puppetlabs_spec_helper/rake_tasks'
|
|
require 'puppet-lint/tasks/puppet-lint'
|
|
PuppetLint.configuration.send('disable_80chars')
|
|
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
|
|
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
|
|
|
|
desc "Validate manifests, templates, and ruby files"
|
|
task :validate do
|
|
Dir['manifests/**/*.pp'].each do |manifest|
|
|
sh "puppet parser validate --noop #{manifest}"
|
|
end
|
|
Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file|
|
|
sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/
|
|
end
|
|
Dir['templates/**/*.erb'].each do |template|
|
|
sh "erb -P -x -T '-' #{template} | ruby -c"
|
|
end
|
|
end
|
|
|
|
namespace :lint do
|
|
desc "Check puppet module code style."
|
|
task :ci do
|
|
begin
|
|
require 'puppet-lint'
|
|
rescue LoadError
|
|
fail 'Cannot load puppet-lint, did you install it?'
|
|
end
|
|
|
|
linter = PuppetLint.new
|
|
linter.configuration.log_format =
|
|
'%{path}:%{linenumber}:%{check}:%{KIND}:%{message}'
|
|
|
|
lintrc = ".puppet-lint.rc"
|
|
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['manifests/**/*.pp','modules/**/*.pp'].exclude(/fixtures/).each do |puppet_file|
|
|
linter.file = puppet_file
|
|
linter.run
|
|
linter.print_problems
|
|
end
|
|
end
|
|
end
|
|
|