diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 7a0980a..496a5c0 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,109 +1,124 @@ This module has grown over time based on a range of contributions from people using it. If you follow these contributing guidelines your patch will likely make it into a release a little more quickly. ## Contributing 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/). 1. Fork the repo. 1. Create a separate branch for your change. 1. Run the tests. We only take pull requests with passing tests, and documentation. 1. Add a test for your change. Only refactoring and documentation changes require no new tests. If you are adding functionality or fixing a bug, please add a test. 1. Squash your commits down into logical components. Make sure to rebase against the current master. 1. Push the branch to your fork and submit a pull request. Please be prepared to repeat some of these steps as our contributors review your code. ## Dependencies The testing and development tools have a bunch of dependencies, all managed by [bundler](http://bundler.io/) according to the [Puppet support matrix](http://docs.puppetlabs.com/guides/platforms.html#ruby-versions). By default the tests use a baseline version of Puppet. If you have Ruby 2.x or want a specific version of Puppet, you must set an environment variable such as: export PUPPET_VERSION="~> 4.2.0" -Install the dependencies like so... +You can install all needed gems for spec tests into the modules directory by +running: - bundle install +```sh +bundle install --path .vendor/ --without development --without system_tests --without release +``` + +If you also want to run acceptance tests: + +```sh +bundle install --path .vendor/ --without development --with system_tests --without release +``` + +Our all in one solution if you don't know if you need to install or update gems: + +```sh +bundle install --path .vendor/ --without development --with system_tests --without release; bundle update; bundle clean +``` ## Syntax and style The test suite will run [Puppet Lint](http://puppet-lint.com/) and [Puppet Syntax](https://github.com/gds-operations/puppet-syntax) to check various syntax and style things. You can run these locally with: bundle exec rake lint bundle exec rake validate It will also run some [Rubocop](http://batsov.com/rubocop/) tests against it. You can run those locally ahead of time with: bundle exec rake rubocop ## Running the unit tests The unit test suite covers most of the code, as mentioned above please add tests if you're adding new functionality. If you've not used [rspec-puppet](http://rspec-puppet.com/) before then feel free to ask about how best to test your new feature. To run the linter, the syntax checker and the unit tests: bundle exec rake test To run your all the unit tests bundle exec rake spec SPEC_OPTS='--format documentation' To run a specific spec test set the `SPEC` variable: bundle exec rake spec SPEC=spec/foo_spec.rb ## Integration tests The unit tests just check the code runs, not that it does exactly what we want on a real machine. For that we're using [beaker](https://github.com/puppetlabs/beaker). This fires up a new virtual machine (using vagrant) and runs a series of simple tests against it after applying the module. You can run this with: bundle exec rake acceptance This will run the tests on the module's default nodeset. You can override the nodeset used, e.g., BEAKER_set=centos-7-x64 bundle exec rake acceptance There are default rake tasks for the various acceptance test modules, e.g., bundle exec rake beaker:centos-7-x64 bundle exec rake beaker:ssh:centos-7-x64 If you don't want to have to recreate the virtual machine every time you can use `BEAKER_destroy=no` and `BEAKER_provision=no`. On the first run you will at least need `BEAKER_provision` set to yes (the default). The Vagrantfile for the created virtual machines will be in `.vagrant/beaker_vagrant_files`. The easiest way to debug in a docker container is to open a shell: docker exec -it -u root ${container_id_or_name} bash diff --git a/.msync.yml b/.msync.yml index b49c4c6..1a13211 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '1.9.0' +modulesync_config_version: '1.9.2' diff --git a/.travis.yml b/.travis.yml index 18e6d8e..2efe490 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,49 +1,52 @@ --- sudo: false dist: trusty language: ruby cache: bundler +# related to https://github.com/rubygems/rubygems/issues/2123 before_install: - - rm -f Gemfile.lock + - 'rm -f Gemfile.lock' + - 'gem update --system' + - 'gem install bundler' script: - 'bundle exec rake $CHECK' matrix: fast_finish: true include: - rvm: 2.1.9 bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 4.0" CHECK=test PARALLEL_TEST_PROCESSORS=12 - - rvm: 2.4.3 + - rvm: 2.4.4 bundler_args: --without system_tests development release - env: PUPPET_VERSION="~> 5.0" CHECK=test_with_coveralls - - rvm: 2.5.0 + env: PUPPET_VERSION="~> 5.0" CHECK=test + - rvm: 2.5.1 bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 5.0" CHECK=test_with_coveralls - - rvm: 2.4.3 + - rvm: 2.4.4 bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 5.0" CHECK=rubocop - - rvm: 2.4.3 + - rvm: 2.5.1 bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 5.0" CHECK=build DEPLOY_TO_FORGE=yes branches: only: - master - /^v\d/ notifications: email: false irc: on_success: always on_failure: always channels: - "chat.freenode.org#voxpupuli-notifications" deploy: provider: puppetforge user: puppet password: secure: "" on: tags: true # all_branches is required to use tags all_branches: true # Only publish the build marked with "DEPLOY_TO_FORGE" condition: "$DEPLOY_TO_FORGE = yes" diff --git a/Gemfile b/Gemfile index 57fcafa..1527b39 100644 --- a/Gemfile +++ b/Gemfile @@ -1,77 +1,78 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" def location_for(place, fake_version = nil) if place =~ /^(git[:@][^#]*)#(.*)/ [fake_version, { :git => $1, :branch => $2, :require => false }].compact elsif place =~ /^file:\/\/(.*)/ ['>= 0', { :path => File.expand_path($1), :require => false }] else [place, { :require => false }] end end group :test do gem 'puppetlabs_spec_helper', '~> 2.6.0', :require => false gem 'rspec-puppet', '~> 2.5', :require => false gem 'rspec-puppet-facts', :require => false gem 'rspec-puppet-utils', :require => false gem 'puppet-lint-leading_zero-check', :require => false gem 'puppet-lint-trailing_comma-check', :require => false gem 'puppet-lint-version_comparison-check', :require => false gem 'puppet-lint-classes_and_types_beginning_with_digits-check', :require => false gem 'puppet-lint-unquoted_string-check', :require => false gem 'puppet-lint-variable_contains_upcase', :require => false gem 'metadata-json-lint', :require => false gem 'redcarpet', :require => false gem 'rubocop', '~> 0.49.1', :require => false if RUBY_VERSION >= '2.3.0' gem 'rubocop-rspec', '~> 1.15.0', :require => false if RUBY_VERSION >= '2.3.0' - gem 'mocha', '>= 1.2.1', :require => false + gem 'mocha', '~> 1.4.0', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false gem 'rack', '~> 1.0', :require => false if RUBY_VERSION < '2.2.2' gem 'parallel_tests', :require => false end group :development do gem 'travis', :require => false gem 'travis-lint', :require => false gem 'guard-rake', :require => false gem 'overcommit', '>= 0.39.1', :require => false end group :system_tests do - gem 'winrm', :require => false + gem 'winrm', :require => false if beaker_version = ENV['BEAKER_VERSION'] gem 'beaker', *location_for(beaker_version) else gem 'beaker', '>= 3.9.0', :require => false end if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] gem 'beaker-rspec', *location_for(beaker_rspec_version) else gem 'beaker-rspec', :require => false end - gem 'serverspec', :require => false - gem 'beaker-puppet_install_helper', :require => false - gem 'beaker-module_install_helper', :require => false + gem 'serverspec', :require => false + gem 'beaker-hostgenerator', '>= 1.1.10', :require => false + gem 'beaker-puppet_install_helper', :require => false + gem 'beaker-module_install_helper', :require => false end group :release do gem 'github_changelog_generator', :require => false, :git => 'https://github.com/skywinder/github-changelog-generator' if RUBY_VERSION >= '2.2.2' gem 'puppet-blacksmith', :require => false gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem' gem 'puppet-strings', '~> 1.0', :require => false end if facterversion = ENV['FACTER_GEM_VERSION'] gem 'facter', facterversion.to_s, :require => false, :groups => [:test] else gem 'facter', :require => false, :groups => [:test] end ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 5.0' : puppetversion = ENV['PUPPET_VERSION'].to_s gem 'puppet', puppetversion, :require => false, :groups => [:test] # vim: syntax=ruby diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cdd4935..ea74a52 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,31 +1,35 @@ require 'puppetlabs_spec_helper/module_spec_helper' require 'rspec-puppet-facts' include RspecPuppetFacts +# This file is managed via modulesync +# https://github.com/voxpupuli/modulesync +# https://github.com/voxpupuli/modulesync_config + if Dir.exist?(File.expand_path('../../lib', __FILE__)) require 'coveralls' require 'simplecov' require 'simplecov-console' SimpleCov.formatters = [ SimpleCov::Formatter::HTMLFormatter, SimpleCov::Formatter::Console ] SimpleCov.start do track_files 'lib/**/*.rb' add_filter '/spec' add_filter '/vendor' add_filter '/.vendor' end end RSpec.configure do |c| default_facts = { puppetversion: Puppet.version, facterversion: Facter.version } default_facts.merge!(YAML.load(File.read(File.expand_path('../default_facts.yml', __FILE__)))) if File.exist?(File.expand_path('../default_facts.yml', __FILE__)) default_facts.merge!(YAML.load(File.read(File.expand_path('../default_module_facts.yml', __FILE__)))) if File.exist?(File.expand_path('../default_module_facts.yml', __FILE__)) c.default_facts = default_facts end # vim: syntax=ruby