diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 42242eb..54e7532 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,57 +1,104 @@ -# Contributing +# Contributing to the Module or Raising Issues + +## Table of Contents + +1. [Raising an Issue](#raising-an-issue) +1. [Contribtions](#contributions) + * [Unit Tests](#unit-tests) +1. [Further Reading](#further-reading) + +## Raising an Issue + +When raising an issue, please provide the following information: + +* The version of the locp-cassandra module that you are using. +* The version of Cassandra that you are installing. +* The operating system and release (output from `facter os` would be + appropriate). +* A sample of your manifest/profile that is calling the `cassandra` module. + Feel free to obfuscate sections of the code that contain details that + are confidential (e.g. passwords and other secrets). + +## Contributions Contributions will be gratefully accepted. Please go to the project page, fork the project, make your changes locally and then raise a pull request. Details on how to do this are available at https://guides.github.com/activities/contributing-to-open-source. -However, we do ask that: +However, we do ask that at the very least, all items marked as **MUST** or +**WON'T** in the list below are applicable: + +* Any new features (e.g. new resources or new attributes to existing resoures) + **MUST** be fully documented . +* Unit tests **MUST** be completing successfully. See + [Unit Tests](#unit-tests) for more details. If your initial unit tests fail + after a pull request and you need to fix them, simply change the code on + your branch and push them to *origin* again as this will re-run the + tests. It is not required to submit a new pull request. +* Any new functionality or enhancements **SHOULD** be covered by unit/spec + tests. If you are not comfortable with this, submit the PR anyway and + we will fill in these gaps. You will most probably be asked to rebase + your PR branch and then push again to register these changes. +* If applicable, changes **COULD** be covered in beaker/acceptance tests. +* Change **WON'T** break any functionality on any of the supported operating + systems. -* All unit tests pass correctly. For details on running unit tests, see below. - Also all pull requests have the unit tests run against them on CircleCI (see - https://circleci.com/gh/locp/cassandra). -* Any attributes are documented. This should be done in the README file in - the section for the specific class. Class attributes are listed, both in - the manifest code and the README alphabetically. +### Unit Tests -If your initial unit tests fail after a pull request and you need to fix them, -simply change the code on your branch and push them to *origin* again as this -will re-run the tests. It is not required to submit a new pull request. +First, you'll need to install the testing dependencies using +[bundler](http://bundler.io). -If you don't know how to fix the failing tests, simply ask for help in the -pull request and we'll do our best to help. +```shell +bundle install +``` -## Testing +To run all of the unit tests execute the following: -### Spec Tests (Unit Testing) +```shell +bundle exec rake test +``` -At the very least, before submitting your pull request or patch, the following -tests should pass with no errors or warnings: +This should output something like the following: -```bash -bundle update # Update/install your bundle. -bundle exec rake metadata_lint # Ensure metadata is correct. -bundle exec rake rubocop # Ensure unit test code is linted. -bundle exec rake lint # Run puppet-lint -bundle exec rake validate # Check syntax of Ruby files and call :syntax and :metadata -bundle exec rake spec # Run spec tests in a clean fixtures directory ``` +Running RuboCop... +Inspecting 24 files +........................ -### Beaker Tests (Acceptance Testing) +24 files inspected, no offenses detected +---> syntax:manifests +---> syntax:templates +---> syntax:hiera:yaml +/home/ben/.rvm/rubies/ruby-2.1.6/bin/ruby -I/home/ben/.rvm/gems/ruby-2.1.6/gems/rspec-core-3.5.4/lib:/home/ben/.rvm/gems/ruby-2.1.6/gems/rspec-support-3.5.0/lib /home/ben/.rvm/gems/ruby-2.1.6/gems/rspec-core-3.5.4/exe/rspec --pattern spec/\{aliases,classes,defines,unit,functions,hosts,integration,types\}/\*\*/\*_spec.rb --color +[Coveralls] Set up the SimpleCov formatter. +[Coveralls] Using SimpleCov's default settings. +....................................................... -These tests are more expensive and are normally only ran in preparation for -a release. More details are available at -https://github.com/locp/cassandra/wiki/Acceptance-(Beaker)-Tests -which describes the transition of the test harness from Vagrant to Docker. +Finished in 7.86 seconds (files took 0.81841 seconds to load) +55 examples, 0 failures -```bash -for node in $( bundle exec rake beaker_nodes ); do - export BEAKER_set=$node - BEAKER_destroy=onpass bundle exec rake beaker || break -done + +Total resources: 64 +Touched resources: 64 +Resource coverage: 100.00% +[Coveralls] Outside the CI environment, not sending data. ``` -### Further Reading +Note that if you prefer, you can run the lint, syntax, and spec tests separately with individual commands: + +```shell +bundle exec rake metadata_lint +bundle exec rake rubocop +bundle exec rake lint +bundle exec rake validate +bundle exec rake spec +``` + +If in doubt, or you are stuck, please ask for help in the PR or via our +[Gitter Room](https://gitter.im/locp/cassandra). + +## Further Reading * *RSpec tests for your Puppet manifests* * *Beaker Info* diff --git a/Rakefile b/Rakefile index 8120091..b8037f9 100644 --- a/Rakefile +++ b/Rakefile @@ -1,12 +1,19 @@ require 'metadata-json-lint/rake_task' require 'puppet_blacksmith/rake_tasks' require 'puppetlabs_spec_helper/rake_tasks' require 'rubocop/rake_task' require 'rubygems' # Use a custom pattern with git tag. %s is replaced with the version number. Blacksmith::RakeTask.new do |t| t.tag_pattern = '%s' end -# RuboCop::RakeTask.new +desc 'Run metadata_lint, rubocop, lint, valuidate and spec.' +task test: [ + :metadata_lint, + :rubocop, + :lint, + :validate, + :spec +]