This repository contains a set of pre-commit hooks for use with the Puppet Development Kit (PDK). The hooks are designed to be used with Puppet modules and control-repos to ensure that the code is well-formatted, tested, and documented.
- Linux or Mac OS (Windows is not supported)1
- pre-commit
- pdk
- Ensure that both pre-commit and the pdk are installed and available in your path
- Add the desired hooks to your
.pre-commit-config.yaml
in the root of the repository - run
pre-commit install --install-hooks
Tip
To automate the install of pre-commit hooks when creating or cloning a repository, use git's init.templateDir
setting. The Pre-commit project's documentation for this process can be found here.
To add the pdk-validate
, pdk-test-unit
, pdk-puppet-strings-control-repo
hooks, add the following to your .pre-commit-config.yaml
file:
- repo: https://github.com/JakeTRogers/pre-commit_puppet
rev: v1.0.0
hooks:
- id: pdk-validate
args: [--puppet-version=7.27.0, --parallel]
- id: pdk-test-unit
args: [--puppet-version=7.27.0, --clean-fixtures]
- id: pdk-puppet-strings-control-repo
args: [--format=markdown, --out=REFERENCE.md]
Note
Review the pdk documentation for more information on the available options for validate and test unit. While the puppet strings documentation can be found here.
Runs pdk validate
to check the module for common errors in metadata, YAML, Puppet, Ruby, or Tasks.
Runs pdk test unit
to execute all available unit tests for the module/control-repo.
Runs pdk bundle exec puppet strings generate 'site*/**/*.pp' 'site*/**/*.rb'
as a pre-push hook to ensure the control-repo documentation is up to date by checking if the git repo's working directory is dirty.
By default, the documentation is generated as html and written to the doc
directory. This hook allows you to specify --format
and --out
options to change the output format and location.
Runs pdk bundle exec puppet strings generate 'manifests/**/*.pp' 'manifests/**/*.rb'
as a pre-push hook to ensure the module documentation is up to date by checking if the git repo's working directory is dirty.
By default, the documentation is generated as html and written to the doc
directory. This hook allows you to specify --format
and --out
options to change the output format and location.
This project is available under the MIT License.
Please feel free to open an issue or pull request if you have any suggestions or improvements.
Footnotes
-
Windows is not supported because this hook runs the pdk via a bash script. ↩