From a5809e45e1f8d34c88713b3c7782a4e78bb50c51 Mon Sep 17 00:00:00 2001 From: varac Date: Mon, 25 Apr 2016 13:11:25 -0300 Subject: Add syntaxcheck and lint rake tasks to platform `rake test` will run all puppet checks required for CI (syntax , validate, templates, spec, lint). We ignore lint checks for submodules for now because puppet-lint would complain a lot! --- Rakefile | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 8f7a9686..0d1b18ad 100644 --- a/Rakefile +++ b/Rakefile @@ -3,11 +3,12 @@ require 'puppet-lint/tasks/puppet-lint' require 'puppet-syntax/tasks/puppet-syntax' # return list of modules, either -# submodules or custom modules +# 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 Dir['puppet/modules/*'].sort.each do |m| system("grep -q #{m} .gitmodules") @@ -16,32 +17,41 @@ def modules_pattern (type) else custom_modules << m + '/**/*.pp' end + all_modules << m + '/**/*.pp' end - if type == 'submodule' - submodules - elsif type == 'custom' - custom_modules - else + case type + when 'submodule' + submodules + when 'custom' + custom_modules + when 'all' + all_modules end - end +exclude_paths = ["**/vendor/**/*", "spec/fixtures/**/*", "pkg/**/*" ] - -# redefine lint task with specific configuration +# redefine lint task so we don't lint submoudules for now Rake::Task[:lint].clear -desc "boo" PuppetLint::RakeTask.new :lint do |config| - # Pattern of files to check, defaults to `**/*.pp` - config.pattern = modules_pattern('custom') - config.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp", "vendor/**/*.pp"] + # 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 = ["**/vendor/**/*"] +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 +end -desc "Run all puppet checks required for CI" -task :test => [:lint, :syntax , :validate, :spec] +desc "Run all puppet checks required for CI (syntax , validate, spec, lint)" +task :test => [:syntax , :validate, :templates, :spec, :lint] -- cgit v1.2.3 From 08b1237a09254382fb746162f146acb7ed109c0e Mon Sep 17 00:00:00 2001 From: varac Date: Sat, 11 Jun 2016 21:10:21 +0200 Subject: Added rake task catalog:all to test catalog compile --- Rakefile | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 0d1b18ad..9e5db405 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,7 @@ require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' require 'puppet-syntax/tasks/puppet-syntax' +require 'puppet-catalog-test' # return list of modules, either # submodules, custom or all modules @@ -53,5 +54,34 @@ task :templates do end end +desc "Compile hiera config for test_provider" +task :test_provider_compile do + sh "cd tests/puppet/provider; bundle exec leap compile" +end + +namespace :catalog do + PuppetCatalogTest::RakeTask.new(:all) do |t| + Rake::Task["test_provider_compile"].invoke + t.module_paths = ["puppet/modules"] + t.manifest_path = File.join("puppet","manifests", "site.pp") + t.facts = { + "operatingsystem" => "Debian", + "osfamily" => "Debian", + "operatingsystemmajrelease" => "8", + "debian_release" => "stable", + "debian_codename" => "jessie", + "lsbdistcodename" => "jessie", + "concat_basedir" => "/var/lib/puppet/concat", + "interfaces" => "eth0" + } + + # crucial option for hiera integration + t.config_dir = File.join("tests/puppet") # expects hiera.yaml to be included in directory + + # t.parser = "future" + t.verbose = true + end +end + desc "Run all puppet checks required for CI (syntax , validate, spec, lint)" task :test => [:syntax , :validate, :templates, :spec, :lint] -- cgit v1.2.3 From 30631498eaa136393cb0e87fcc569209c30d8726 Mon Sep 17 00:00:00 2001 From: varac Date: Tue, 14 Jun 2016 11:48:36 +0200 Subject: Improved Rakefile --- Rakefile | 101 +++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 60 insertions(+), 41 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 9e5db405..ca1b4ef7 100644 --- a/Rakefile +++ b/Rakefile @@ -4,30 +4,33 @@ require 'puppet-syntax/tasks/puppet-syntax' require 'puppet-catalog-test' # return list of modules, either -# submodules, custom or all modules +# "external" (submodules or subrepos), "custom" (no submodules nor subrepos) +# 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 + external = Array.new + internal = Array.new + all = Array.new Dir['puppet/modules/*'].sort.each do |m| - system("grep -q #{m} .gitmodules") + + # submodule or subrepo ? + system("grep -q #{m} .gitmodules 2>/dev/null || test -f #{m}/.gitrepo") if $?.exitstatus == 0 - submodules << m + '/**/*.pp' + external << m + '/**/*.pp' else - custom_modules << m + '/**/*.pp' + internal << m + '/**/*.pp' end - all_modules << m + '/**/*.pp' + all << m + '/**/*.pp' end case type - when 'submodule' - submodules - when 'custom' - custom_modules + when 'external' + external + when 'internal' + internal when 'all' - all_modules + all end end @@ -37,7 +40,7 @@ exclude_paths = ["**/vendor/**/*", "spec/fixtures/**/*", "pkg/**/*" ] 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.pattern = modules_pattern('internal') config.ignore_paths = exclude_paths config.disable_checks = ['documentation', '80chars'] config.fail_on_warnings = false @@ -54,34 +57,50 @@ task :templates do end end -desc "Compile hiera config for test_provider" -task :test_provider_compile do - sh "cd tests/puppet/provider; bundle exec leap compile" +namespace :platform do + desc "Compile hiera config for test_provider" + task :provider_compile do + sh "cd tests/puppet/provider; bundle exec leap compile" + end end -namespace :catalog do - PuppetCatalogTest::RakeTask.new(:all) do |t| - Rake::Task["test_provider_compile"].invoke - t.module_paths = ["puppet/modules"] - t.manifest_path = File.join("puppet","manifests", "site.pp") - t.facts = { - "operatingsystem" => "Debian", - "osfamily" => "Debian", - "operatingsystemmajrelease" => "8", - "debian_release" => "stable", - "debian_codename" => "jessie", - "lsbdistcodename" => "jessie", - "concat_basedir" => "/var/lib/puppet/concat", - "interfaces" => "eth0" - } - - # crucial option for hiera integration - t.config_dir = File.join("tests/puppet") # expects hiera.yaml to be included in directory - - # t.parser = "future" - t.verbose = true - end +PuppetCatalogTest::RakeTask.new('catalog') do |t| + Rake::Task["platform:provider_compile"].invoke + t.module_paths = ["puppet/modules"] + t.manifest_path = File.join("puppet","manifests", "site.pp") + t.facts = { + "operatingsystem" => "Debian", + "osfamily" => "Debian", + "operatingsystemmajrelease" => "8", + "debian_release" => "stable", + "debian_codename" => "jessie", + "lsbdistcodename" => "jessie", + "concat_basedir" => "/var/lib/puppet/concat", + "interfaces" => "eth0" + } + + # crucial option for hiera integration + t.config_dir = File.join("tests/puppet") # expects hiera.yaml to be included in directory + + # t.parser = "future" + #t.verbose = true +end + + +namespace :test do + desc "Run all puppet syntax checks required for CI (syntax , validate, templates, spec, lint)" + task :syntax => [:syntax, :validate, :templates, :spec, :lint] + + desc "Tries to compile the catalog" + task :catalog => [:catalog] + + #task :all => [:syntax, :catalog] end -desc "Run all puppet checks required for CI (syntax , validate, spec, lint)" -task :test => [:syntax , :validate, :templates, :spec, :lint] +# unfortunatly, we cannot have one taks to rule them all +# because :catalog would conflict with :syntax or :validate: +# rake aborted! +# Puppet::DevError: Attempting to initialize global default settings more than once! +# /home/varac/dev/projects/leap/git/leap_platform/vendor/bundle/ruby/2.3.0/gems/puppet-3.8.7/lib/puppet/settings.rb:261:in `initialize_global_settings' +#desc "Run all platform tests" +#task :test => 'test:all' -- cgit v1.2.3 From 816ce319a6bb89372a316de0e0623a64b6e2aa26 Mon Sep 17 00:00:00 2001 From: varac Date: Tue, 14 Jun 2016 12:03:34 +0200 Subject: squirrel fails on syntax:templates --- Rakefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index ca1b4ef7..88f1361b 100644 --- a/Rakefile +++ b/Rakefile @@ -88,8 +88,10 @@ end namespace :test do + # :syntax:templates fails on squirrel, see https://jenkins.leap.se/view/Platform%20Builds/job/platform_citest/115/console + # but we have our own synax test desc "Run all puppet syntax checks required for CI (syntax , validate, templates, spec, lint)" - task :syntax => [:syntax, :validate, :templates, :spec, :lint] + task :syntax => [:"syntax:hiera", :"syntax:manifests", :validate, :templates, :spec, :lint] desc "Tries to compile the catalog" task :catalog => [:catalog] -- cgit v1.2.3 From 0eac23ff397bbf58a9a6ef465c5b27fa6fa7d8c2 Mon Sep 17 00:00:00 2001 From: varac Date: Mon, 27 Jun 2016 13:49:50 +0200 Subject: Puppet-lint 2.0 release --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 88f1361b..cbd3d07c 100644 --- a/Rakefile +++ b/Rakefile @@ -42,7 +42,7 @@ PuppetLint::RakeTask.new :lint do |config| # only check for custom manifests, not submodules for now config.pattern = modules_pattern('internal') config.ignore_paths = exclude_paths - config.disable_checks = ['documentation', '80chars'] + config.disable_checks = ['documentation', '140chars', 'arrow_alignment'] config.fail_on_warnings = false end -- cgit v1.2.3 From 1d56c0a7795ef87e34bd06c93a6525f3068aa536 Mon Sep 17 00:00:00 2001 From: elijah Date: Mon, 29 Aug 2016 21:13:42 -0700 Subject: move platform ci tests to tests/platform-ci --- Rakefile | 108 --------------------------------------------------------------- 1 file changed, 108 deletions(-) delete mode 100644 Rakefile (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile deleted file mode 100644 index cbd3d07c..00000000 --- a/Rakefile +++ /dev/null @@ -1,108 +0,0 @@ -require 'puppetlabs_spec_helper/rake_tasks' -require 'puppet-lint/tasks/puppet-lint' -require 'puppet-syntax/tasks/puppet-syntax' -require 'puppet-catalog-test' - -# return list of modules, either -# "external" (submodules or subrepos), "custom" (no submodules nor subrepos) -# or all modules -# so we can check each array seperately -def modules_pattern (type) - external = Array.new - internal = Array.new - all = Array.new - - Dir['puppet/modules/*'].sort.each do |m| - - # submodule or subrepo ? - system("grep -q #{m} .gitmodules 2>/dev/null || test -f #{m}/.gitrepo") - if $?.exitstatus == 0 - external << m + '/**/*.pp' - else - internal << m + '/**/*.pp' - end - all << m + '/**/*.pp' - end - - case type - when 'external' - external - when 'internal' - internal - when 'all' - all - end -end - -exclude_paths = ["**/vendor/**/*", "spec/fixtures/**/*", "pkg/**/*" ] - -# 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('internal') - config.ignore_paths = exclude_paths - config.disable_checks = ['documentation', '140chars', 'arrow_alignment'] - 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 -end - -namespace :platform do - desc "Compile hiera config for test_provider" - task :provider_compile do - sh "cd tests/puppet/provider; bundle exec leap compile" - end -end - -PuppetCatalogTest::RakeTask.new('catalog') do |t| - Rake::Task["platform:provider_compile"].invoke - t.module_paths = ["puppet/modules"] - t.manifest_path = File.join("puppet","manifests", "site.pp") - t.facts = { - "operatingsystem" => "Debian", - "osfamily" => "Debian", - "operatingsystemmajrelease" => "8", - "debian_release" => "stable", - "debian_codename" => "jessie", - "lsbdistcodename" => "jessie", - "concat_basedir" => "/var/lib/puppet/concat", - "interfaces" => "eth0" - } - - # crucial option for hiera integration - t.config_dir = File.join("tests/puppet") # expects hiera.yaml to be included in directory - - # t.parser = "future" - #t.verbose = true -end - - -namespace :test do - # :syntax:templates fails on squirrel, see https://jenkins.leap.se/view/Platform%20Builds/job/platform_citest/115/console - # but we have our own synax test - desc "Run all puppet syntax checks required for CI (syntax , validate, templates, spec, lint)" - task :syntax => [:"syntax:hiera", :"syntax:manifests", :validate, :templates, :spec, :lint] - - desc "Tries to compile the catalog" - task :catalog => [:catalog] - - #task :all => [:syntax, :catalog] -end - -# unfortunatly, we cannot have one taks to rule them all -# because :catalog would conflict with :syntax or :validate: -# rake aborted! -# Puppet::DevError: Attempting to initialize global default settings more than once! -# /home/varac/dev/projects/leap/git/leap_platform/vendor/bundle/ruby/2.3.0/gems/puppet-3.8.7/lib/puppet/settings.rb:261:in `initialize_global_settings' -#desc "Run all platform tests" -#task :test => 'test:all' -- cgit v1.2.3