|
1 | 1 | require 'puppetlabs_spec_helper/rake_tasks' |
| 2 | +require 'puppet/version' |
| 3 | +require 'puppet/vendor/semantic/lib/semantic' unless Puppet.version.to_f < 3.6 |
2 | 4 | require 'puppet-lint/tasks/puppet-lint' |
3 | | -PuppetLint.configuration.send('disable_80chars') |
4 | | -PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] |
5 | | - |
6 | | -desc "Validate manifests, templates, and ruby files" |
7 | | -task :validate do |
8 | | - Dir['manifests/**/*.pp'].each do |manifest| |
9 | | - sh "puppet parser validate --noop #{manifest}" |
10 | | - end |
11 | | - Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file| |
12 | | - sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/ |
13 | | - end |
14 | | - Dir['templates/**/*.erb'].each do |template| |
15 | | - sh "erb -P -x -T '-' #{template} | ruby -c" |
16 | | - end |
| 5 | +require 'puppet-syntax/tasks/puppet-syntax' |
| 6 | + |
| 7 | +# These gems aren't always present, for instance |
| 8 | +# on Travis with --without development |
| 9 | +begin |
| 10 | + require 'puppet_blacksmith/rake_tasks' |
| 11 | +rescue LoadError |
| 12 | +end |
| 13 | + |
| 14 | +Rake::Task[:lint].clear |
| 15 | + |
| 16 | +PuppetLint.configuration.relative = true |
| 17 | +PuppetLint.configuration.send("disable_80chars") |
| 18 | +PuppetLint.configuration.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}" |
| 19 | +PuppetLint.configuration.fail_on_warnings = true |
| 20 | + |
| 21 | +# Forsake support for Puppet 2.6.2 for the benefit of cleaner code. |
| 22 | +# http://puppet-lint.com/checks/class_parameter_defaults/ |
| 23 | +PuppetLint.configuration.send('disable_class_parameter_defaults') |
| 24 | +# http://puppet-lint.com/checks/class_inherits_from_params_class/ |
| 25 | +PuppetLint.configuration.send('disable_class_inherits_from_params_class') |
| 26 | + |
| 27 | +exclude_paths = [ |
| 28 | + "bundle/**/*", |
| 29 | + "pkg/**/*", |
| 30 | + "vendor/**/*", |
| 31 | + "spec/**/*", |
| 32 | +] |
| 33 | +PuppetLint.configuration.ignore_paths = exclude_paths |
| 34 | +PuppetSyntax.exclude_paths = exclude_paths |
| 35 | + |
| 36 | +desc "Run acceptance tests" |
| 37 | +RSpec::Core::RakeTask.new(:acceptance) do |t| |
| 38 | + t.pattern = 'spec/acceptance' |
| 39 | +end |
| 40 | + |
| 41 | +desc "Populate CONTRIBUTORS file" |
| 42 | +task :contributors do |
| 43 | + system("git log --format='%aN' | sort -u > CONTRIBUTORS") |
17 | 44 | end |
| 45 | + |
| 46 | +task :metadata do |
| 47 | + sh "metadata-json-lint metadata.json" |
| 48 | +end |
| 49 | + |
| 50 | +desc "Run syntax, lint, and spec tests." |
| 51 | +task :test => [ |
| 52 | + :syntax, |
| 53 | + :lint, |
| 54 | + :spec, |
| 55 | + :metadata, |
| 56 | +] |
0 commit comments