From 02d00f79ce32968d079e5c0dfc80bcd49f31c606 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 13 Oct 2018 18:51:51 +0200 Subject: [PATCH 1/6] modulesync 2.2.0 --- .github/CONTRIBUTING.md | 75 ++++++++++++++++++++++++++++++++--------- .msync.yml | 2 +- .travis.yml | 20 ++++++++--- Gemfile | 5 ++- spec/default_facts.yml | 1 - spec/spec_helper.rb | 24 +++++++------ 6 files changed, 92 insertions(+), 35 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 496a5c034..832578e12 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -12,15 +12,20 @@ By participating in this project you agree to abide by its terms. 1. Create a separate branch for your change. -1. Run the tests. We only take pull requests with passing tests, and - documentation. +1. We only take pull requests with passing tests, and documentation. [travis-ci](http://travis-ci.org) + runs the tests for us. You can also execute them locally. This is explained + in a later section. + +1. Checkout [our docs](https://voxpupuli.org/docs/#reviewing-a-module-pr) we + use to review a module and the [official styleguide](https://puppet.com/docs/puppet/6.0/style_guide.html). + They provide some guidance for new code that might help you before you submit a pull request. 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. + against our current master. 1. Push the branch to your fork and submit a pull request. @@ -38,7 +43,9 @@ 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" +```sh +export PUPPET_VERSION="~> 5.5.6" +``` You can install all needed gems for spec tests into the modules directory by running: @@ -65,13 +72,17 @@ 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 +```sh +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 +```sh +bundle exec rake rubocop +``` ## Running the unit tests @@ -82,15 +93,21 @@ about how best to test your new feature. To run the linter, the syntax checker and the unit tests: - bundle exec rake test +```sh +bundle exec rake test +``` To run your all the unit tests - bundle exec rake spec SPEC_OPTS='--format documentation' +```sh +bundle exec rake spec +``` To run a specific spec test set the `SPEC` variable: - bundle exec rake spec SPEC=spec/foo_spec.rb +```sh +bundle exec rake spec SPEC=spec/foo_spec.rb +``` ## Integration tests @@ -102,23 +119,51 @@ 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 +```sh +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 +```sh +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 +```sh +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`. +Beaker also supports docker containers. We also use that in our automated CI +pipeline at [travis-ci](http://travis-ci.org). To use that instead of Vagrant: + +``` +PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=debian9-64{hypervisor=docker} BEAKER_destroy=yes bundle exec rake beaker +``` + +You can replace the string `debian9` with any common operating system. +The following strings are known to work: + +* ubuntu1604 +* ubuntu1804 +* debian8 +* debian9 +* centos6 +* centos7 + The easiest way to debug in a docker container is to open a shell: - docker exec -it -u root ${container_id_or_name} bash +```sh +docker exec -it -u root ${container_id_or_name} bash +``` + +The source of this file is in our [modulesync_config](https://github.com/voxpupuli/modulesync_config/blob/master/moduleroot/.github/CONTRIBUTING.md.erb) +repository. diff --git a/.msync.yml b/.msync.yml index e1cef550d..1d2221fa3 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '2.0.0' +modulesync_config_version: '2.2.0' diff --git a/.travis.yml b/.travis.yml index d306535ff..7f2a7be6b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,11 +22,11 @@ matrix: 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.4 - bundler_args: --without system_tests development release - env: PUPPET_VERSION="~> 5.0" CHECK=rubocop + env: PUPPET_VERSION="~> 6.0" CHECK=test_with_coveralls - rvm: 2.5.1 + bundler_args: --without system_tests development release + env: PUPPET_VERSION="~> 6.0" CHECK=rubocop + - rvm: 2.4.4 bundler_args: --without system_tests development release env: PUPPET_VERSION="~> 5.0" CHECK=build DEPLOY_TO_FORGE=yes - rvm: 2.5.1 @@ -35,6 +35,12 @@ matrix: env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64{hypervisor=docker} CHECK=beaker services: docker sudo: required + - rvm: 2.5.1 + bundler_args: --without development release + dist: trusty + env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64{hypervisor=docker} CHECK=beaker + services: docker + sudo: required - rvm: 2.5.1 bundler_args: --without development release dist: trusty @@ -47,6 +53,12 @@ matrix: env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos7-64{hypervisor=docker} CHECK=beaker services: docker sudo: required + - rvm: 2.5.1 + bundler_args: --without development release + dist: trusty + env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=centos7-64{hypervisor=docker} CHECK=beaker + services: docker + sudo: required - rvm: 2.5.1 bundler_args: --without development release dist: trusty diff --git a/Gemfile b/Gemfile index 20f3df025..7ed69d4e5 100644 --- a/Gemfile +++ b/Gemfile @@ -11,9 +11,8 @@ def location_for(place, fake_version = nil) end group :test do - gem 'puppetlabs_spec_helper', '~> 2.6', :require => false - gem 'rspec-puppet', '~> 2.5', :require => false - gem 'rspec-puppet-facts', :require => false + gem 'puppetlabs_spec_helper', '>= 2.11.0', :require => false + gem 'rspec-puppet-facts', '>= 1.8.0', :require => false gem 'rspec-puppet-utils', :require => false gem 'puppet-lint-leading_zero-check', :require => false gem 'puppet-lint-trailing_comma-check', :require => false diff --git a/spec/default_facts.yml b/spec/default_facts.yml index 13c416576..2f6698d5b 100644 --- a/spec/default_facts.yml +++ b/spec/default_facts.yml @@ -8,7 +8,6 @@ # Hint if using with rspec-puppet-facts ("on_supported_os.each"): # if a same named fact exists in facterdb it will be overridden. --- -concat_basedir: "/tmp" ipaddress: "172.16.254.254" is_pe: false macaddress: "AA:AA:AA:AA:AA:AA" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index edd44681e..f2d4688d1 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,10 +1,13 @@ -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 +RSpec.configure do |c| + c.mock_with :rspec +end + +require 'puppetlabs_spec_helper/module_spec_helper' +require 'rspec-puppet-facts' +include RspecPuppetFacts if Dir.exist?(File.expand_path('../../lib', __FILE__)) require 'coveralls' @@ -23,14 +26,13 @@ end RSpec.configure do |c| - default_facts = { - puppetversion: Puppet.version, - facterversion: Facter.version - } + default_facts = {} 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 - c.mock_with :rspec -end -# vim: syntax=ruby + # Coverage generation + c.after(:suite) do + RSpec::Puppet::Coverage.report! + end +end From 4f35dc19bc8d4aff79cc7f4ce2276b5bdeb895f9 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 13 Oct 2018 19:03:27 +0200 Subject: [PATCH 2/6] purge obsolete symlink setting in fixtures --- .fixtures.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index 98761185f..b7ec05000 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -6,5 +6,3 @@ fixtures: dirtree: "https://github.com/puppetlabs/pltraining-dirtree.git" java_ks: "https://github.com/puppetlabs/puppetlabs-java_ks.git" apt: "https://github.com/puppetlabs/puppetlabs-apt.git" - symlinks: - rundeck: "#{source_dir}" From 2e711c555291cc6c205ae8f2e487c4fc10151b39 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 13 Oct 2018 19:03:36 +0200 Subject: [PATCH 3/6] allow puppet 6.x --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 72049d6ec..717096800 100644 --- a/metadata.json +++ b/metadata.json @@ -66,7 +66,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 4.10.0 < 6.0.0" + "version_requirement": ">= 4.10.0 < 7.0.0" } ] } From 9362444090fda7cc13ba0f29eb357444d3d21727 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 13 Oct 2018 19:03:41 +0200 Subject: [PATCH 4/6] delete unneeded coverage_spec.rb --- spec/classes/coverage_spec.rb | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 spec/classes/coverage_spec.rb diff --git a/spec/classes/coverage_spec.rb b/spec/classes/coverage_spec.rb deleted file mode 100644 index de446548b..000000000 --- a/spec/classes/coverage_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rspec-puppet' - -at_exit { RSpec::Puppet::Coverage.report! } -# vim: syntax=ruby From 8a4e1e651798e196671c354a1b8a76d474290db4 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 13 Oct 2018 19:51:57 +0200 Subject: [PATCH 5/6] add yumrepo_core module to fixtures --- .fixtures.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.fixtures.yml b/.fixtures.yml index b7ec05000..0c7ac7d0a 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -6,3 +6,6 @@ fixtures: dirtree: "https://github.com/puppetlabs/pltraining-dirtree.git" java_ks: "https://github.com/puppetlabs/puppetlabs-java_ks.git" apt: "https://github.com/puppetlabs/puppetlabs-apt.git" + yumrepo_core: + repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git + puppet_version: ">= 6.0.0" From 2eb5eaf52b42d696855b3f40efbebe5bc23b4f47 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 13 Oct 2018 20:06:54 +0200 Subject: [PATCH 6/6] add augeas_core module to fixtures --- .fixtures.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.fixtures.yml b/.fixtures.yml index 0c7ac7d0a..9e4fdca72 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -9,3 +9,6 @@ fixtures: yumrepo_core: repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git puppet_version: ">= 6.0.0" + augeas_core: + repo: https://github.com/puppetlabs/puppetlabs-augeas_core.git + puppet_version: ">= 6.0.0"