README.md in puppet-check-1.2.0 vs README.md in puppet-check-1.2.1
- old
+ new
@@ -3,10 +3,11 @@
- [Description](#description)
- [Usage](#usage)
- [CLI](#cli)
- [Rake](#rake)
+ - [Docker](#docker)
- [Exit Codes](#exit-codes)
- [Optional Dependencies](#optional-dependencies)
- [Contributing](#contributing)
## Description
@@ -110,15 +111,18 @@
- Puppetlabs Spec Helper does not allow interfacing through it to the gems executing the checks.
- Puppetlabs Spec Helper has no CLI.
- Puppetlabs Spec Helper intrinsically only executes spec tests against one module at a time.
- Puppetlabs Spec Helper requires an additional config file for RSpec Puppet support.
-It is worth nothing that there is no current development objective for Puppet Check to achieve the same advanced level of robustness for spec testing that Puppetlabs Spec Helper enables. If you are performing standard spec testing on your Puppet code and data, then Puppet Check's spec testing is a fantastic lightweight and faster alternative to Puppetlabs Spec Helper. If you require advanced and intricate capabilities in your spec testing (e.g. direct interfacing to the `Puppet::Parser::Scope` API), you will likely prefer Puppetlabs Spec Helper's spec testing in conjunction with Puppet Check's file validation.
+It is worth nothing that there is no current development objective for Puppet Check to achieve the same advanced level of robustness for spec testing that Puppetlabs Spec Helper enables. If you are performing standard spec testing on your Puppet code and data, then Puppet Check's spec testing is a fantastic lightweight and faster alternative to Puppetlabs Spec Helper. If you require advanced and intricate capabilities in your spec testing (e.g. direct interfacing to the `Puppet::Parser::Scope` API), then you will likely prefer Puppetlabs Spec Helper's spec testing in conjunction with Puppet Check's file validation.
## Usage
-Puppet Check requires `ruby >= 1.9.3`, `puppet >= 3.2`, and `puppet-lint >= 1.1.0`. All other dependencies should be fine with various versions. Puppet Check can be used either with a CLI or Rake tasks. Please note both interfaces will ignore any directories named `fixtures` or specified paths with that directory during file checks.
+Puppet Check requires `ruby >= 1.9.3`, `puppet >= 3.2`, and `puppet-lint >= 2.0.0`. All other dependencies should be fine with various versions. Puppet Check can be used either with a CLI or Rake tasks. Please note both interfaces will ignore any directories named `fixtures` or specified paths with that directory during file checks and spec tests.
+#### Important Note for Ruby 1.9.3
+If you are using Ruby 1.9.3, there is currently an issue where Hiera has an unspecified version dependency on JSonPure. Since JSonPure 2.0.2 requires `ruby >= 2.0.0`, this breaks Hiera installs on Ruby 1.9.3, which breaks Puppet installs, which breaks PuppetCheck installs. Therefore, you will need to restrict your installed version of JSonPure to something lower than 2.0.2 if you are using Ruby 1.9.3. A ticket with Puppet has been filed by me for this issue, so hopefully a resolution is forthcoming.
+
### CLI
```
usage: puppet-check [options] paths
-f, --future Enable future parser
-s, --style Enable style checks
@@ -130,11 +134,11 @@
The command line interface enables the ability to select the Puppet future parser, additional style checks besides the syntax checks, and to specify PuppetLint and Rubocop checks to ignore. If you require a more robust interface to PuppetLint, Rubocop, and Reek, then please use `.puppet-lint.rc`, `.rubocop.yml` and `*.reek` config files. The `.puppet-lint.rc` can be specified with the `-c` argument. If it is not specified, then PuppetLint will automatically load one from `.puppet-lint.rc`, `~/.puppet-lint.rc`, or `/etc/puppet-lint.rc`, in that order of preference. The nearest `.rubocop.yml` and `*.reek` will be automatically respected.
Example:
```
-puppet-check -s --puppet-lint no-hard_tabs-check,no-80chars-check --rubocop Metrics/LineLength,Style/Encoding path/to/code_and_data
+puppet-check -s --puppet-lint no-hard_tabs-check,no-140chars-check --rubocop Metrics/LineLength,Style/Encoding path/to/code_and_data
```
### Rake
Interfacing with Puppet-Check via `rake` requires a `require puppet-check/tasks` in your Rakefile. This generates the following `rake` commands:
@@ -154,58 +158,85 @@
```
The style checks from within `rake puppetcheck:file` are directly interfaced to `puppet-lint`, `rubocop`, and `reek`. This means that all arguments and options should be specified from within your `.puppet-lint.rc`, `.rubocop.yml`, and `*.reek`. The capability to pass style arguments and options from within the `Rakefile` task block will be considered for future versions.
#### puppetcheck:spec
-The spec tests will be executed against everything that matches the pattern `**/{classes, defines, facter, functions, hosts, puppet, unit, types}/**/*_spec.rb`. This means everything in the current path that appears to be a Puppet module spec test will be regarded as such and executed during this rake task.
+The spec tests will be executed against everything that matches the pattern `**/{classes, defines, facter, functions, hosts, puppet, unit, types}/**/*_spec.rb`. Any of these directories inside of a `fixtures` directory will be ignored. This means everything in the current path that appears to be a Puppet module spec test for your module (not dependencies) will be regarded as such and executed during this rake task.
Please note it is perfectly acceptable to only execute standard RSpec tests in your modules and not use the extended RSpec Puppet matchers. If no Puppet module directories are identified during directory parsing, then no RSpec Puppet related actions (including those described below) will be performed.
-Prior to executing the spec tests, Puppet Check will parse everything in the current path and identify all `spec` directories not within `fixtures` directories. It will then execute RSpec Puppet setup actions inside all directories one level above that contain a `manifests` directory. This is assumed to be a Puppet module directory. These setup actions include creating all of the necessary directories inside of `spec/fixtures`, creating a blank `site.pp` if it is missing, symlinking everything from the module that is needed into fixtures (automatically replaces functionality of self module symlink in `.fixtures.yaml` from Puppetlabs Spec Helper), and creates the `spec_helper.rb` if it is missing.
+Prior to executing the spec tests, Puppet Check will parse everything in the current path and identify all `spec` directories not within `fixtures` directories. It will then execute RSpec Puppet setup actions inside all directories one level above that contain a `manifests` directory. This is assumed to be a Puppet module directory. These setup actions include creating all of the necessary directories inside of `spec/fixtures`, creating a blank `site.pp` if it is missing, symlinking everything from the module that is needed into fixtures (automatically replaces functionality of self module symlink in `.fixtures.yaml` from Puppetlabs Spec Helper), and creates the `spec_helper.rb` if it is missing. Note these setup actions can replace `rspec-puppet-init` from RSpec Puppet and currently are both faster and more accurate.
Puppet Check will also automatically download specified external module dependencies for and during RSpec Puppet testing. Currently `git`, `puppet forge`, and `hg` commands are supported. They can be implemented in the following way in your modules' `metadata.json`:
```json
"dependencies": [
{
"name": "module-name",
- "forge": "forge-name"
+ "forge": "forge-name",
+ "args": "puppet module install optional-arguments"
},
{
"name": "module-name",
- "git": "git-url"
+ "git": "git-url",
+ "args": "git clone optional-arguments"
},
{
"name": "module-name",
- "hg": "hg-url"
+ "hg": "hg-url",
+ "args": "hg clone optional-arguments"
}
]
```
Example:
```json
"dependencies": [
{
"name": "puppetlabs/stdlib",
- "forge": "puppetlabs-stdlib"
+ "forge": "puppetlabs-stdlib",
+ "args": "--do-something-cool"
},
{
"name": "puppetlabs/lvm",
"git": "https://github.com/puppetlabs/puppetlabs-lvm.git"
}
]
```
#### puppetcheck:beaker
-The spec tests will be executed against everything that matches the pattern `**/acceptance`. This means everything in the current path that appears to be a Puppet module acceptance test will be regarded as such and executed during this rake task.
+The spec tests will be executed against everything that matches the pattern `**/acceptance`. Any of these directories inside of a `fixtures` directory will be ignored. This means everything in the current path that appears to be a Puppet module acceptance test for your module (not dependencies) will be regarded as such and executed during this rake task.
Please note this is merely a frontend to Beaker and that Beaker itself has a self-contained scope compared to all the other tools Puppet Check interfaces with and utilizes. This means if you want to add Beaker-RSpec, Serverspec, etc., or perform advanced configurations, those would be all be performed within Beaker itself. This task merely provides an interface to integrate Beaker in with your other testing infrastructure.
+### Docker
+
+You can also use Puppet Check inside of Docker for quick, portable, and disposable testing. Below is an example Dockerfile for this purpose:
+
+```dockerfile
+# a reliable and small container at the moment
+FROM ubuntu:16.04
+# you need ruby and any other extra dependencies that come from packages; in this example we install git to use it for downloading external module dependencies
+RUN apt-get update && apt-get install ruby git -y
+# you need puppet-check and any other extra dependencies that come from gems; in this example we install reek because the ruby ABI is 2.3 and then rspec-puppet and rake for extra testing
+RUN gem install --no-rdoc --no-ri puppet-check reek rspec-puppet rake
+# this is needed for the ruby json parser to not flip out on fresh os installs for some reason (change encoding value as necessary)
+ENV LANG en_US.UTF-8
+# create the directory for your module and change directory into it
+WORKDIR /module_name
+# copy the module contents into the module directory inside the container
+COPY / .
+# execute your tests; in this example we are executing the full suite of tests for this module
+RUN rake puppetcheck
+```
+
+You can also build your own general container for testing various Puppet situations by removing the last three lines. You can then test each module, directory environment, etc. on top of that container by merely adding and modifying the final three lines to a Dockerfile that uses the container you built from the first four lines. This is recommended usage due to being very efficient and stable.
+
### Exit Codes
- 0: PuppetCheck exited with no internal exceptions or errors in your Puppet code and data.
- 1: PuppetCheck exited with an internal exception (takes preference over other non-zero exit codes).
-- 2: PuppetCheck exited with errors in your Puppet code and data.
+- 2: PuppetCheck exited with one or more errors in your Puppet code and data.
### Optional dependencies
- **reek**: will automatically (with `bundler`, otherwise manually) be installed as a dependency and checks enabled during style checks if your Ruby version is `>= 2.1.0`.
- **rake**: install this if you want to use Puppet Check with `rake` tasks in addition to the CLI.
- **rspec**: install this if you want to use Puppet Check to execute the spec tests for your ruby files during `rake`.