diff --git a/.gitignore b/.gitignore index 650022e..2767022 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ /convert_report.txt /update_report.txt .DS_Store +.project +.envrc +/inventory.yaml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index ea59806..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,42 +0,0 @@ ---- -stages: - - syntax - - unit - -cache: - paths: - - vendor/bundle - -before_script: - - bundle -v - - rm Gemfile.lock || true - - gem update --system $RUBYGEMS_VERSION - - gem --version - - bundle -v - - bundle install --without system_tests --path vendor/bundle --jobs $(nproc) - -parallel_spec-Ruby 2.1.9-Puppet ~> 4.0: - stage: unit - image: ruby:2.1.9 - script: - - bundle exec rake parallel_spec - variables: - PUPPET_GEM_VERSION: '~> 4.0' - RUBYGEMS_VERSION: '2.7.8' - -syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop-Ruby 2.4.4-Puppet ~> 5.5: - stage: syntax - image: ruby:2.4.4 - script: - - bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop - variables: - PUPPET_GEM_VERSION: '~> 5.5' - -parallel_spec-Ruby 2.4.4-Puppet ~> 5.5: - stage: unit - image: ruby:2.4.4 - script: - - bundle exec rake parallel_spec - variables: - PUPPET_GEM_VERSION: '~> 5.5' - diff --git a/.pdkignore b/.pdkignore index b713b3b..e6215cd 100644 --- a/.pdkignore +++ b/.pdkignore @@ -22,6 +22,9 @@ /convert_report.txt /update_report.txt .DS_Store +.project +.envrc +/inventory.yaml /appveyor.yml /.fixtures.yml /Gemfile @@ -30,8 +33,10 @@ /.gitlab-ci.yml /.pdkignore /Rakefile +/rakelib/ /.rspec /.rubocop.yml /.travis.yml /.yardopts /spec/ +/.vscode/ diff --git a/.project b/.project deleted file mode 100644 index 64e3276..0000000 --- a/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - edestecd-mariadb - - - - - - com.puppetlabs.geppetto.pp.dsl.ui.modulefileBuilder - - - - - org.eclipse.xtext.ui.shared.xtextBuilder - - - - - - com.puppetlabs.geppetto.pp.dsl.ui.puppetNature - org.eclipse.xtext.ui.shared.xtextNature - - diff --git a/.rubocop.yml b/.rubocop.yml index f5a6c2a..5307849 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,7 @@ --- -require: rubocop-rspec +require: +- rubocop-rspec +- rubocop-i18n AllCops: DisplayCopNames: true TargetRubyVersion: '2.1' @@ -19,10 +21,13 @@ AllCops: Metrics/LineLength: Description: People have wide screens, use them. Max: 200 +GetText: + Enabled: false GetText/DecorateString: Description: We don't want to decorate test output. Exclude: - - spec/* + - spec/**/* + Enabled: false RSpec/BeforeAfterAll: Description: Beware of using after(:all) as it may cause state to leak between tests. A necessary evil in acceptance testing. @@ -35,6 +40,10 @@ Style/BlockDelimiters: Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to be consistent then. EnforcedStyle: braces_for_chaining +Style/BracesAroundHashParameters: + Description: Braces are required by Ruby 2.7. Cop removed from RuboCop v0.80.0. + See https://github.com/rubocop-hq/rubocop/pull/7643 + Enabled: true Style/ClassAndModuleChildren: Description: Compact style reduces the required amount of indentation. EnforcedStyle: compact @@ -84,6 +93,12 @@ Style/MethodCalledOnDoEndBlock: Enabled: true Style/StringMethods: Enabled: true +GetText/DecorateFunctionMessage: + Enabled: false +GetText/DecorateStringFormattingUsingInterpolation: + Enabled: false +GetText/DecorateStringFormattingUsingPercent: + Enabled: false Layout/EndOfLine: Enabled: false Layout/IndentHeredoc: diff --git a/.sync.yml b/.sync.yml index 20318b9..0c7e451 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,22 +1,16 @@ --- +.gitlab-ci.yml: + delete: true +appveyor.yml: + delete: true + .travis.yml: - includes: - - env: PUPPET_GEM_VERSION="~> 5.0" CHECK=build DEPLOY_TO_FORGE=yes - branches: - - /^\d/ - deploy: true user: edestecd secure: "iz5AkBn6RYnD5J4PAFKz0AkY79LKjH5wPpw7jSoMrfX9nw8yPybiZnuemJJFEIREO7wZoaCt09AvJY2X2QgDCqtoZo0QlV6F9SMLlX2SqZ/KiuoqArh/E64Lc0fGv4onFXV2c56KCbEwaih0MKWbvYqgHL8CmR6be73e/zwAEPJArpmwa7Yzj/ekjy0PcEbBQCm7KSocQy7rRopB/1xuwUDufvB1fA12Q3rdxQoXdMS7pu/I+s9qQ13fPC0/XctHMgfteLNxYoBvmIwfotGPWun6e3ZOH+zat2uyzi/yI/cerEhPMkP8Z8JIoCxfEXbdOUEWXcjHvPCcTkFLkqX/u26qEBxOwpNb6LshCvOdIrr0utDBBVFZ6+WLE7W7NFcjWfFeYmiD6drH66vZV+lumUhYvi19WKMsa3y8KMkz1fqnDecuatJ1LxSFH/eCG/v6d7brGh4A5A3a7XhUa1KSnwXe9HHOflmUEyckY1ile7fOC0b9n0tuTclzDNIxoETHX6KWSS6xVfiOthXb/8uqzrVZBrokYumoilLHIOTwka9P2oyKkbZ2dfQDmwJuxan53JFbCIyBsJAj2goEGWXVDH4o6HgGv040FYF3FgZozdWvXNvaxh1NUVdh9qdt3D5EgF3tmqS43H4nrli9uLOe7FNj5+itKoqva5O8ie8AYiE=" -# .rubocop.yml: -# include_todos: true - -mock_with: ':rspec' - Gemfile: required: ':development': - - gem: puppet-blacksmith - gem: travis ':puppet_lint': - gem: puppet-lint-absolute_classname-check @@ -40,3 +34,6 @@ Gemfile: - gem: puppet-lint-unquoted_string-check - gem: puppet-lint-variable_contains_upcase - gem: puppet-lint-version_comparison-check + +spec/spec_helper.rb: + mock_with: ':rspec' diff --git a/.travis.yml b/.travis.yml index 6c639f5..5edbd8a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,43 +1,55 @@ --- -dist: trusty +os: linux +dist: xenial language: ruby cache: bundler before_install: - bundle -v - rm -f Gemfile.lock - - gem update --system $RUBYGEMS_VERSION + - "# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner" + - "# See https://github.com/puppetlabs/pdk-templates/commit/705154d5c437796b821691b707156e1b056d244f for an example of how this was used" + - "# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set" + - '[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION' - gem --version - bundle -v script: - 'bundle exec rake $CHECK' bundler_args: --without system_tests rvm: - - 2.5.1 -env: - global: - - BEAKER_PUPPET_COLLECTION=puppet6 PUPPET_GEM_VERSION="~> 6.0" -matrix: + - 2.5.7 +stages: + - static + - spec + - acceptance + - + if: tag =~ ^v\d + name: deploy +jobs: fast_finish: true include: - - env: CHECK="syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop" - - - env: CHECK=parallel_spec + env: CHECK="check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint" + stage: static - env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec - rvm: 2.4.4 + rvm: 2.4.5 + stage: spec + - + env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec + rvm: 2.5.7 + stage: spec - - env: PUPPET_GEM_VERSION="~> 5.0" CHECK=build DEPLOY_TO_FORGE=yes + env: DEPLOY_TO_FORGE=yes + stage: deploy branches: only: - master - /^v\d/ - - /^\d/ notifications: email: false deploy: provider: puppetforge - user: edestecd + username: edestecd password: secure: "iz5AkBn6RYnD5J4PAFKz0AkY79LKjH5wPpw7jSoMrfX9nw8yPybiZnuemJJFEIREO7wZoaCt09AvJY2X2QgDCqtoZo0QlV6F9SMLlX2SqZ/KiuoqArh/E64Lc0fGv4onFXV2c56KCbEwaih0MKWbvYqgHL8CmR6be73e/zwAEPJArpmwa7Yzj/ekjy0PcEbBQCm7KSocQy7rRopB/1xuwUDufvB1fA12Q3rdxQoXdMS7pu/I+s9qQ13fPC0/XctHMgfteLNxYoBvmIwfotGPWun6e3ZOH+zat2uyzi/yI/cerEhPMkP8Z8JIoCxfEXbdOUEWXcjHvPCcTkFLkqX/u26qEBxOwpNb6LshCvOdIrr0utDBBVFZ6+WLE7W7NFcjWfFeYmiD6drH66vZV+lumUhYvi19WKMsa3y8KMkz1fqnDecuatJ1LxSFH/eCG/v6d7brGh4A5A3a7XhUa1KSnwXe9HHOflmUEyckY1ile7fOC0b9n0tuTclzDNIxoETHX6KWSS6xVfiOthXb/8uqzrVZBrokYumoilLHIOTwka9P2oyKkbZ2dfQDmwJuxan53JFbCIyBsJAj2goEGWXVDH4o6HgGv040FYF3FgZozdWvXNvaxh1NUVdh9qdt3D5EgF3tmqS43H4nrli9uLOe7FNj5+itKoqva5O8ie8AYiE=" on: diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..2f1e4f7 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "puppet.puppet-vscode", + "rebornix.Ruby" + ] +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 5635108..4f6ed91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,10 @@ All notable changes to this project will be documented in this file. +## Next (2.1.2) Chris Edester +* Update PDK template version to 1.18.1 + ## 2020-08-26 (2.1.1) Brad Koby -* Update PDK template version * Increase stdlib dependency max version * Increase puppet max version diff --git a/Gemfile b/Gemfile index 91301c2..b7c6790 100644 --- a/Gemfile +++ b/Gemfile @@ -17,18 +17,18 @@ ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments minor_version = ruby_version_segments[0..1].join('.') group :development do - gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') - gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') - gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') - gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') - gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby] - 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", require: false - gem "travis", require: false + gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') + gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') + gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') + gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') + gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "puppet-module-posix-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby] + gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby] + gem "puppet-module-win-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "puppet-module-win-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "travis", require: false end group :puppet_lint do gem "puppet-lint-absolute_classname-check", require: false diff --git a/Rakefile b/Rakefile index a6b14c5..0a5093b 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,6 @@ +# frozen_string_literal: true + +require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? 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? @@ -14,15 +17,24 @@ 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? + + returnVal = nil + returnVal ||= begin + metadata_source = JSON.load(File.read('metadata.json'))['source'] + metadata_source_match = metadata_source && metadata_source.match(%r{.*\/([^\/]*?)(?:\.git)?\Z}) + + metadata_source_match && metadata_source_match[1] + end + + raise "unable to find the changelog_project in .sync.yml or calculate it from the source 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'] + returnVal = "v%s" % 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 @@ -40,7 +52,7 @@ if Bundler.rubygems.find_name('github_changelog_generator').any? 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.merge_prefix = "### UNCATEGORIZED PRS; LABEL THEM ON GITHUB" config.configure_sections = { "Changed" => { "prefix" => "### Changed", @@ -48,11 +60,11 @@ if Bundler.rubygems.find_name('github_changelog_generator').any? }, "Added" => { "prefix" => "### Added", - "labels" => ["feature", "enhancement"], + "labels" => ["enhancement", "feature"], }, "Fixed" => { "prefix" => "### Fixed", - "labels" => ["bugfix"], + "labels" => ["bug", "documentation", "bugfix"], }, } end @@ -60,16 +72,15 @@ else desc 'Generate a Changelog from GitHub' task :changelog do raise <= Gem::Version.new('2.2.2')" + version: '~> 1.15' + condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0')" EOM end end diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index e10ba3b..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,55 +0,0 @@ ---- -version: 1.1.x.{build} -branches: - only: - - master -skip_commits: - message: /^\(?doc\)?.*/ -clone_depth: 10 -init: - - SET - - 'mkdir C:\ProgramData\PuppetLabs\code && exit 0' - - 'mkdir C:\ProgramData\PuppetLabs\facter && exit 0' - - 'mkdir C:\ProgramData\PuppetLabs\hiera && exit 0' - - 'mkdir C:\ProgramData\PuppetLabs\puppet\var && exit 0' -environment: - matrix: - - - RUBY_VERSION: 24-x64 - CHECK: syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop - - - PUPPET_GEM_VERSION: ~> 5.0 - RUBY_VERSION: 24 - CHECK: parallel_spec - - - PUPPET_GEM_VERSION: ~> 5.0 - RUBY_VERSION: 24-x64 - CHECK: parallel_spec - - - PUPPET_GEM_VERSION: ~> 6.0 - RUBY_VERSION: 25 - CHECK: parallel_spec - - - PUPPET_GEM_VERSION: ~> 6.0 - RUBY_VERSION: 25-x64 - CHECK: parallel_spec -matrix: - fast_finish: true -install: - - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH% - - bundle install --jobs 4 --retry 2 --without system_tests - - type Gemfile.lock -build: off -test_script: - - bundle exec puppet -V - - ruby -v - - gem -v - - bundle -v - - bundle exec rake %CHECK% -notifications: - - provider: Email - to: - - nobody@nowhere.com - on_build_success: false - on_build_failure: false - on_build_status_changed: false diff --git a/metadata.json b/metadata.json index 0625232..d58fd69 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "edestecd-mariadb", - "version": "2.1.1", + "version": "2.1.2", "author": "Chris Edester", "summary": "Puppet Module for managing MariaDB", "license": "GPL-3.0+", @@ -70,6 +70,6 @@ ], "description": "Puppet Module to install/configure MariaDB client/cluster/server", "pdk-version": "1.18.1", - "template-url": "https://github.com/puppetlabs/pdk-templates#1.9.0", - "template-ref": "tags/1.9.0-0-g7281db5" + "template-url": "https://github.com/puppetlabs/pdk-templates#1.18.1", + "template-ref": "tags/1.18.1-0-g3d2e75c" } diff --git a/spec/default_facts.yml b/spec/default_facts.yml index ea1e480..f777abf 100644 --- a/spec/default_facts.yml +++ b/spec/default_facts.yml @@ -3,5 +3,6 @@ # Facts specified here will override the values provided by rspec-puppet-facts. --- ipaddress: "172.16.254.254" +ipaddress6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" is_pe: false macaddress: "AA:AA:AA:AA:AA:AA" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7dfbc49..b367fde 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.configure do |c| c.mock_with :rspec end @@ -23,24 +25,32 @@ next unless File.exist?(f) && File.readable?(f) && File.size?(f) begin - default_facts.merge!(YAML.safe_load(File.read(f))) + default_facts.merge!(YAML.safe_load(File.read(f), [], [], true)) rescue => e RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" end end +# read default_facts and merge them over what is provided by facterdb +default_facts.each do |fact, value| + add_custom_fact fact, value +end + RSpec.configure do |c| c.default_facts = default_facts c.before :each do # set to strictest setting for testing # by default Puppet runs at warning level Puppet.settings[:strict] = :warning + Puppet.settings[:strict_variables] = true end c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] c.after(:suite) do end end +# Ensures that a module is defined +# @param module_name Name of the module 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, false)