This is the Code Quality plugin for puppetlabs-onceover, The gateway drug to automated infrastructure testing with Puppet
The plugin checks your control repository for:
- Linting
- Syntax
And then generates documentation using Puppet Strings
For sure you can hack around with rake/make and hack something up each time but aint nobody got time for that!
Install the puppetlabs-onceover-codequality gem by adding it to your Gemfile or by running the following command:
gem install puppetlabs-onceover-codequalityInstalling the codequality gem creates a new item within puppetlabs-onceover's run command: codequality. See puppetlabs-onceover run codequality --help for all available options.
The command will return 1 to the system if any tests fail, otherwise 0, which makes it perfect to include in build pipelines.
puppetlabs-onceover run codequalitypuppetlabs-onceover run codequality --no_lintpuppetlabs-onceover run codequality --no_syntaxpuppetlabs-onceover run codequality --no_puppetfilepuppetlabs-onceover run codequality --no_docsCreate a file puppet-lint.rc in the directory you run puppetlabs-onceover codequality
from and it will be automatically used by Puppet Lint. If missing, the built-in
defaults from lib/puppetlabs-onceover/codequality/lint.rb will be used.
$ puppetlabs-onceover run codequality
INFO -> Checking for lint...
INFO -> checking manifests
INFO -> checking site/role
INFO -> Checking syntax...
---> syntax:manifests
---> syntax:templates
---> syntax:hiera:yaml
INFO -> Code Quality tests passed, have a nice day$ puppetlabs-onceover run codequality
INFO -> Checking for lint...
INFO -> checking manifests
INFO -> checking site/role
./manifests/example.pp - WARNING: class not documented on line 1
./manifests/webserver.pp - WARNING: class not documented on line 1
./manifests/database_server.pp - WARNING: class not documented on line 1
ERROR -> Lint test failed, see previous errors
INFO -> Checking syntax...
---> syntax:manifests
Could not parse for environment *root*: Syntax error at 'ensure' at /home/geoff/crud/control-repo/manifests/bogus.pp:2:3
ERROR -> Syntax test failed, see previous errors
ERROR -> Code Quality tests failed, see previous error
$ echo $?
1WARN: Unresolved specs during Gem::Specification.reset?
I get these errors when I run puppetlabs-onceover run codequality but everything seems to work, what gives?:
WARN: Unresolved specs during Gem::Specification.reset:
rake (>= 0)
hiera (< 4, >= 2.0)
gettext (>= 3.0.2)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.Beats me - something to do with rubygems. The best way to beat this message is to use bundler which basically you should already be doing anyway (for your own sanity):
bundle exec puppetlabs-onceover run codequalityWhat are you using under-the-hood?
Have a look at helloworld plugin if you want to have a go at writing a plugin of your own.
bundle exec rake spec- Bug reports and pull requests welcome
This project was originally authored by dylanratcliffe. The maintainer preferred that Vox Pupuli take ownership of the project for future improvement and maintenance. Existing pull requests and issues were transferred over, please fork and continue to contribute here instead of voxpupuli/onceover-codequality.