diff --git a/.gitignore b/.gitignore index 49bc2a4..650022e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.git/ .*.sw[op] .metadata .yardoc diff --git a/.pdkignore b/.pdkignore index 49bc2a4..650022e 100644 --- a/.pdkignore +++ b/.pdkignore @@ -1,3 +1,4 @@ +.git/ .*.sw[op] .metadata .yardoc diff --git a/.rubocop.yml b/.rubocop.yml index 573e0a4..38b9c95 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,11 +8,14 @@ AllCops: Exclude: - bin/* - ".vendor/**/*" - - Gemfile - - Rakefile + - "**/Gemfile" + - "**/Rakefile" - pkg/**/* - spec/fixtures/**/* - vendor/**/* + - "**/Puppetfile" + - "**/Vagrantfile" + - "**/Guardfile" Metrics/LineLength: Description: People have wide screens, use them. Max: 200 @@ -67,6 +70,12 @@ Style/UnneededPercentQ: Enabled: false RSpec/MessageSpies: EnforcedStyle: receive +Style/Documentation: + Exclude: + - lib/puppet/parser/functions/**/* + - spec/**/* +Style/WordArray: + EnforcedStyle: brackets Style/CollectionMethods: Enabled: true Style/MethodCalledOnDoEndBlock: @@ -75,6 +84,8 @@ Style/StringMethods: Enabled: true Layout/EndOfLine: Enabled: false +Layout/IndentHeredoc: + Enabled: false Metrics/AbcSize: Enabled: false Metrics/BlockLength: diff --git a/.sync.yml b/.sync.yml index 5f25919..1b95373 100644 --- a/.sync.yml +++ b/.sync.yml @@ -28,13 +28,15 @@ appveyor.yml: script: "\"bundle exec rake release_checks\"" docker_sets: + - set: docker/ubuntu-18.04 - set: docker/ubuntu-16.04 - set: docker/ubuntu-14.04 +# - set: docker/debian-9 - set: docker/debian-8 - set: docker/centos-7 docker_defaults: # values will replace @@SET@@ with the docker_sets' value - rvm: 2.4.1 + rvm: 2.4.4 sudo: required dist: trusty services: docker @@ -85,5 +87,7 @@ spec/acceptance/nodesets/debian-8-x64.yml: spec/acceptance/nodesets/default.yml: spec/acceptance/nodesets/docker/centos-7.yml: spec/acceptance/nodesets/docker/debian-8.yml: +spec/acceptance/nodesets/docker/debian-9.yml: spec/acceptance/nodesets/docker/ubuntu-14.04.yml: spec/acceptance/nodesets/docker/ubuntu-16.04.yml: +spec/acceptance/nodesets/docker/ubuntu-18.04.yml: diff --git a/.travis.yml b/.travis.yml index fd52d91..954c183 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,64 +7,62 @@ before_install: - bundle -v - rm -f Gemfile.lock - gem update --system - - gem update bundler - gem --version - bundle -v script: - 'bundle exec rake $CHECK' bundler_args: rvm: - - 2.4.1 + - 2.4.4 env: - - PUPPET_GEM_VERSION="~> 5.0" CHECK=spec + global: + - BEAKER_PUPPET_COLLECTION=puppet5 PUPPET_GEM_VERSION="~> 5.0" matrix: fast_finish: true include: + - + dist: trusty + env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/ubuntu-18.04 + rvm: 2.4.4 + script: bundle exec rake beaker + services: docker + sudo: required - dist: trusty env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/ubuntu-16.04 - rvm: 2.4.1 + rvm: 2.4.4 script: bundle exec rake beaker services: docker sudo: required - dist: trusty env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/ubuntu-14.04 - rvm: 2.4.1 + rvm: 2.4.4 script: bundle exec rake beaker services: docker sudo: required - dist: trusty env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/debian-8 - rvm: 2.4.1 + rvm: 2.4.4 script: bundle exec rake beaker services: docker sudo: required - dist: trusty env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/centos-7 - rvm: 2.4.1 + rvm: 2.4.4 script: bundle exec rake beaker services: docker sudo: required - - env: CHECK=rubocop - - - env: CHECK="syntax lint" - - - env: CHECK=metadata_lint - - - env: CHECK=release_checks + env: CHECK="syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop" - - env: CHECK=spec + env: CHECK=parallel_spec - - env: PUPPET_GEM_VERSION="~> 4.0" CHECK=spec + env: PUPPET_GEM_VERSION="~> 4.0" CHECK=parallel_spec rvm: 2.1.9 branches: - only: - - master - - /^v\d/ notifications: email: false deploy: diff --git a/Gemfile b/Gemfile index a7ec820..065353b 100644 --- a/Gemfile +++ b/Gemfile @@ -33,7 +33,6 @@ group :development do gem "puppet-module-posix-dev-r#{minor_version}", require: false, platforms: [:ruby] gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] gem "puppet-module-win-dev-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-blacksmith", '~> 3.4', require: false, platforms: [:ruby] end group :system_tests do gem "puppet-module-posix-system-r#{minor_version}", require: false, platforms: [:ruby] diff --git a/Rakefile b/Rakefile index fb58663..204fb18 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,75 @@ require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-syntax/tasks/puppet-syntax' require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? +require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any? + +def changelog_user + return unless Rake.application.top_level_tasks.include? "changelog" + returnVal = nil || JSON.load(File.read('metadata.json'))['author'] + raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil? + puts "GitHubChangelogGenerator user:#{returnVal}" + returnVal +end + +def changelog_project + return unless Rake.application.top_level_tasks.include? "changelog" + returnVal = nil || JSON.load(File.read('metadata.json'))['name'] + raise "unable to find the changelog_project in .sync.yml or the name in metadata.json" if returnVal.nil? + puts "GitHubChangelogGenerator project:#{returnVal}" + returnVal +end + +def changelog_future_release + return unless Rake.application.top_level_tasks.include? "changelog" + returnVal = JSON.load(File.read('metadata.json'))['version'] + raise "unable to find the future_release (version) in metadata.json" if returnVal.nil? + puts "GitHubChangelogGenerator future_release:#{returnVal}" + returnVal +end + +PuppetLint.configuration.send('disable_relative') + +if Bundler.rubygems.find_name('github_changelog_generator').any? + GitHubChangelogGenerator::RakeTask.new :changelog do |config| + raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil? + config.user = "#{changelog_user}" + config.project = "#{changelog_project}" + config.future_release = "#{changelog_future_release}" + config.exclude_labels = ['maintenance'] + config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)." + config.add_pr_wo_labels = true + config.issues = false + config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM" + config.configure_sections = { + "Changed" => { + "prefix" => "### Changed", + "labels" => ["backwards-incompatible"], + }, + "Added" => { + "prefix" => "### Added", + "labels" => ["feature", "enhancement"], + }, + "Fixed" => { + "prefix" => "### Fixed", + "labels" => ["bugfix"], + }, + } + end +else + desc 'Generate a Changelog from GitHub' + task :changelog do + raise <= Gem::Version.new('2.2.2')" +EOM + end +end -PuppetLint.configuration.send('relative') diff --git a/appveyor.yml b/appveyor.yml index 5fd5e89..14971eb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,3 +1,4 @@ +--- version: 1.1.x.{build} skip_commits: message: /^\(?doc\)?.*/ @@ -12,29 +13,32 @@ environment: matrix: - RUBY_VERSION: 24-x64 - CHECK: syntax lint - - - RUBY_VERSION: 24-x64 - CHECK: metadata_lint - - - RUBY_VERSION: 24-x64 - CHECK: rubocop + CHECK: syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop - PUPPET_GEM_VERSION: ~> 4.0 RUBY_VERSION: 21 - CHECK: spec + CHECK: parallel_spec - PUPPET_GEM_VERSION: ~> 4.0 RUBY_VERSION: 21-x64 - CHECK: spec + CHECK: parallel_spec - PUPPET_GEM_VERSION: ~> 5.0 RUBY_VERSION: 24 - CHECK: spec + CHECK: parallel_spec - PUPPET_GEM_VERSION: ~> 5.0 RUBY_VERSION: 24-x64 - CHECK: spec + CHECK: parallel_spec + - + RUBY_VERSION: 24-x64 + CHECK: syntax lint + - + RUBY_VERSION: 24-x64 + CHECK: metadata_lint + - + RUBY_VERSION: 24-x64 + CHECK: rubocop matrix: fast_finish: true install: diff --git a/metadata.json b/metadata.json index f3e245e..671cfd1 100644 --- a/metadata.json +++ b/metadata.json @@ -10,7 +10,7 @@ "dependencies": [ { "name": "puppetlabs-stdlib", - "version_requirement": ">= 4.0.0 < 5.0.0" + "version_requirement": ">= 4.0.0 < 6.0.0" }, { "name": "rehan-wget", @@ -66,7 +66,6 @@ { "operatingsystem": "Debian", "operatingsystemrelease": [ - "7", "8", "9" ] @@ -122,7 +121,7 @@ "Public Key Infrastructure", "Certificate Managment" ], - "pdk-version": "1.5.0", + "pdk-version": "1.7.0", "template-url": "file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git", - "template-ref": "1.5.0-0-gd1b3eca" + "template-ref": "1.7.0-0-g57412ed" } diff --git a/spec/acceptance/nodesets/docker/debian-9.yml b/spec/acceptance/nodesets/docker/debian-9.yml new file mode 100644 index 0000000..2fcabb5 --- /dev/null +++ b/spec/acceptance/nodesets/docker/debian-9.yml @@ -0,0 +1,11 @@ +HOSTS: + debian-9-x64: + platform: debian-9-amd64 + hypervisor: docker + image: debian:9 + docker_preserve_image: true +# docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get update && apt-get install -y net-tools wget locales strace lsof && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen' +CONFIG: + trace_limit: 200 diff --git a/spec/acceptance/nodesets/docker/ubuntu-18.04.yml b/spec/acceptance/nodesets/docker/ubuntu-18.04.yml new file mode 100644 index 0000000..ba0dafd --- /dev/null +++ b/spec/acceptance/nodesets/docker/ubuntu-18.04.yml @@ -0,0 +1,11 @@ +HOSTS: + ubuntu-1804-x64: + platform: ubuntu-18.04-amd64 + hypervisor: docker + image: ubuntu:18.04 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get update && apt-get install -y net-tools wget locales strace lsof && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen' +CONFIG: + trace_limit: 200 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e117192..5e721b7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +1,3 @@ - require 'puppetlabs_spec_helper/module_spec_helper' require 'rspec-puppet-facts' @@ -34,3 +33,12 @@ Puppet.settings[:strict] = :warning end end + +def ensure_module_defined(module_name) + module_name.split('::').reduce(Object) do |last_module, next_module| + last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module) + last_module.const_get(next_module) + end +end + +# 'spec_overrides' from sync.yml will appear below this line diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 8c51ca7..cc4d202 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -15,7 +15,7 @@ def pe_install? install_module_on(hosts) install_module_dependencies_on(hosts) -UNSUPPORTED_PLATFORMS = %w[RedHat Suse windows AIX Solaris].freeze +UNSUPPORTED_PLATFORMS = ['RedHat', 'Suse', 'windows', 'AIX', 'Solaris'].freeze DEFAULT_PASSWORD = if default[:hypervisor] == 'vagrant' 'vagrant'