diff options
Diffstat (limited to 'Rakefile')
-rw-r--r--[-rwxr-xr-x] | Rakefile | 83 |
1 files changed, 49 insertions, 34 deletions
@@ -1,42 +1,57 @@ -require 'puppet_blacksmith/rake_tasks' -require 'puppet-lint/tasks/puppet-lint' require 'puppetlabs_spec_helper/rake_tasks' +require 'puppet-lint/tasks/puppet-lint' +require 'puppet-syntax/tasks/puppet-syntax' + +# return list of modules, either +# submodules, custom or all modules +# so we can check each array seperately +def modules_pattern (type) + submodules = Array.new + custom_modules = Array.new + all_modules = Array.new -PuppetLint.configuration.fail_on_warnings = true -PuppetLint.configuration.send('relative') -PuppetLint.configuration.send('disable_80chars') -PuppetLint.configuration.send('disable_class_inherits_from_params_class') -PuppetLint.configuration.send('disable_documentation') -PuppetLint.configuration.send('disable_single_quote_string_with_variables') -PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] - -desc 'Generate pooler nodesets' -task :gen_nodeset do - require 'beaker-hostgenerator' - require 'securerandom' - require 'fileutils' - - agent_target = ENV['TEST_TARGET'] - if ! agent_target - STDERR.puts 'TEST_TARGET environment variable is not set' - STDERR.puts 'setting to default value of "redhat-64default."' - agent_target = 'redhat-64default.' + Dir['puppet/modules/*'].sort.each do |m| + system("grep -q #{m} .gitmodules") + if $?.exitstatus == 0 + submodules << m + '/**/*.pp' + else + custom_modules << m + '/**/*.pp' + end + all_modules << m + '/**/*.pp' end - master_target = ENV['MASTER_TEST_TARGET'] - if ! master_target - STDERR.puts 'MASTER_TEST_TARGET environment variable is not set' - STDERR.puts 'setting to default value of "redhat7-64mdcl"' - master_target = 'redhat7-64mdcl' + case type + when 'submodule' + submodules + when 'custom' + custom_modules + when 'all' + all_modules end +end + +exclude_paths = ["**/vendor/**/*", "spec/fixtures/**/*", "pkg/**/*" ] - targets = "#{master_target}-#{agent_target}" - cli = BeakerHostGenerator::CLI.new([targets]) - nodeset_dir = "tmp/nodesets" - nodeset = "#{nodeset_dir}/#{targets}-#{SecureRandom.uuid}.yaml" - FileUtils.mkdir_p(nodeset_dir) - File.open(nodeset, 'w') do |fh| - fh.print(cli.execute) +# redefine lint task so we don't lint submoudules for now +Rake::Task[:lint].clear +PuppetLint::RakeTask.new :lint do |config| + # only check for custom manifests, not submodules for now + config.pattern = modules_pattern('custom') + config.ignore_paths = exclude_paths + config.disable_checks = ['documentation', '80chars'] + config.fail_on_warnings = false +end + +# rake syntax::* tasks +PuppetSyntax.exclude_paths = exclude_paths +PuppetSyntax.future_parser = true + +desc "Validate erb templates" +task :templates do + Dir['**/templates/**/*.erb'].each do |template| + sh "erb -P -x -T '-' #{template} | ruby -c" unless template =~ /.*vendor.*/ end - puts nodeset end + +desc "Run all puppet checks required for CI (syntax , validate, spec, lint)" +task :test => [:syntax , :validate, :templates, :spec, :lint] |