From 69449e9150d85b48e927b9dc7de3f23e1a7fd8df Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 7 Apr 2019 18:56:23 +0200 Subject: [PATCH 1/9] modulesync 2.7.0 --- .msync.yml | 2 +- .travis.yml | 59 ++++----------------------------------------- Dockerfile | 2 +- Gemfile | 5 ++-- Rakefile | 41 ++++++------------------------- spec/spec_helper.rb | 4 +++ 6 files changed, 22 insertions(+), 91 deletions(-) diff --git a/.msync.yml b/.msync.yml index 4c6463a5..55198916 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '2.5.1' +modulesync_config_version: '2.7.0' diff --git a/.travis.yml b/.travis.yml index d819e106..4966fc74 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,9 @@ dist: xenial language: ruby cache: bundler before_install: - - sh ./.travis/setup.sh + - gem update --system + - gem update bundler + - bundle --version script: - 'bundle exec rake $CHECK' matrix: @@ -61,11 +63,6 @@ matrix: env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker script: bundle exec rspec spec/acceptance/php56_spec.rb services: docker - - rvm: 2.5.3 - bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6-nightly BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker - script: bundle exec rspec spec/acceptance/php56_spec.rb - services: docker - rvm: 2.5.3 bundler_args: --without development release env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1804-64 BEAKER_HYPERVISOR=docker CHECK=beaker @@ -76,11 +73,6 @@ matrix: env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1804-64 BEAKER_HYPERVISOR=docker CHECK=beaker script: bundle exec rspec spec/acceptance/php_spec.rb services: docker - - rvm: 2.5.3 - bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6-nightly BEAKER_debug=true BEAKER_setfile=ubuntu1804-64 BEAKER_HYPERVISOR=docker CHECK=beaker - script: bundle exec rspec spec/acceptance/php_spec.rb - services: docker - rvm: 2.5.3 bundler_args: --without development release env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker @@ -94,53 +86,12 @@ matrix: - rvm: 2.5.3 bundler_args: --without development release env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6-nightly BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1404-64 BEAKER_HYPERVISOR=docker CHECK=beaker script: bundle exec rspec spec/acceptance/php_spec.rb services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker - script: bundle exec rspec spec/acceptance/php_spec.rb - services: docker - - rvm: 2.5.3 - bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker - script: bundle exec rspec spec/acceptance/php_spec.rb - services: docker - - rvm: 2.5.3 - bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6-nightly BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker - script: bundle exec rspec spec/acceptance/php_spec.rb - services: docker - - rvm: 2.5.3 - bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=debian9-64 BEAKER_HYPERVISOR=docker CHECK=beaker - script: bundle exec rspec spec/acceptance/php_spec.rb - services: docker - - rvm: 2.5.3 - bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian9-64 BEAKER_HYPERVISOR=docker CHECK=beaker - script: bundle exec rspec spec/acceptance/php_spec.rb - services: docker - - rvm: 2.5.3 - bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6-nightly BEAKER_debug=true BEAKER_setfile=debian9-64 BEAKER_HYPERVISOR=docker CHECK=beaker - script: bundle exec rspec spec/acceptance/php_spec.rb - services: docker - - rvm: 2.5.3 - bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=debian8-64 BEAKER_HYPERVISOR=docker CHECK=beaker - script: bundle exec rspec spec/acceptance/php_spec.rb - services: docker - - rvm: 2.5.3 - bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian8-64 BEAKER_HYPERVISOR=docker CHECK=beaker - script: bundle exec rspec spec/acceptance/php_spec.rb - services: docker - - rvm: 2.5.3 - bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6-nightly BEAKER_debug=true BEAKER_setfile=debian8-64 BEAKER_HYPERVISOR=docker CHECK=beaker - script: bundle exec rspec spec/acceptance/php_spec.rb - services: docker + env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1404-64 BEAKER_HYPERVISOR=docker CHECK=beaker branches: only: - master diff --git a/Dockerfile b/Dockerfile index 27a33cf6..67048bb4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:2.5.1 +FROM ruby:2.5.3 WORKDIR /opt/puppet diff --git a/Gemfile b/Gemfile index 9524f1ab..24dbb7ff 100644 --- a/Gemfile +++ b/Gemfile @@ -11,7 +11,7 @@ def location_for(place, fake_version = nil) end group :test do - gem 'puppetlabs_spec_helper', '>= 2.11.0', :require => false + gem 'puppetlabs_spec_helper', '>= 2.14.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 @@ -20,6 +20,7 @@ group :test do 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 'puppet-lint-absolute_classname-check', :require => false gem 'metadata-json-lint', :require => false gem 'redcarpet', :require => false gem 'rubocop', '~> 0.49.1', :require => false @@ -64,7 +65,7 @@ group :release do gem 'github_changelog_generator', :require => false, :git => 'https://github.com/github-changelog-generator/github-changelog-generator' 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 + gem 'puppet-strings', '>= 2.2', :require => false end diff --git a/Rakefile b/Rakefile index 13ef17c0..09701d0f 100644 --- a/Rakefile +++ b/Rakefile @@ -3,19 +3,12 @@ require 'puppetlabs_spec_helper/rake_tasks' # load optional tasks for releases # only available if gem group releases is installed begin - require 'puppet_blacksmith/rake_tasks' require 'voxpupuli/release/rake_tasks' - require 'puppet-strings/tasks' rescue LoadError end PuppetLint.configuration.log_format = '%{path}:%{line}:%{check}:%{KIND}:%{message}' -PuppetLint.configuration.fail_on_warnings = true -PuppetLint.configuration.send('relative') -PuppetLint.configuration.send('disable_140chars') -PuppetLint.configuration.send('disable_class_inherits_from_params_class') -PuppetLint.configuration.send('disable_documentation') -PuppetLint.configuration.send('disable_single_quote_string_with_variables') +PuppetLint.configuration.absolute_classname_reverse = true exclude_paths = %w( pkg/**/* @@ -28,8 +21,7 @@ PuppetSyntax.exclude_paths = exclude_paths desc 'Auto-correct puppet-lint offenses' task 'lint:auto_correct' do - PuppetLint.configuration.fix = true - Rake::Task[:lint].invoke + Rake::Task[:lint_fix].invoke end desc 'Run acceptance tests' @@ -37,10 +29,8 @@ RSpec::Core::RakeTask.new(:acceptance) do |t| t.pattern = 'spec/acceptance' end -desc 'Run tests release_checks' -task test: [ - :release_checks, -] +desc 'Run tests' +task test: [:release_checks] namespace :check do desc 'Check for trailing whitespace' @@ -69,25 +59,10 @@ task test_with_coveralls: [:test] do end end -desc "Print supported beaker sets" -task 'beaker_sets', [:directory] do |t, args| - directory = args[:directory] - - metadata = JSON.load(File.read('metadata.json')) - - (metadata['operatingsystem_support'] || []).each do |os| - (os['operatingsystemrelease'] || []).each do |release| - if directory - beaker_set = "#{directory}/#{os['operatingsystem'].downcase}-#{release}" - else - beaker_set = "#{os['operatingsystem'].downcase}-#{release}-x64" - end - - filename = "spec/acceptance/nodesets/#{beaker_set}.yml" - - puts beaker_set if File.exists? filename - end - end +desc 'Generate REFERENCE.md' +task :reference, [:debug, :backtrace] do |t, args| + patterns = '' + Rake::Task['strings:generate:reference'].invoke(patterns, args[:debug], args[:backtrace]) end begin diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2f2279d2..c53e7031 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,10 @@ # 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 From b4755654d6347ad30db41b81f2fdd626bba089c9 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 7 Apr 2019 19:58:19 +0200 Subject: [PATCH 2/9] puppet-lint: fix relative_classname_inclusion --- manifests/packages.pp | 2 +- manifests/repo.pp | 6 +++--- manifests/repo/ubuntu.pp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/manifests/packages.pp b/manifests/packages.pp index 1758f057..fd556e02 100644 --- a/manifests/packages.pp +++ b/manifests/packages.pp @@ -24,7 +24,7 @@ $real_names = union($names, $names_to_prefix) if $facts['os']['family'] == 'Debian' { if $manage_repos { - include ::apt + include apt Class['::apt::update'] -> Package[$real_names] } package { $real_names: diff --git a/manifests/repo.pp b/manifests/repo.pp index 85b808d4..dd773a66 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -9,10 +9,10 @@ # no contain here because apt does that already case $facts['os']['name'] { 'Debian': { - include ::php::repo::debian + include php::repo::debian } 'Ubuntu': { - include ::php::repo::ubuntu + include php::repo::ubuntu } default: { fail($msg_no_repo) @@ -21,7 +21,7 @@ } 'FreeBSD': {} 'Suse': { - contain ::php::repo::suse + contain php::repo::suse } 'RedHat': { contain 'php::repo::redhat' diff --git a/manifests/repo/ubuntu.pp b/manifests/repo/ubuntu.pp index 09883092..c375b25a 100644 --- a/manifests/repo/ubuntu.pp +++ b/manifests/repo/ubuntu.pp @@ -8,7 +8,7 @@ class php::repo::ubuntu ( $version = undef, ) { - include '::apt' + include 'apt' if($version == undef) { $version_real = '5.6' From a469ad6a3d30066ff770656fb2f2fb6ed3c5be92 Mon Sep 17 00:00:00 2001 From: Dennis Hoppe Date: Fri, 6 Dec 2019 15:34:41 +0100 Subject: [PATCH 3/9] modulesync 2.9.0 --- .github/CONTRIBUTING.md | 157 ++++++++++++++++++++++++++++++++-------- .msync.yml | 2 +- .travis.yml | 21 +++--- Dockerfile | 2 +- Gemfile | 9 ++- Rakefile | 13 ++++ spec/spec_helper.rb | 19 +++++ 7 files changed, 176 insertions(+), 47 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 5d047472..f3ffb570 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,3 +1,18 @@ +# Contribution guidelines + +## Table of contents + +* [Contributing](#contributing) +* [Writing proper commits - short version](#writing-proper-commits-short-version) +* [Writing proper commits - long version](#writing-proper-commits-long-version) +* [Dependencies](#dependencies) + * [Note for OS X users](#note-for-os-x-users) +* [The test matrix](#the-test-matrix) +* [Syntax and style](#syntax-and-style) +* [Running the unit tests](#running-the-unit-tests) +* [Unit tests in docker](#unit-tests-in-docker) +* [Integration tests](#integration-tests) + 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. @@ -8,29 +23,92 @@ 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. 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 our 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. +* Fork the repo. +* Create a separate branch for your change. +* 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](#the-test-matrix). +* Checkout [our docs](https://voxpupuli.org/docs/reviewing_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. +* 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. +* Squash your commits down into logical components. Make sure to rebase against our current master. +* 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. + +## Writing proper commits - short version + +* Make commits of logical units. +* Check for unnecessary whitespace with "git diff --check" before committing. +* Commit using Unix line endings (check the settings around "crlf" in git-config(1)). +* Do not check in commented out code or unneeded files. +* The first line of the commit message should be a short description (50 characters is the soft limit, excluding ticket number(s)), and should skip the full stop. +* Associate the issue in the message. The first line should include the issue number in the form "(#XXXX) Rest of message". +* The body should provide a meaningful commit message, which: + *uses the imperative, present tense: `change`, not `changed` or `changes`. + * includes motivation for the change, and contrasts its implementation with the previous behavior. + * Make sure that you have tests for the bug you are fixing, or feature you are adding. + * Make sure the test suites passes after your commit: + * When introducing a new feature, make sure it is properly documented in the README.md + +## Writing proper commits - long version + + 1. Make separate commits for logically separate changes. + + Please break your commits down into logically consistent units + which include new or changed tests relevant to the rest of the + change. The goal of doing this is to make the diff easier to + read for whoever is reviewing your code. In general, the easier + your diff is to read, the more likely someone will be happy to + review it and get it into the code base. + + If you are going to refactor a piece of code, please do so as a + separate commit from your feature or bug fix changes. + + We also really appreciate changes that include tests to make + sure the bug is not re-introduced, and that the feature is not + accidentally broken. + + Describe the technical detail of the change(s). If your + description starts to get too long, that is a good sign that you + probably need to split up your commit into more finely grained + pieces. + + Commits which plainly describe the things which help + reviewers check the patch and future developers understand the + code are much more likely to be merged in with a minimum of + bike-shedding or requested changes. Ideally, the commit message + would include information, and be in a form suitable for + inclusion in the release notes for the version of Puppet that + includes them. + + Please also check that you are not introducing any trailing + whitespace or other "whitespace errors". You can do this by + running "git diff --check" on your changes before you commit. + + 2. Sending your patches + + To submit your changes via a GitHub pull request, we _highly_ + recommend that you have them on a topic branch, instead of + directly on `master`. + It makes things much easier to keep track of, especially if + you decide to work on another thing before your first change + is merged in. + + GitHub has some pretty good + [general documentation](http://help.github.com/) on using + their site. They also have documentation on + [creating pull requests](http://help.github.com/send-pull-requests/). + + In general, after pushing your topic branch up to your + repository on GitHub, you can switch to the branch in the + GitHub UI and click "Pull Request" towards the top of the page + in order to open a pull request. + + + 3. Update the related GitHub issue. + + If there is a GitHub issue associated with the change you + submitted, then you should update the ticket to include the + location of your branch, along with any other commentary you + may wish to make. ## Dependencies @@ -51,22 +129,39 @@ You can install all needed gems for spec tests into the modules directory by running: ```sh -bundle install --path .vendor/ --without development system_tests release +bundle install --path .vendor/ --without development system_tests release --jobs "$(nproc)" ``` If you also want to run acceptance tests: ```sh -bundle install --path .vendor/ --with system_tests --without development release +bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)" ``` Our all in one solution if you don't know if you need to install or update gems: ```sh -bundle install --path .vendor/ --with system_tests --without development release; bundle update; bundle clean +bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)"; bundle update; bundle clean +``` + +As an alternative to the `--jobs "$(nproc)` parameter, you can set an +environment variable: + +```sh +BUNDLE_JOBS="$(nproc)" ``` -## Syntax and style +### Note for OS X users + +`nproc` isn't a valid command under OS x. As an alternative, you can do: + +```sh +--jobs "$(sysctl -n hw.ncpu)" +``` + +## The test matrix + +### 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 @@ -84,7 +179,7 @@ against it. You can run those locally ahead of time with: bundle exec rake rubocop ``` -## Running the unit tests +### 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 @@ -109,7 +204,7 @@ To run a specific spec test set the `SPEC` variable: bundle exec rake spec SPEC=spec/foo_spec.rb ``` -### Unit tests in docker +#### Unit tests in docker Some people don't want to run the dependencies locally or don't want to install ruby. We ship a Dockerfile that enables you to run all unit tests and linting. @@ -124,7 +219,7 @@ permission to talk to it. You can specify a remote docker host by setting the `DOCKER_HOST` environment variable. it will copy the content of the module into the docker image. So it will not work if a Gemfile.lock exists. -## Integration tests +### 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 @@ -160,7 +255,7 @@ 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: -``` +```sh 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 ``` diff --git a/.msync.yml b/.msync.yml index 55198916..a7c0bbf9 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '2.7.0' +modulesync_config_version: '2.9.0' diff --git a/.travis.yml b/.travis.yml index 4966fc74..5ceee0ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ --- -dist: xenial +dist: bionic language: ruby cache: bundler before_install: @@ -25,17 +25,17 @@ matrix: env: PUPPET_VERSION="~> 5.0" CHECK=build DEPLOY_TO_FORGE=yes - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker script: bundle exec rspec spec/acceptance/php56_spec.rb services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker script: bundle exec rspec spec/acceptance/php56_spec.rb services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6-nightly BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker script: bundle exec rspec spec/acceptance/php56_spec.rb services: docker - rvm: 2.5.3 @@ -55,37 +55,36 @@ matrix: services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker script: bundle exec rspec spec/acceptance/php56_spec.rb services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker script: bundle exec rspec spec/acceptance/php56_spec.rb services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1804-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1804-64 BEAKER_HYPERVISOR=docker CHECK=beaker script: bundle exec rspec spec/acceptance/php_spec.rb services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1804-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1804-64 BEAKER_HYPERVISOR=docker CHECK=beaker script: bundle exec rspec spec/acceptance/php_spec.rb services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker script: bundle exec rspec spec/acceptance/php_spec.rb services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker script: bundle exec rspec spec/acceptance/php_spec.rb services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6-nightly BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1404-64 BEAKER_HYPERVISOR=docker CHECK=beaker script: bundle exec rspec spec/acceptance/php_spec.rb services: docker diff --git a/Dockerfile b/Dockerfile index 67048bb4..6fd63422 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ RUN bundle install --without system_tests development release --path=${BUNDLE_PA COPY . . RUN bundle install -RUN bundle exec release_checks +RUN bundle exec rake release_checks # Container should not saved RUN exit 1 diff --git a/Gemfile b/Gemfile index 24dbb7ff..5a2e7379 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ end group :test do gem 'puppetlabs_spec_helper', '>= 2.14.0', :require => false - gem 'rspec-puppet-facts', '>= 1.8.0', :require => false + gem 'rspec-puppet-facts', '>= 1.9.5', :require => false gem 'rspec-puppet-utils', :require => false gem 'puppet-lint-leading_zero-check', :require => false gem 'puppet-lint-trailing_comma-check', :require => false @@ -21,6 +21,9 @@ group :test do gem 'puppet-lint-unquoted_string-check', :require => false gem 'puppet-lint-variable_contains_upcase', :require => false gem 'puppet-lint-absolute_classname-check', :require => false + gem 'puppet-lint-topscope-variable-check', :require => false + gem 'puppet-lint-legacy_facts-check', :require => false + gem 'puppet-lint-anchor-check', :require => false gem 'metadata-json-lint', :require => false gem 'redcarpet', :require => false gem 'rubocop', '~> 0.49.1', :require => false @@ -62,9 +65,9 @@ group :system_tests do end group :release do - gem 'github_changelog_generator', :require => false, :git => 'https://github.com/github-changelog-generator/github-changelog-generator' + gem 'github_changelog_generator', :require => false, :git => 'https://github.com/voxpupuli/github-changelog-generator', :branch => 'voxpupuli_essential_fixes' gem 'puppet-blacksmith', :require => false - gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem' + gem 'voxpupuli-release', :require => false gem 'puppet-strings', '>= 2.2', :require => false end diff --git a/Rakefile b/Rakefile index 09701d0f..e3642ace 100644 --- a/Rakefile +++ b/Rakefile @@ -77,6 +77,19 @@ begin metadata = JSON.load(File.read(metadata_json)) config.project = metadata['name'] end + + # Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715 + require 'rbconfig' + if RbConfig::CONFIG['host_os'] =~ /linux/ + task :changelog do + puts 'Fixing line endings...' + changelog_file = File.join(__dir__, 'CHANGELOG.md') + changelog_txt = File.read(changelog_file) + new_contents = changelog_txt.gsub(%r{\r\n}, "\n") + File.open(changelog_file, "w") {|file| file.puts new_contents } + end + end + rescue LoadError end # vim: syntax=ruby diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c53e7031..93f417a1 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -7,8 +7,14 @@ require 'puppetlabs_spec_helper/module_spec_helper' require 'rspec-puppet-facts' +require 'bundler' include RspecPuppetFacts +if ENV['DEBUG'] + Puppet::Util::Log.level = :debug + Puppet::Util::Log.newdestination(:console) +end + if File.exist?(File.join(__dir__, 'default_module_facts.yml')) facts = YAML.load(File.read(File.join(__dir__, 'default_module_facts.yml'))) if facts @@ -31,10 +37,23 @@ add_filter '/spec' add_filter '/vendor' add_filter '/.vendor' + add_filter Bundler.configured_bundle_path.path end end RSpec.configure do |c| + # getting the correct facter version is tricky. We use facterdb as a source to mock facts + # see https://github.com/camptocamp/facterdb + # people might provide a specific facter version. In that case we use it. + # Otherwise we need to match the correct facter version to the used puppet version. + # as of 2019-10-31, puppet 5 ships facter 3.11 and puppet 6 ships facter 3.14 + # https://puppet.com/docs/puppet/5.5/about_agent.html + c.default_facter_version = if ENV['FACTERDB_FACTS_VERSION'] + ENV['FACTERDB_FACTS_VERSION'] + else + Gem::Dependency.new('', ENV['PUPPET_VERSION']).match?('', '5') ? '3.11.0' : '3.14.0' + end + # Coverage generation c.after(:suite) do RSpec::Puppet::Coverage.report! From ce6cf058f179c1ce2302da54775164e53cfc0a6b Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Mon, 23 Dec 2019 00:59:18 +0100 Subject: [PATCH 4/9] modulesync 2.10.0 --- .msync.yml | 2 +- .rubocop.yml | 2 +- .travis.yml | 4 ++-- Gemfile | 2 +- Rakefile | 10 ---------- 5 files changed, 5 insertions(+), 15 deletions(-) diff --git a/.msync.yml b/.msync.yml index a7c0bbf9..11aed5fe 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '2.9.0' +modulesync_config_version: '2.10.0' diff --git a/.rubocop.yml b/.rubocop.yml index 099a11c5..5984ccc6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,6 @@ require: rubocop-rspec AllCops: - TargetRubyVersion: 1.9 + TargetRubyVersion: 2.1 Include: - ./**/*.rb Exclude: diff --git a/.travis.yml b/.travis.yml index 5ceee0ae..7307b425 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,7 @@ dist: bionic language: ruby cache: bundler before_install: - - gem update --system - - gem update bundler + - yes | gem update --system - bundle --version script: - 'bundle exec rake $CHECK' @@ -97,6 +96,7 @@ branches: - /^v\d/ notifications: email: false + webhooks: https://voxpupu.li/incoming/travis irc: on_success: always on_failure: always diff --git a/Gemfile b/Gemfile index 5a2e7379..50a90301 100644 --- a/Gemfile +++ b/Gemfile @@ -20,7 +20,7 @@ group :test do 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 'puppet-lint-absolute_classname-check', :require => false + gem 'puppet-lint-absolute_classname-check', '>= 2.0.0', :require => false gem 'puppet-lint-topscope-variable-check', :require => false gem 'puppet-lint-legacy_facts-check', :require => false gem 'puppet-lint-anchor-check', :require => false diff --git a/Rakefile b/Rakefile index e3642ace..c0f2d37d 100644 --- a/Rakefile +++ b/Rakefile @@ -8,16 +8,6 @@ rescue LoadError end PuppetLint.configuration.log_format = '%{path}:%{line}:%{check}:%{KIND}:%{message}' -PuppetLint.configuration.absolute_classname_reverse = true - -exclude_paths = %w( - pkg/**/* - vendor/**/* - .vendor/**/* - spec/**/* -) -PuppetLint.configuration.ignore_paths = exclude_paths -PuppetSyntax.exclude_paths = exclude_paths desc 'Auto-correct puppet-lint offenses' task 'lint:auto_correct' do From 6947c26992a27d522601cf4c11536f28ef73f5b0 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 4 Apr 2020 14:42:17 +0200 Subject: [PATCH 5/9] modulesync 2.12.0 --- .github/CONTRIBUTING.md | 6 +++-- .msync.yml | 2 +- .rubocop.yml | 3 ++- .sync.yml | 3 --- .travis.yml | 34 +++++++++++---------------- Gemfile | 25 ++++---------------- Rakefile | 33 +------------------------- spec/spec_helper.rb | 51 ++++------------------------------------- 8 files changed, 29 insertions(+), 128 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index f3ffb570..2240a970 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -256,18 +256,20 @@ 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: ```sh -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 +PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian10-64{hypervisor=docker} BEAKER_destroy=yes bundle exec rake beaker ``` -You can replace the string `debian9` with any common operating system. +You can replace the string `debian10` with any common operating system. The following strings are known to work: * ubuntu1604 * ubuntu1804 * debian8 * debian9 +* debian10 * centos6 * centos7 +* centos8 The easiest way to debug in a docker container is to open a shell: diff --git a/.msync.yml b/.msync.yml index 11aed5fe..8864fc09 100644 --- a/.msync.yml +++ b/.msync.yml @@ -1 +1 @@ -modulesync_config_version: '2.10.0' +modulesync_config_version: '2.12.0' diff --git a/.rubocop.yml b/.rubocop.yml index 5984ccc6..c2ebc88d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,7 @@ require: rubocop-rspec AllCops: - TargetRubyVersion: 2.1 +# Puppet Server 5 defaults to jruby 1.7 so TargetRubyVersion must stay at 1.9 until we drop support for puppet 5 + TargetRubyVersion: 1.9 Include: - ./**/*.rb Exclude: diff --git a/.sync.yml b/.sync.yml index fd8e067b..0d3c790d 100644 --- a/.sync.yml +++ b/.sync.yml @@ -19,7 +19,4 @@ - set: debian9-64 options: script: 'bundle exec rspec spec/acceptance/php_spec.rb' - - set: debian8-64 - options: - script: 'bundle exec rspec spec/acceptance/php_spec.rb' secure: "GOhttACuJt+3s38m4WnW5RuTgwqaAoeEQnNT+X1Ukn7KdcIk4KV8NzYU/CC0VIm8lUOnBWYJKEC4ixX/J/4Wbxox2RAoKMQrO++L0DB1zTCJnq9SfoUBMaQhXvLu+PbxAR0p3P47ozra0C+pOWDpOaxT9ecufrPQt9W9Z4aY/bs=" diff --git a/.travis.yml b/.travis.yml index 7307b425..9319058b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,62 +34,54 @@ matrix: services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker - script: bundle exec rspec spec/acceptance/php56_spec.rb - services: docker - - rvm: 2.5.3 - bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1804-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker script: bundle exec rspec spec/acceptance/php56_spec.rb services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1804-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker script: bundle exec rspec spec/acceptance/php56_spec.rb services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6-nightly BEAKER_debug=true BEAKER_setfile=ubuntu1804-64 BEAKER_HYPERVISOR=docker CHECK=beaker - script: bundle exec rspec spec/acceptance/php56_spec.rb + env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1804-64 BEAKER_HYPERVISOR=docker CHECK=beaker + script: bundle exec rspec spec/acceptance/php_spec.rb services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker - script: bundle exec rspec spec/acceptance/php56_spec.rb + env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1804-64 BEAKER_HYPERVISOR=docker CHECK=beaker + script: bundle exec rspec spec/acceptance/php_spec.rb services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker - script: bundle exec rspec spec/acceptance/php56_spec.rb + env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker + script: bundle exec rspec spec/acceptance/php_spec.rb services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1804-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker script: bundle exec rspec spec/acceptance/php_spec.rb services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1804-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker script: bundle exec rspec spec/acceptance/php_spec.rb services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=centos7-64 BEAKER_HYPERVISOR=docker CHECK=beaker script: bundle exec rspec spec/acceptance/php_spec.rb services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=debian9-64 BEAKER_HYPERVISOR=docker CHECK=beaker script: bundle exec rspec spec/acceptance/php_spec.rb services: docker - rvm: 2.5.3 bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1404-64 BEAKER_HYPERVISOR=docker CHECK=beaker + env: PUPPET_INSTALL_TYPE=agent BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian9-64 BEAKER_HYPERVISOR=docker CHECK=beaker script: bundle exec rspec spec/acceptance/php_spec.rb services: docker - - rvm: 2.5.3 - bundler_args: --without development release - env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1404-64 BEAKER_HYPERVISOR=docker CHECK=beaker branches: only: - master diff --git a/Gemfile b/Gemfile index 50a90301..11c85584 100644 --- a/Gemfile +++ b/Gemfile @@ -11,27 +11,9 @@ def location_for(place, fake_version = nil) end group :test do - gem 'puppetlabs_spec_helper', '>= 2.14.0', :require => false - gem 'rspec-puppet-facts', '>= 1.9.5', :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 'puppet-lint-absolute_classname-check', '>= 2.0.0', :require => false - gem 'puppet-lint-topscope-variable-check', :require => false - gem 'puppet-lint-legacy_facts-check', :require => false - gem 'puppet-lint-anchor-check', :require => false - gem 'metadata-json-lint', :require => false - gem 'redcarpet', :require => false - gem 'rubocop', '~> 0.49.1', :require => false - gem 'rubocop-rspec', '~> 1.15.0', :require => false - gem 'mocha', '~> 1.4.0', :require => false - gem 'coveralls', :require => false - gem 'simplecov-console', :require => false - gem 'parallel_tests', :require => false + gem 'voxpupuli-test', '>= 1.0.0', :require => false + gem 'coveralls', :require => false + gem 'simplecov-console', :require => false end group :development do @@ -62,6 +44,7 @@ group :system_tests do gem 'rbnacl', '>= 4', :require => false gem 'rbnacl-libsodium', :require => false gem 'bcrypt_pbkdf', :require => false + gem 'ed25519', :require => false end group :release do diff --git a/Rakefile b/Rakefile index c0f2d37d..b450fe7b 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,4 @@ -require 'puppetlabs_spec_helper/rake_tasks' +require 'voxpupuli/test/rake' # load optional tasks for releases # only available if gem group releases is installed @@ -7,37 +7,6 @@ begin rescue LoadError end -PuppetLint.configuration.log_format = '%{path}:%{line}:%{check}:%{KIND}:%{message}' - -desc 'Auto-correct puppet-lint offenses' -task 'lint:auto_correct' do - Rake::Task[:lint_fix].invoke -end - -desc 'Run acceptance tests' -RSpec::Core::RakeTask.new(:acceptance) do |t| - t.pattern = 'spec/acceptance' -end - -desc 'Run tests' -task test: [:release_checks] - -namespace :check do - desc 'Check for trailing whitespace' - task :trailing_whitespace do - Dir.glob('**/*.md', File::FNM_DOTMATCH).sort.each do |filename| - next if filename =~ %r{^((modules|acceptance|\.?vendor|spec/fixtures|pkg)/|REFERENCE.md)} - File.foreach(filename).each_with_index do |line, index| - if line =~ %r{\s\n$} - puts "#{filename} has trailing whitespace on line #{index + 1}" - exit 1 - end - end - end - end -end -Rake::Task[:release_checks].enhance ['check:trailing_whitespace'] - desc "Run main 'test' task and report merged results to coveralls" task test_with_coveralls: [:test] do if Dir.exist?(File.expand_path('../lib', __FILE__)) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 93f417a1..b2b27045 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,19 +1,12 @@ # 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' -require 'bundler' -include RspecPuppetFacts +# puppetlabs_spec_helper will set up coverage if the env variable is set. +# We want to do this if lib exists and it hasn't been explicitly set. +ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../../lib', __FILE__)) -if ENV['DEBUG'] - Puppet::Util::Log.level = :debug - Puppet::Util::Log.newdestination(:console) -end +require 'voxpupuli/test/spec_helper' if File.exist?(File.join(__dir__, 'default_module_facts.yml')) facts = YAML.load(File.read(File.join(__dir__, 'default_module_facts.yml'))) @@ -23,39 +16,3 @@ end end end - -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' - add_filter Bundler.configured_bundle_path.path - end -end - -RSpec.configure do |c| - # getting the correct facter version is tricky. We use facterdb as a source to mock facts - # see https://github.com/camptocamp/facterdb - # people might provide a specific facter version. In that case we use it. - # Otherwise we need to match the correct facter version to the used puppet version. - # as of 2019-10-31, puppet 5 ships facter 3.11 and puppet 6 ships facter 3.14 - # https://puppet.com/docs/puppet/5.5/about_agent.html - c.default_facter_version = if ENV['FACTERDB_FACTS_VERSION'] - ENV['FACTERDB_FACTS_VERSION'] - else - Gem::Dependency.new('', ENV['PUPPET_VERSION']).match?('', '5') ? '3.11.0' : '3.14.0' - end - - # Coverage generation - c.after(:suite) do - RSpec::Puppet::Coverage.report! - end -end From b1bb3433a337ad2026a2bb3eb33999b0c01ccc15 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 4 Apr 2020 15:37:15 +0200 Subject: [PATCH 6/9] puppet-lint: fix topscope vars --- manifests/fpm.pp | 2 +- manifests/global.pp | 2 +- manifests/init.pp | 2 +- manifests/pear.pp | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifests/fpm.pp b/manifests/fpm.pp index f6b57f0c..d14c3696 100644 --- a/manifests/fpm.pp +++ b/manifests/fpm.pp @@ -114,7 +114,7 @@ else { $fpm_override = "reload signal USR2\nmanual" } - file { "/etc/init/${::php::fpm::service::service_name}.override": + file { "/etc/init/${php::fpm::service::service_name}.override": content => $fpm_override, before => Package[$real_package], } diff --git a/manifests/global.pp b/manifests/global.pp index d5237e38..bc28e26d 100644 --- a/manifests/global.pp +++ b/manifests/global.pp @@ -21,7 +21,7 @@ # No deep merging required since the settings we have are the global settings. $real_settings = $settings - ::php::config { 'global': + php::config { 'global': file => $inifile, config => $real_settings, } diff --git a/manifests/init.pp b/manifests/init.pp index 481f453e..e7662c31 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -159,7 +159,7 @@ String $log_group = $php::params::fpm_group, ) inherits php::params { - $real_fpm_package = pick($fpm_package, "${package_prefix}${::php::params::fpm_package_suffix}") + $real_fpm_package = pick($fpm_package, "${package_prefix}${php::params::fpm_package_suffix}") $real_settings = $settings $real_extensions = $extensions diff --git a/manifests/pear.pp b/manifests/pear.pp index dec0acc5..cf51b4b8 100644 --- a/manifests/pear.pp +++ b/manifests/pear.pp @@ -24,14 +24,14 @@ # On Amazon Linux the package name is also just 'php-pear'. # This would normally not be problematic but if you specify a # package_prefix other than 'php' then it will fail. - $package_name = "php-${::php::params::pear_package_suffix}" + $package_name = "php-${php::params::pear_package_suffix}" } else { case $facts['os']['family'] { 'Debian': { # Debian is a litte stupid: The pear package is called 'php-pear' # even though others are called 'php5-fpm' or 'php5-dev' - $package_name = "php-${::php::params::pear_package_suffix}" + $package_name = "php-${php::params::pear_package_suffix}" } 'FreeBSD': { # On FreeBSD the package name is just 'pear'. @@ -39,7 +39,7 @@ } default: { # This is the default for all other architectures - $package_name = "${::php::package_prefix}${::php::params::pear_package_suffix}" + $package_name = "${php::package_prefix}${php::params::pear_package_suffix}" } } } From 5be38329247ece0bc166307c30a10a77facce2e0 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 4 Apr 2020 15:38:30 +0200 Subject: [PATCH 7/9] puppet-lint: remove anchors --- manifests/init.pp | 56 +++++++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index e7662c31..09839511 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -170,16 +170,15 @@ $final_cli_settings = $real_settings + $cli_settings if $manage_repos { - class { 'php::repo': } - -> Anchor['php::begin'] + contain php::repo } - anchor { 'php::begin': } - -> class { 'php::packages': } + class { 'php::packages': } -> class { 'php::cli': settings => $final_cli_settings, } - -> anchor { 'php::end': } + contain php::packages + contain php::cli # Configure global PHP settings in php.ini if $facts['os']['family'] != 'Debian' { @@ -187,7 +186,7 @@ -> class {'php::global': settings => $real_settings, } - -> Anchor['php::end'] + contain php::global } if $fpm { contain 'php::fpm' } @@ -197,48 +196,37 @@ fail('Enabling both cli and embedded sapis is not currently supported') } - Anchor['php::begin'] - -> class { 'php::embedded': - settings => $real_settings, - } - -> Anchor['php::end'] + class { 'php::embedded': + settings => $real_settings, + } + contain php::embedded } if $dev { - Anchor['php::begin'] - -> class { 'php::dev': } - -> Anchor['php::end'] + contain php::dev } if $composer { - Anchor['php::begin'] - -> class { 'php::composer': - proxy_type => $proxy_type, - proxy_server => $proxy_server, - } - -> Anchor['php::end'] + class { 'php::composer': + proxy_type => $proxy_type, + proxy_server => $proxy_server, + } } if $pear { - Anchor['php::begin'] - -> class { 'php::pear': - ensure => $pear_ensure, - } - -> Anchor['php::end'] + class { 'php::pear': + ensure => $pear_ensure, + } } if $phpunit { - Anchor['php::begin'] - -> class { 'php::phpunit': } - -> Anchor['php::end'] + contain php::phpunit } if $apache_config { - Anchor['php::begin'] - -> class { 'php::apache_config': - settings => $real_settings, - } - -> Anchor['php::end'] + class { 'php::apache_config': + settings => $real_settings, + } + contain php::apache_config } create_resources('php::extension', $real_extensions, { require => Class['php::cli'], - before => Anchor['php::end'] }) # On FreeBSD purge the system-wide extensions.ini. It is going From 6295c99d8f9285d6d792505f0c4f28de7c54398c Mon Sep 17 00:00:00 2001 From: Dennis Hoppe Date: Wed, 8 Apr 2020 12:44:05 +0200 Subject: [PATCH 8/9] Rewrite tests to use rspec-mocks --- spec/unit/provider/package/pear_spec.rb | 42 ++++++++++++------------- spec/unit/provider/package/pecl_spec.rb | 22 ++++++------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/spec/unit/provider/package/pear_spec.rb b/spec/unit/provider/package/pear_spec.rb index fc36a095..cdc17ccb 100644 --- a/spec/unit/provider/package/pear_spec.rb +++ b/spec/unit/provider/package/pear_spec.rb @@ -12,15 +12,15 @@ end before do - described_class.stubs(:command).with(:pear).returns '/fake/pear' + allow(described_class).to receive(:command).with(:pear).and_return '/fake/pear' resource.provider = provider end describe '.instances' do it 'returns an array of installed packages' do - described_class.expects(:pear). + allow(described_class).to receive(:pear). with('list', '-a'). - returns File.read(my_fixture('list_a')) + and_return File.read(my_fixture('list_a')) expect(described_class.instances.map(&:properties)).to eq [ { name: 'Archive_Tar', vendor: 'pear.php.net', ensure: '1.4.0', provider: :pear }, @@ -33,31 +33,31 @@ end it 'ignores malformed lines' do - described_class.expects(:pear). + allow(described_class).to receive(:pear). with('list', '-a'). - returns 'aaa2.1' - Puppet.expects(:warning).with('Could not match aaa2.1') + and_return 'aaa2.1' + allow(Puppet).to receive(:warning).with('Could not match aaa2.1') expect(described_class.instances).to eq [] end end describe '#install' do it 'installs a package' do - described_class.expects(:pear). + allow(described_class).to receive(:pear). with('-D', 'auto_discover=1', 'upgrade', '--alldeps', 'dummy') provider.install end it 'installs a specific version' do resource[:ensure] = '0.2' - described_class.expects(:pear). + allow(described_class).to receive(:pear). with('-D', 'auto_discover=1', 'upgrade', '--alldeps', '-f', 'dummy-0.2') provider.install end it 'installs from a specific source' do resource[:source] = 'pear.php.net/dummy' - described_class.expects(:pear). + allow(described_class).to receive(:pear). with('-D', 'auto_discover=1', 'upgrade', '--alldeps', 'pear.php.net/dummy') provider.install end @@ -65,14 +65,14 @@ it 'installs a specific version from a specific source' do resource[:ensure] = '0.2' resource[:source] = 'pear.php.net/dummy' - described_class.expects(:pear). + allow(described_class).to receive(:pear). with('-D', 'auto_discover=1', 'upgrade', '--alldeps', '-f', 'pear.php.net/dummy-0.2') provider.install end it 'uses the specified responsefile' do resource[:responsefile] = '/fake/pearresponse' - Puppet::Util::Execution.expects(:execute). + allow(Puppet::Util::Execution).to receive(:execute). with( ['/fake/pear', '-D', 'auto_discover=1', 'upgrade', '--alldeps', 'dummy'], stdinfile: resource[:responsefile] @@ -82,7 +82,7 @@ it 'accepts install_options' do resource[:install_options] = ['--onlyreqdeps'] - described_class.expects(:pear). + allow(described_class).to receive(:pear). with('-D', 'auto_discover=1', 'upgrade', '--onlyreqdeps', 'dummy') provider.install end @@ -90,9 +90,9 @@ describe '#query' do it 'queries information about one package' do - described_class.expects(:pear). + allow(described_class).to receive(:pear). with('list', '-a'). - returns File.read(my_fixture('list_a')) + and_return File.read(my_fixture('list_a')) resource[:name] = 'pear' expect(provider.query).to eq( @@ -103,9 +103,9 @@ describe '#latest' do it 'fetches the latest version available' do - described_class.expects(:pear). + allow(described_class).to receive(:pear). with('remote-info', 'Benchmark'). - returns File.read(my_fixture('remote-info_benchmark')) + and_return File.read(my_fixture('remote-info_benchmark')) resource[:name] = 'Benchmark' expect(provider.latest).to eq '1.2.9' @@ -114,16 +114,16 @@ describe '#uninstall' do it 'uninstalls a package' do - described_class.expects(:pear). + allow(described_class).to receive(:pear). with('uninstall', resource[:name]). - returns('uninstall ok') + and_return('uninstall ok') provider.uninstall end it 'raises an error otherwise' do - described_class.expects(:pear). + allow(described_class).to receive(:pear). with('uninstall', resource[:name]). - returns('unexpected output') + and_return('unexpected output') expect { provider.uninstall }.to raise_error(Puppet::Error) end end @@ -132,7 +132,7 @@ it 'ignores the resource version' do resource[:ensure] = '2.0' - described_class.expects(:pear). + allow(described_class).to receive(:pear). with('-D', 'auto_discover=1', 'upgrade', '--alldeps', 'dummy') provider.update end diff --git a/spec/unit/provider/package/pecl_spec.rb b/spec/unit/provider/package/pecl_spec.rb index ae2f15d1..1233a65a 100644 --- a/spec/unit/provider/package/pecl_spec.rb +++ b/spec/unit/provider/package/pecl_spec.rb @@ -14,14 +14,14 @@ end before do - parent_class.stubs(:command).with(:pear).returns '/fake/pear' + allow(parent_class).to receive(:command).with(:pear).and_return '/fake/pear' end describe '.instances' do it 'returns pecl installed packages via pear' do - parent_class.expects(:pear). + allow(parent_class).to receive(:pear). with('list', '-a'). - returns File.read(fixtures('unit/provider/package/pear/list_a')) + and_return File.read(fixtures('unit/provider/package/pear/list_a')) expect(described_class.instances.map(&:properties)).to eq [ { ensure: '1.13.5', name: 'zip', vendor: 'pecl.php.net', provider: :pecl } @@ -31,16 +31,16 @@ describe '#install' do it 'installs with pear' do - parent_class.expects(:pear) + allow(parent_class).to receive(:pear) provider.install end end describe '#query' do it 'queries pecl package info via pear' do - parent_class.expects(:pear). + allow(parent_class).to receive(:pear). with('list', '-a'). - returns File.read(fixtures('unit/provider/package/pear/list_a')) + and_return File.read(fixtures('unit/provider/package/pear/list_a')) resource[:name] = 'zip' expect(provider.query).to eq(ensure: '1.13.5', name: 'zip', vendor: 'pecl.php.net', provider: :pecl) @@ -49,9 +49,9 @@ describe '#latest' do it 'fetches the latest version available via pear' do - parent_class.expects(:pear). + allow(parent_class).to receive(:pear). with('remote-info', 'pecl.php.net/zip'). - returns File.read(fixtures('unit/provider/package/pear/remote-info_zip')) + and_return File.read(fixtures('unit/provider/package/pear/remote-info_zip')) resource[:name] = 'zip' expect(provider.latest).to eq '1.13.5' @@ -60,8 +60,8 @@ describe '#uninstall' do it 'uninstalls a package via pear' do - parent_class.expects(:pear). - returns('uninstall ok') + allow(parent_class).to receive(:pear). + and_return('uninstall ok') provider.uninstall end end @@ -70,7 +70,7 @@ it 'updates to latest version via pear' do resource[:ensure] = '2.0' - parent_class.expects(:pear) + allow(parent_class).to receive(:pear) provider.update end end From 87aad937b0b5aaa05dd85bd074af482d8a04e137 Mon Sep 17 00:00:00 2001 From: Dennis Hoppe Date: Wed, 8 Apr 2020 13:05:34 +0200 Subject: [PATCH 9/9] Remove code from no longer supported distributions --- spec/acceptance/php_spec.rb | 24 ------------------------ spec/classes/php_fpm_service_spec.rb | 4 ---- spec/classes/php_fpm_spec.rb | 8 -------- 3 files changed, 36 deletions(-) diff --git a/spec/acceptance/php_spec.rb b/spec/acceptance/php_spec.rb index 01ab0a5c..95427df8 100644 --- a/spec/acceptance/php_spec.rb +++ b/spec/acceptance/php_spec.rb @@ -14,8 +14,6 @@ packagename = 'php7.2-fpm' when %r{ubuntu-16.04} packagename = 'php7.0-fpm' - when %r{ubuntu-14.04} - packagename = 'php5-fpm' when %r{el} packagename = 'php-fpm' when %r{debian-8} @@ -65,26 +63,6 @@ apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end - when %r{ubuntu-14.04} - it 'works with defaults' do - pp = <<-EOS - class{'php': - extensions => { - 'mysql' => {}, - 'gd' => {}, - 'net-url' => { - package_prefix => 'php-', - settings => { - extension => undef - }, - } - } - } - EOS - # Run it twice and test for idempotency - apply_manifest(pp, catch_failures: true) - apply_manifest(pp, catch_changes: true) - end else it 'works with defaults' do pp = <<-EOS @@ -106,8 +84,6 @@ packagename = 'php7.2-fpm' when %r{ubuntu-16.04} packagename = 'php7.0-fpm' - when %r{ubuntu-14.04} - packagename = 'php5-fpm' when %r{el} packagename = 'php-fpm' when %r{debian-8} diff --git a/spec/classes/php_fpm_service_spec.rb b/spec/classes/php_fpm_service_spec.rb index 6056f409..5e15a836 100644 --- a/spec/classes/php_fpm_service_spec.rb +++ b/spec/classes/php_fpm_service_spec.rb @@ -14,10 +14,6 @@ case facts[:osfamily] when 'Debian' case facts[:operatingsystemrelease] - when '12.04' - it { is_expected.to contain_service('php5-fpm').with_ensure('running').without_restart } - when '14.04' - it { is_expected.to contain_service('php5-fpm').with_restart('service php5-fpm reload').with_ensure('running') } when '16.04' it { is_expected.to contain_service('php7.0-fpm').with_ensure('running') } end diff --git a/spec/classes/php_fpm_spec.rb b/spec/classes/php_fpm_spec.rb index da3f0242..afe1c595 100644 --- a/spec/classes/php_fpm_spec.rb +++ b/spec/classes/php_fpm_spec.rb @@ -13,14 +13,6 @@ case facts[:osfamily] when 'Debian' case facts[:operatingsystemrelease] - when '14.04' - it { is_expected.to contain_file('/etc/init/php5-fpm.override').with_content('reload signal USR2') } - it { is_expected.to contain_package('php5-fpm').with_ensure('present') } - it { is_expected.to contain_service('php5-fpm').with_ensure('running') } - when '12.02' - it { is_expected.to contain_file('/etc/init/php5-fpm.override').with_content("reload signal USR2\nmanual") } - it { is_expected.to contain_package('php5-fpm').with_ensure('present') } - it { is_expected.to contain_service('php5-fpm').with_ensure('running') } when '16.04' it { is_expected.to contain_package('php7.0-fpm').with_ensure('present') } it { is_expected.to contain_service('php7.0-fpm').with_ensure('running') }