|
| 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 | +Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. [Contributor Code of Conduct](https://voxpupuli.org/coc/). |
| 9 | + |
| 10 | +1. Fork the repo. |
| 11 | + |
| 12 | +1. Create a separate branch for your change. |
| 13 | + |
| 14 | +1. Run the tests. We only take pull requests with passing tests, and |
| 15 | + documentation. |
| 16 | + |
| 17 | +1. Add a test for your change. Only refactoring and documentation |
| 18 | + changes require no new tests. If you are adding functionality |
| 19 | + or fixing a bug, please add a test. |
| 20 | + |
| 21 | +1. Squash your commits down into logical components. Make sure to rebase |
| 22 | + against the current master. |
| 23 | + |
| 24 | +1. Push the branch to your fork and submit a pull request. |
| 25 | + |
| 26 | +Please be prepared to repeat some of these steps as our contributors review |
| 27 | +your code. |
| 28 | + |
| 29 | +## Dependencies |
| 30 | + |
| 31 | +The testing and development tools have a bunch of dependencies, |
| 32 | +all managed by [bundler](http://bundler.io/) according to the |
| 33 | +[Puppet support matrix](http://docs.puppetlabs.com/guides/platforms.html#ruby-versions). |
| 34 | + |
| 35 | +By default the tests use a baseline version of Puppet. |
| 36 | + |
| 37 | +If you have Ruby 2.x or want a specific version of Puppet, |
| 38 | +you must set an environment variable such as: |
| 39 | + |
| 40 | + export PUPPET_VERSION="~> 4.2.0" |
| 41 | + |
| 42 | +Install the dependencies like so... |
| 43 | + |
| 44 | + bundle install |
| 45 | + |
| 46 | +## Syntax and style |
| 47 | + |
| 48 | +The test suite will run [Puppet Lint](http://puppet-lint.com/) and |
| 49 | +[Puppet Syntax](https://github.com/gds-operations/puppet-syntax) to |
| 50 | +check various syntax and style things. You can run these locally with: |
| 51 | + |
| 52 | + bundle exec rake lint |
| 53 | + bundle exec rake validate |
| 54 | + |
| 55 | +## Running the unit tests |
| 56 | + |
| 57 | +The unit test suite covers most of the code, as mentioned above please |
| 58 | +add tests if you're adding new functionality. If you've not used |
| 59 | +[rspec-puppet](http://rspec-puppet.com/) before then feel free to ask |
| 60 | +about how best to test your new feature. |
| 61 | + |
| 62 | +To run your all the unit tests |
| 63 | + |
| 64 | + bundle exec rake spec SPEC_OPTS='--format documentation' |
| 65 | + |
| 66 | +To run a specific spec test set the `SPEC` variable: |
| 67 | + |
| 68 | + bundle exec rake spec SPEC=spec/foo_spec.rb |
| 69 | + |
| 70 | +To run the linter, the syntax checker and the unit tests: |
| 71 | + |
| 72 | + bundle exec rake test |
| 73 | + |
| 74 | + |
| 75 | +## Integration tests |
| 76 | + |
| 77 | +The unit tests just check the code runs, not that it does exactly what |
| 78 | +we want on a real machine. For that we're using |
| 79 | +[beaker](https://github.com/puppetlabs/beaker). |
| 80 | + |
| 81 | +This fires up a new virtual machine (using vagrant) and runs a series of |
| 82 | +simple tests against it after applying the module. You can run this |
| 83 | +with: |
| 84 | + |
| 85 | + bundle exec rake acceptance |
| 86 | + |
| 87 | +This will run the tests on an Ubuntu 12.04 virtual machine. You can also |
| 88 | +run the integration tests against Centos 6.5 with. |
| 89 | + |
| 90 | + BEAKER_set=centos-64-x64 bundle exec rake acceptances |
| 91 | + |
| 92 | +If you don't want to have to recreate the virtual machine every time you |
| 93 | +can use `BEAKER_DESTROY=no` and `BEAKER_PROVISION=no`. On the first run you will |
| 94 | +at least need `BEAKER_PROVISION` set to yes (the default). The Vagrantfile |
| 95 | +for the created virtual machines will be in `.vagrant/beaker_vagrant_fies`. |
0 commit comments