From b2c341d4a52c46181b7ed506ce05c5b4eabcd89b Mon Sep 17 00:00:00 2001 From: Gael Chamoulaud Date: Wed, 12 Nov 2014 17:36:08 +0100 Subject: [PATCH] Introduce Puppet-lint/syntax test into Packstack - Add puppet-lint and puppet-syntax - To run puppet-lint, please look at the README.md file. Change-Id: I4b9e5d0c030b891545bc07f10091d748cdc1482e Signed-off-by: Gael Chamoulaud --- .gitignore | 2 ++ Gemfile | 17 +++++++++++++++++ README.md | 28 ++++++++++++++++++++++++++++ Rakefile | 20 ++++++++++++++++++++ 4 files changed, 67 insertions(+) create mode 100644 Gemfile create mode 100644 Rakefile diff --git a/.gitignore b/.gitignore index 726885683..b2eb9bdbe 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ *.swp *.log .tox +vendor/* +Gemfile.lock packstack.egg-info diff --git a/Gemfile b/Gemfile new file mode 100644 index 000000000..9e6d4a367 --- /dev/null +++ b/Gemfile @@ -0,0 +1,17 @@ +source 'https://rubygems.org' + +group :development, :test do + gem 'puppetlabs_spec_helper', :require => false + gem 'puppet-lint', '~> 1.1' + gem 'puppet-lint-param-docs', '1.1.0' + gem 'puppet-syntax' + gem 'rake', '10.1.1' +end + +if puppetversion = ENV['PUPPET_GEM_VERSION'] + gem 'puppet', puppetversion, :require => false +else + gem 'puppet', :require => false +end + +# vim:ft=ruby diff --git a/README.md b/README.md index a73d31734..1e68b996f 100644 --- a/README.md +++ b/README.md @@ -131,3 +131,31 @@ executable without further intervention, and **Packstack** is ready to install. **IMPORTANT** Please, respect the Puppet Style Guide as much as possible ! + +## Running local Puppet-lint tests + +It assumes that both `bundler` as well as `rubygems` (and `ruby`) are already +installed on the system. If not, run this command: + + $ sudo yum install rubygems rubygem-bundler ruby ruby-devel -y + +Go into the **Packstack** root directory. + + $ cd packstack/ + +A `Rakefile` contains all you need to run puppet-lint task automatically over +all the puppet manifests included in the **Packstack** project. + + $ ls -l packstack/puppet/templates/ + +and + + $ ls -l packstack/puppet/modules/ + +The default puppet-lint pattern for `.pp` files is `**/*.pp`. So there is no +need to go inside those directories to run puppet-lint ! + + $ mkdir vendor + $ export GEM_HOME=vendor + $ bundle install + $ bundle exec rake lint diff --git a/Rakefile b/Rakefile new file mode 100644 index 000000000..dc9efc974 --- /dev/null +++ b/Rakefile @@ -0,0 +1,20 @@ +require 'puppetlabs_spec_helper/rake_tasks' +require 'puppet-lint/tasks/puppet-lint' +require 'puppet-syntax/tasks/puppet-syntax' + +PuppetLint.configuration.fail_on_warnings = true +PuppetLint.configuration.with_filename = false +PuppetLint.configuration.send('disable_names_containing_dash') +PuppetLint.configuration.send('disable_80chars') +PuppetLint.configuration.send('disable_class_parameter_defaults') +exclude_paths = ['spec/**/*','pkg/**/*','vendor/**/*'] +exclude_lint_paths = exclude_paths + +PuppetLint.configuration.ignore_paths = exclude_lint_paths +PuppetSyntax.exclude_paths = exclude_paths + +task(:default).clear +task :default => :lint + +desc 'Run syntax, lint' +task :test => [:syntax,:lint]