|
| 1 | +This module has grown over time based on a range of contributions from |
| 2 | +people using it. If you follow these contributing guidelines your patch |
| 3 | +will likely make it into a release a little quicker. |
| 4 | + |
| 5 | + |
| 6 | +## Contributing |
| 7 | + |
| 8 | +1. Fork the repo. |
| 9 | + |
| 10 | +2. Run the tests. We only take pull requests with passing tests, and |
| 11 | + it's great to know that you have a clean slate |
| 12 | + |
| 13 | +3. Add a test for your change. Only refactoring and documentation |
| 14 | + changes require no new tests. If you are adding functionality |
| 15 | + or fixing a bug, please add a test. |
| 16 | + |
| 17 | +4. Make the test pass. |
| 18 | + |
| 19 | +5. Push to your fork and submit a pull request. |
| 20 | + |
| 21 | + |
| 22 | +## Dependencies |
| 23 | + |
| 24 | +The testing and development tools have a bunch of dependencies, |
| 25 | +all managed by [bundler](http://bundler.io/) according to the |
| 26 | +[Puppet support matrix](http://docs.puppetlabs.com/guides/platforms.html#ruby-versions). |
| 27 | + |
| 28 | +By default the tests use a baseline version of Puppet. |
| 29 | + |
| 30 | +If you have Ruby 2.x or want a specific version of Puppet, |
| 31 | +you must set an environment variable such as: |
| 32 | + |
| 33 | + export PUPPET_VERSION="~> 3.2.0" |
| 34 | + |
| 35 | +Install the dependencies like so... |
| 36 | + |
| 37 | + bundle install |
| 38 | + |
| 39 | +## Syntax and style |
| 40 | + |
| 41 | +The test suite will run [Puppet Lint](http://puppet-lint.com/) and |
| 42 | +[Puppet Syntax](https://github.com/gds-operations/puppet-syntax) to |
| 43 | +check various syntax and style things. You can run these locally with: |
| 44 | + |
| 45 | + bundle exec rake lint |
| 46 | + bundle exec rake syntax |
| 47 | + |
| 48 | +## Running the unit tests |
| 49 | + |
| 50 | +The unit test suite covers most of the code, as mentioned above please |
| 51 | +add tests if you're adding new functionality. If you've not used |
| 52 | +[rspec-puppet](http://rspec-puppet.com/) before then feel free to ask |
| 53 | +about how best to test your new feature. Running the test suite is done |
| 54 | +with: |
| 55 | + |
| 56 | + bundle exec rake spec |
| 57 | + |
| 58 | +Note also you can run the syntax, style and unit tests in one go with: |
| 59 | + |
| 60 | + bundle exec rake test |
| 61 | + |
| 62 | +## Automatically run the Integration tests |
| 63 | + |
| 64 | +During development of your puppet module you might want to run your unit tests a couple of times. You can use the following command to automate running the unit tests on every change made in the manifests folder. |
| 65 | + |
| 66 | + bundle exec guard |
| 67 | + |
| 68 | +## Integration tests |
| 69 | + |
| 70 | +The unit tests just check the code runs, not that it does exactly what |
| 71 | +we want on a real machine. For that we're using |
| 72 | +[beaker](https://github.com/puppetlabs/beaker). |
| 73 | + |
| 74 | +This fires up a new virtual machine (using vagrant) and runs a series of |
| 75 | +simple tests against it after applying the module. You can run this |
| 76 | +with: |
| 77 | + |
| 78 | + bundle exec rake acceptance |
| 79 | + |
| 80 | +This will run the tests on an CentOS 7.0 virtual machine. You can also |
| 81 | +run the integration tests against Centos 6.5 with. A list of all configured |
| 82 | +nodesets is in spec/acceptance/nodeset. |
| 83 | + |
| 84 | + BEAKER_SET=centos-65-x64 bundle exec rake acceptance |
| 85 | + |
| 86 | +If you don't want to have to recreate the virtual machine every time you |
| 87 | +can use `BEAKER_DESTROY=no` and `BEAKER_PROVISION=no`. On the first run you will |
| 88 | +at least need `BEAKER_PROVISION` set to yes (the default). The Vagrantfile |
| 89 | +for the created virtual machines will be in `.vagrant/beaker_vagrant_files`. |
| 90 | + |
0 commit comments