From c1ffb4c5c35a362cd55757162dc93e0bcb931faa Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Wed, 1 Aug 2018 10:19:13 +0100 Subject: [PATCH] Convert to use the PDK 1.6.1 --- .gitignore | 28 +- .gitlab-ci.yml | 41 +++ .pdkignore | 24 ++ .rspec | 2 + .rubocop.yml | 694 +++++++++++++++++++++++++++++++++++++++++ .sync.yml | 3 + .travis.yml | 44 +++ .yardopts | 1 + Gemfile | 80 ++++- Gemfile.lock | 173 ++++++++-- Rakefile | 80 ++++- appveyor.yml | 52 +++ metadata.json | 27 +- spec/default_facts.yml | 8 + spec/spec_helper.rb | 46 ++- 15 files changed, 1258 insertions(+), 45 deletions(-) create mode 100644 .gitlab-ci.yml create mode 100644 .pdkignore create mode 100644 .rspec create mode 100644 .rubocop.yml create mode 100644 .sync.yml create mode 100644 .travis.yml create mode 100644 .yardopts create mode 100644 appveyor.yml create mode 100644 spec/default_facts.yml diff --git a/.gitignore b/.gitignore index 4572784..650022e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,24 @@ -spec/fixtures -vendor -.bundle -pkg +.git/ +.*.sw[op] +.metadata +.yardoc +.yardwarns +*.iml +/.bundle/ +/.idea/ +/.vagrant/ +/coverage/ +/bin/ +/doc/ +/Gemfile.local +/Gemfile.lock +/junit/ +/log/ +/pkg/ +/spec/fixtures/manifests/ +/spec/fixtures/modules/ +/tmp/ +/vendor/ +/convert_report.txt +/update_report.txt +.DS_Store diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..d651650 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,41 @@ +--- +stages: + - syntax + - unit + +cache: + paths: + - vendor/bundle + +before_script: + - bundle -v + - rm Gemfile.lock || true + - gem update --system + - gem --version + - bundle -v + - bundle install --without system_tests --path vendor/bundle --jobs $(nproc) + +parallel_spec-Ruby 2.1.9-Puppet ~> 4.0: + stage: syntax + image: ruby:2.1.9 + script: + - bundle exec rake parallel_spec + variables: + PUPPET_GEM_VERSION: '~> 4.0' + +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: syntax + image: ruby:2.4.4 + script: + - bundle exec rake parallel_spec + variables: + PUPPET_GEM_VERSION: '~> 5.5' + diff --git a/.pdkignore b/.pdkignore new file mode 100644 index 0000000..650022e --- /dev/null +++ b/.pdkignore @@ -0,0 +1,24 @@ +.git/ +.*.sw[op] +.metadata +.yardoc +.yardwarns +*.iml +/.bundle/ +/.idea/ +/.vagrant/ +/coverage/ +/bin/ +/doc/ +/Gemfile.local +/Gemfile.lock +/junit/ +/log/ +/pkg/ +/spec/fixtures/manifests/ +/spec/fixtures/modules/ +/tmp/ +/vendor/ +/convert_report.txt +/update_report.txt +.DS_Store diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..16f9cdb --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--color +--format documentation diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..d72faaa --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,694 @@ +--- +require: rubocop-rspec +AllCops: + DisplayCopNames: true + TargetRubyVersion: '2.1' + Include: + - "./**/*.rb" + Exclude: + - bin/* + - ".vendor/**/*" + - "**/Gemfile" + - "**/Rakefile" + - pkg/**/* + - spec/fixtures/**/* + - vendor/**/* + - "**/Puppetfile" + - "**/Vagrantfile" + - "**/Guardfile" +Bundler/DuplicatedGem: + Enabled: false +Bundler/OrderedGems: + Enabled: false +Layout/AccessModifierIndentation: + Enabled: false +Layout/AlignArray: + Enabled: false +Layout/AlignHash: + Enabled: false +Layout/AlignParameters: + Enabled: false +Layout/BlockEndNewline: + Enabled: false +Layout/CaseIndentation: + Enabled: false +Layout/ClosingParenthesisIndentation: + Enabled: false +Layout/CommentIndentation: + Enabled: false +Layout/DotPosition: + Enabled: false +Layout/ElseAlignment: + Enabled: false +Layout/EmptyLineAfterMagicComment: + Enabled: false +Layout/EmptyLineBetweenDefs: + Enabled: false +Layout/EmptyLines: + Enabled: false +Layout/EmptyLinesAroundAccessModifier: + Enabled: false +Layout/EmptyLinesAroundBeginBody: + Enabled: false +Layout/EmptyLinesAroundBlockBody: + Enabled: false +Layout/EmptyLinesAroundClassBody: + Enabled: false +Layout/EmptyLinesAroundExceptionHandlingKeywords: + Enabled: false +Layout/EmptyLinesAroundMethodBody: + Enabled: false +Layout/EmptyLinesAroundModuleBody: + Enabled: false +Layout/EndOfLine: + Enabled: false +Layout/ExtraSpacing: + Enabled: false +Layout/FirstParameterIndentation: + Enabled: false +Layout/IndentArray: + Enabled: false +Layout/IndentAssignment: + Enabled: false +Layout/IndentHash: + Enabled: false +Layout/IndentHeredoc: + Enabled: false +Layout/IndentationConsistency: + Enabled: false +Layout/IndentationWidth: + Enabled: false +Layout/InitialIndentation: + Enabled: false +Layout/LeadingCommentSpace: + Enabled: false +Layout/MultilineArrayBraceLayout: + Enabled: false +Layout/MultilineBlockLayout: + Enabled: false +Layout/MultilineHashBraceLayout: + Enabled: false +Layout/MultilineMethodCallBraceLayout: + Enabled: false +Layout/MultilineMethodCallIndentation: + Enabled: false +Layout/MultilineMethodDefinitionBraceLayout: + Enabled: false +Layout/MultilineOperationIndentation: + Enabled: false +Layout/RescueEnsureAlignment: + Enabled: false +Layout/SpaceAfterColon: + Enabled: false +Layout/SpaceAfterComma: + Enabled: false +Layout/SpaceAfterMethodName: + Enabled: false +Layout/SpaceAfterNot: + Enabled: false +Layout/SpaceAfterSemicolon: + Enabled: false +Layout/SpaceAroundBlockParameters: + Enabled: false +Layout/SpaceAroundEqualsInParameterDefault: + Enabled: false +Layout/SpaceAroundKeyword: + Enabled: false +Layout/SpaceAroundOperators: + Enabled: false +Layout/SpaceBeforeBlockBraces: + Enabled: false +Layout/SpaceBeforeComma: + Enabled: false +Layout/SpaceBeforeComment: + Enabled: false +Layout/SpaceBeforeFirstArg: + Enabled: false +Layout/SpaceBeforeSemicolon: + Enabled: false +Layout/SpaceInLambdaLiteral: + Enabled: false +Layout/SpaceInsideArrayPercentLiteral: + Enabled: false +Layout/SpaceInsideBlockBraces: + Enabled: false +Layout/SpaceInsideBrackets: + Enabled: false +Layout/SpaceInsideHashLiteralBraces: + Enabled: false +Layout/SpaceInsideParens: + Enabled: false +Layout/SpaceInsidePercentLiteralDelimiters: + Enabled: false +Layout/SpaceInsideRangeLiteral: + Enabled: false +Layout/SpaceInsideStringInterpolation: + Enabled: false +Layout/Tab: + Enabled: false +Layout/TrailingBlankLines: + Enabled: false +Layout/TrailingWhitespace: + Enabled: false +Lint/AmbiguousBlockAssociation: + Enabled: false +Lint/AmbiguousOperator: + Enabled: false +Lint/AmbiguousRegexpLiteral: + Enabled: false +Lint/AssignmentInCondition: + Enabled: false +Lint/BlockAlignment: + Enabled: false +Lint/CircularArgumentReference: + Enabled: false +Lint/ConditionPosition: + Enabled: false +Lint/Debugger: + Enabled: false +Lint/DefEndAlignment: + Enabled: false +Lint/DeprecatedClassMethods: + Enabled: false +Lint/DuplicateCaseCondition: + Enabled: false +Lint/DuplicateMethods: + Enabled: false +Lint/DuplicatedKey: + Enabled: false +Lint/EachWithObjectArgument: + Enabled: false +Lint/ElseLayout: + Enabled: false +Lint/EmptyEnsure: + Enabled: false +Lint/EmptyExpression: + Enabled: false +Lint/EmptyInterpolation: + Enabled: false +Lint/EmptyWhen: + Enabled: false +Lint/EndAlignment: + Enabled: false +Lint/EndInMethod: + Enabled: false +Lint/EnsureReturn: + Enabled: false +Lint/FloatOutOfRange: + Enabled: false +Lint/FormatParameterMismatch: + Enabled: false +Lint/HandleExceptions: + Enabled: false +Lint/ImplicitStringConcatenation: + Enabled: false +Lint/IneffectiveAccessModifier: + Enabled: false +Lint/InheritException: + Enabled: false +Lint/InvalidCharacterLiteral: + Enabled: false +Lint/LiteralInCondition: + Enabled: false +Lint/LiteralInInterpolation: + Enabled: false +Lint/Loop: + Enabled: false +Lint/MultipleCompare: + Enabled: false +Lint/NestedMethodDefinition: + Enabled: false +Lint/NextWithoutAccumulator: + Enabled: false +Lint/NonLocalExitFromIterator: + Enabled: false +Lint/ParenthesesAsGroupedExpression: + Enabled: false +Lint/PercentStringArray: + Enabled: false +Lint/PercentSymbolArray: + Enabled: false +Lint/RandOne: + Enabled: false +Lint/RequireParentheses: + Enabled: false +Lint/RescueException: + Enabled: false +Lint/RescueType: + Enabled: false +Lint/SafeNavigationChain: + Enabled: false +Lint/ScriptPermission: + Enabled: false +Lint/ShadowedException: + Enabled: false +Lint/ShadowingOuterLocalVariable: + Enabled: false +Lint/StringConversionInInterpolation: + Enabled: false +Lint/UnderscorePrefixedVariableName: + Enabled: false +Lint/UnifiedInteger: + Enabled: false +Lint/UnneededDisable: + Enabled: false +Lint/UnneededSplatExpansion: + Enabled: false +Lint/UnreachableCode: + Enabled: false +Lint/UnusedBlockArgument: + Enabled: false +Lint/UnusedMethodArgument: + Enabled: false +Lint/UselessAccessModifier: + Enabled: false +Lint/UselessAssignment: + Enabled: false +Lint/UselessComparison: + Enabled: false +Lint/UselessElseWithoutRescue: + Enabled: false +Lint/UselessSetterCall: + Enabled: false +Lint/Void: + Enabled: false +Metrics/AbcSize: + Enabled: false +Metrics/BlockLength: + Enabled: false +Metrics/BlockNesting: + Enabled: false +Metrics/ClassLength: + Enabled: false +Metrics/CyclomaticComplexity: + Enabled: false +Metrics/LineLength: + Enabled: false +Metrics/MethodLength: + Enabled: false +Metrics/ModuleLength: + Enabled: false +Metrics/ParameterLists: + Enabled: false +Metrics/PerceivedComplexity: + Enabled: false +Performance/Caller: + Enabled: false +Performance/CaseWhenSplat: + Enabled: false +Performance/Casecmp: + Enabled: false +Performance/CompareWithBlock: + Enabled: false +Performance/Count: + Enabled: false +Performance/Detect: + Enabled: false +Performance/DoubleStartEndWith: + Enabled: false +Performance/EndWith: + Enabled: false +Performance/FixedSize: + Enabled: false +Performance/FlatMap: + Enabled: false +Performance/HashEachMethods: + Enabled: false +Performance/LstripRstrip: + Enabled: false +Performance/RangeInclude: + Enabled: false +Performance/RedundantBlockCall: + Enabled: false +Performance/RedundantMatch: + Enabled: false +Performance/RedundantMerge: + Enabled: false +Performance/RedundantSortBy: + Enabled: false +Performance/RegexpMatch: + Enabled: false +Performance/ReverseEach: + Enabled: false +Performance/Sample: + Enabled: false +Performance/Size: + Enabled: false +Performance/StartWith: + Enabled: false +Performance/StringReplacement: + Enabled: false +Performance/TimesMap: + Enabled: false +RSpec/AnyInstance: + Enabled: false +RSpec/AroundBlock: + Enabled: false +RSpec/BeEql: + Enabled: false +RSpec/BeforeAfterAll: + Enabled: false +RSpec/DescribeClass: + Enabled: false +RSpec/DescribeMethod: + Enabled: false +RSpec/DescribeSymbol: + Enabled: false +RSpec/DescribedClass: + Enabled: false +RSpec/EmptyExampleGroup: + Enabled: false +RSpec/EmptyLineAfterFinalLet: + Enabled: false +RSpec/EmptyLineAfterSubject: + Enabled: false +RSpec/ExampleLength: + Enabled: false +RSpec/ExampleWording: + Enabled: false +RSpec/ExpectActual: + Enabled: false +RSpec/ExpectOutput: + Enabled: false +RSpec/FilePath: + Enabled: false +RSpec/Focus: + Enabled: false +RSpec/HookArgument: + Enabled: false +RSpec/ImplicitExpect: + Enabled: false +RSpec/InstanceSpy: + Enabled: false +RSpec/InstanceVariable: + Enabled: false +RSpec/ItBehavesLike: + Enabled: false +RSpec/IteratedExpectation: + Enabled: false +RSpec/LeadingSubject: + Enabled: false +RSpec/LetSetup: + Enabled: false +RSpec/MessageChain: + Enabled: false +RSpec/MessageExpectation: + Enabled: false +RSpec/MessageSpies: + Enabled: false +RSpec/MultipleDescribes: + Enabled: false +RSpec/MultipleExpectations: + Enabled: false +RSpec/NamedSubject: + Enabled: false +RSpec/NestedGroups: + Enabled: false +RSpec/NotToNot: + Enabled: false +RSpec/OverwritingSetup: + Enabled: false +RSpec/RepeatedDescription: + Enabled: false +RSpec/RepeatedExample: + Enabled: false +RSpec/ScatteredLet: + Enabled: false +RSpec/ScatteredSetup: + Enabled: false +RSpec/SharedContext: + Enabled: false +RSpec/SingleArgumentMessageChain: + Enabled: false +RSpec/SubjectStub: + Enabled: false +RSpec/VerifiedDoubles: + Enabled: false +Security/Eval: + Enabled: false +Security/JSONLoad: + Enabled: false +Security/MarshalLoad: + Enabled: false +Security/YAMLLoad: + Enabled: false +Style/AccessorMethodName: + Enabled: false +Style/Alias: + Enabled: false +Style/AndOr: + Enabled: false +Style/ArrayJoin: + Enabled: false +Style/AsciiComments: + Enabled: false +Style/AsciiIdentifiers: + Enabled: false +Style/Attr: + Enabled: false +Style/BarePercentLiterals: + Enabled: false +Style/BeginBlock: + Enabled: false +Style/BlockComments: + Enabled: false +Style/BlockDelimiters: + Enabled: false +Style/BracesAroundHashParameters: + Enabled: false +Style/CaseEquality: + Enabled: false +Style/CharacterLiteral: + Enabled: false +Style/ClassAndModuleCamelCase: + Enabled: false +Style/ClassAndModuleChildren: + Enabled: false +Style/ClassCheck: + Enabled: false +Style/ClassMethods: + Enabled: false +Style/ClassVars: + Enabled: false +Style/ColonMethodCall: + Enabled: false +Style/CommandLiteral: + Enabled: false +Style/CommentAnnotation: + Enabled: false +Style/ConditionalAssignment: + Enabled: false +Style/ConstantName: + Enabled: false +Style/DefWithParentheses: + Enabled: false +Style/Documentation: + Enabled: false +Style/DoubleNegation: + Enabled: false +Style/EachForSimpleLoop: + Enabled: false +Style/EachWithObject: + Enabled: false +Style/EmptyCaseCondition: + Enabled: false +Style/EmptyElse: + Enabled: false +Style/EmptyLiteral: + Enabled: false +Style/EmptyMethod: + Enabled: false +Style/EndBlock: + Enabled: false +Style/EvenOdd: + Enabled: false +Style/FileName: + Enabled: false +Style/FlipFlop: + Enabled: false +Style/For: + Enabled: false +Style/FormatString: + Enabled: false +Style/FormatStringToken: + Enabled: false +Style/FrozenStringLiteralComment: + Enabled: false +Style/GlobalVars: + Enabled: false +Style/GuardClause: + Enabled: false +Style/HashSyntax: + Enabled: false +Style/IdenticalConditionalBranches: + Enabled: false +Style/IfInsideElse: + Enabled: false +Style/IfUnlessModifier: + Enabled: false +Style/IfUnlessModifierOfIfUnless: + Enabled: false +Style/IfWithSemicolon: + Enabled: false +Style/InfiniteLoop: + Enabled: false +Style/InverseMethods: + Enabled: false +Style/Lambda: + Enabled: false +Style/LambdaCall: + Enabled: false +Style/LineEndConcatenation: + Enabled: false +Style/MethodCallWithoutArgsParentheses: + Enabled: false +Style/MethodDefParentheses: + Enabled: false +Style/MethodMissing: + Enabled: false +Style/MethodName: + Enabled: false +Style/MixinGrouping: + Enabled: false +Style/ModuleFunction: + Enabled: false +Style/MultilineBlockChain: + Enabled: false +Style/MultilineIfModifier: + Enabled: false +Style/MultilineIfThen: + Enabled: false +Style/MultilineMemoization: + Enabled: false +Style/MultilineTernaryOperator: + Enabled: false +Style/MultipleComparison: + Enabled: false +Style/MutableConstant: + Enabled: false +Style/NegatedIf: + Enabled: false +Style/NegatedWhile: + Enabled: false +Style/NestedModifier: + Enabled: false +Style/NestedParenthesizedCalls: + Enabled: false +Style/NestedTernaryOperator: + Enabled: false +Style/Next: + Enabled: false +Style/NilComparison: + Enabled: false +Style/NonNilCheck: + Enabled: false +Style/Not: + Enabled: false +Style/NumericLiteralPrefix: + Enabled: false +Style/NumericLiterals: + Enabled: false +Style/NumericPredicate: + Enabled: false +Style/OneLineConditional: + Enabled: false +Style/OpMethod: + Enabled: false +Style/OptionalArguments: + Enabled: false +Style/ParallelAssignment: + Enabled: false +Style/ParenthesesAroundCondition: + Enabled: false +Style/PercentLiteralDelimiters: + Enabled: false +Style/PercentQLiterals: + Enabled: false +Style/PerlBackrefs: + Enabled: false +Style/PredicateName: + Enabled: false +Style/PreferredHashMethods: + Enabled: false +Style/Proc: + Enabled: false +Style/RaiseArgs: + Enabled: false +Style/RedundantBegin: + Enabled: false +Style/RedundantException: + Enabled: false +Style/RedundantFreeze: + Enabled: false +Style/RedundantParentheses: + Enabled: false +Style/RedundantReturn: + Enabled: false +Style/RedundantSelf: + Enabled: false +Style/RegexpLiteral: + Enabled: false +Style/RescueModifier: + Enabled: false +Style/SafeNavigation: + Enabled: false +Style/SelfAssignment: + Enabled: false +Style/Semicolon: + Enabled: false +Style/SignalException: + Enabled: false +Style/SingleLineMethods: + Enabled: false +Style/SpecialGlobalVars: + Enabled: false +Style/StabbyLambdaParentheses: + Enabled: false +Style/StringLiterals: + Enabled: false +Style/StringLiteralsInInterpolation: + Enabled: false +Style/StructInheritance: + Enabled: false +Style/SymbolArray: + Enabled: false +Style/SymbolLiteral: + Enabled: false +Style/SymbolProc: + Enabled: false +Style/TernaryParentheses: + Enabled: false +Style/TrailingCommaInArguments: + Enabled: false +Style/TrailingCommaInLiteral: + Enabled: false +Style/TrailingUnderscoreVariable: + Enabled: false +Style/TrivialAccessors: + Enabled: false +Style/UnlessElse: + Enabled: false +Style/UnneededCapitalW: + Enabled: false +Style/UnneededInterpolation: + Enabled: false +Style/UnneededPercentQ: + Enabled: false +Style/VariableInterpolation: + Enabled: false +Style/VariableName: + Enabled: false +Style/VariableNumber: + Enabled: false +Style/WhenThen: + Enabled: false +Style/WhileUntilDo: + Enabled: false +Style/WhileUntilModifier: + Enabled: false +Style/WordArray: + Enabled: false +Style/YodaCondition: + Enabled: false +Style/ZeroLengthPredicate: + Enabled: false diff --git a/.sync.yml b/.sync.yml new file mode 100644 index 0000000..299d038 --- /dev/null +++ b/.sync.yml @@ -0,0 +1,3 @@ +.rubocop.yml: + selected_profile: off + diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..5ef0f6f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,44 @@ +--- +sudo: false +dist: trusty +language: ruby +cache: bundler +before_install: + - bundle -v + - rm -f Gemfile.lock + - gem update --system + - gem --version + - bundle -v +script: + - 'bundle exec rake $CHECK' +bundler_args: --without system_tests +rvm: + - 2.4.4 +env: + global: + - BEAKER_PUPPET_COLLECTION=puppet5 PUPPET_GEM_VERSION="~> 5.0" +matrix: + 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: PUPPET_GEM_VERSION="~> 4.0" CHECK=parallel_spec + rvm: 2.1.9 +branches: + only: + - master + - /^v\d/ +notifications: + email: false +deploy: + provider: puppetforge + user: puppet + password: + secure: "" + on: + tags: true + all_branches: true + condition: "$DEPLOY_TO_FORGE = yes" diff --git a/.yardopts b/.yardopts new file mode 100644 index 0000000..29c933b --- /dev/null +++ b/.yardopts @@ -0,0 +1 @@ +--markup markdown diff --git a/Gemfile b/Gemfile index 88e5684..5cda86e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,78 @@ -source "https://rubygems.org" +source ENV['GEM_SOURCE'] || 'https://rubygems.org' -group :development, :test do - gem "puppetlabs_spec_helper" - gem "puppet" +def location_for(place_or_version, fake_version = nil) + if place_or_version =~ %r{\A(git[:@][^#]*)#(.*)} + [fake_version, { git: Regexp.last_match(1), branch: Regexp.last_match(2), require: false }].compact + elsif place_or_version =~ %r{\Afile:\/\/(.*)} + ['>= 0', { path: File.expand_path(Regexp.last_match(1)), require: false }] + else + [place_or_version, { require: false }] + end end + +def gem_type(place_or_version) + if place_or_version =~ %r{\Agit[:@]} + :git + elsif !place_or_version.nil? && place_or_version.start_with?('file:') + :file + else + :gem + end +end + +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::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.4.4') + 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] +end + +puppet_version = ENV['PUPPET_GEM_VERSION'] +puppet_type = gem_type(puppet_version) +facter_version = ENV['FACTER_GEM_VERSION'] +hiera_version = ENV['HIERA_GEM_VERSION'] + +gems = {} + +gems['puppet'] = location_for(puppet_version) + +# If facter or hiera versions have been specified via the environment +# variables + +gems['facter'] = location_for(facter_version) if facter_version +gems['hiera'] = location_for(hiera_version) if hiera_version + +if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)} + # If we're using a Puppet gem on Windows which handles its own win32-xxx gem + # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445). + gems['win32-dir'] = ['<= 0.4.9', require: false] + gems['win32-eventlog'] = ['<= 0.6.5', require: false] + gems['win32-process'] = ['<= 0.7.5', require: false] + gems['win32-security'] = ['<= 0.2.5', require: false] + gems['win32-service'] = ['0.8.8', require: false] +end + +gems.each do |gem_name, gem_params| + gem gem_name, *gem_params +end + +# Evaluate Gemfile.local and ~/.gemfile if they exist +extra_gemfiles = [ + "#{__FILE__}.local", + File.join(Dir.home, '.gemfile'), +] + +extra_gemfiles.each do |gemfile| + if File.file?(gemfile) && File.readable?(gemfile) + eval(File.read(gemfile), binding) + end +end +# vim: syntax=ruby diff --git a/Gemfile.lock b/Gemfile.lock index f471e85..190e38f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,37 +1,124 @@ GEM remote: https://rubygems.org/ specs: - CFPropertyList (2.3.6) + addressable (2.5.2) + public_suffix (>= 2.0.2, < 4.0) + ansi (1.5.0) + ast (2.4.0) + codecov (0.1.10) + json + simplecov + url + coderay (1.1.2) diff-lcs (1.3) + docile (1.3.1) + domain_name (0.5.20180417) + unf (>= 0.0.5, < 1.0.0) facter (2.5.1) - facter (2.5.1-universal-darwin) - CFPropertyList (~> 2.2) + facterdb (0.5.2) + facter + jgrep fast_gettext (1.1.2) - hiera (3.4.2) + gettext (3.2.9) + locale (>= 2.0.5) + text (>= 1.3.0) + gettext-setup (0.30) + fast_gettext (~> 1.1.0) + gettext (>= 3.0.2) + locale + hiera (3.4.3) + hirb (0.7.3) + http-cookie (1.0.3) + domain_name (~> 0.5) + jgrep (1.5.0) + json (2.0.4) + json-schema (2.8.0) + addressable (>= 2.4) locale (2.1.2) + mcollective-client (2.12.1) + json + stomp + systemu metaclass (0.0.4) - mocha (1.3.0) + metadata-json-lint (2.1.0) + json-schema (~> 2.8) + spdx-licenses (~> 1.0) + method_source (0.8.2) + mime-types (3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2016.0521) + mocha (1.1.0) metaclass (~> 0.0.1) - puppet (5.4.0) + multi_json (1.13.1) + net-scp (1.2.1) + net-ssh (>= 2.6.5) + net-ssh (4.2.0) + net-telnet (0.1.1) + netrc (0.11.0) + parallel (1.12.1) + parallel_tests (2.14.2) + parallel + parser (2.5.1.2) + ast (~> 2.4.0) + powerpack (0.1.2) + pry (0.10.4) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + public_suffix (3.0.2) + puppet (5.5.3) facter (> 2.0.1, < 4) fast_gettext (~> 1.1.2) hiera (>= 3.2.1, < 4) locale (~> 2.1) - puppet (5.4.0-universal-darwin) - CFPropertyList (~> 2.2) - facter (> 2.0.1, < 4) - fast_gettext (~> 1.1.2) - hiera (>= 3.2.1, < 4) - locale (~> 2.1) - puppet-lint (2.3.3) + multi_json (~> 1.10) + puppet-blacksmith (4.1.2) + rest-client (~> 2.0) + puppet-lint (2.3.6) + puppet-module-posix-default-r2.4 (0.3.5) + puppet-module-posix-dev-r2.4 (0.3.5) + codecov (~> 0.1.10) + gettext-setup (~> 0.26) + metadata-json-lint (>= 2.0.2, < 3.0.0) + mocha (>= 1.0.0, < 1.2.0) + parallel_tests (>= 2.14.1, < 2.14.3) + pry (~> 0.10.4) + puppet-blacksmith (>= 3.4.0) + puppet-lint (>= 2.3.0, < 3.0.0) + puppet-strings (~> 2.0) + puppet-syntax (>= 2.4.1, < 3.0.0) + puppet_pot_generator (~> 1.0) + puppetlabs_spec_helper (>= 2.9.0, < 3.0.0) + rainbow (~> 2.0) + rspec-puppet (>= 2.3.2, < 3.0.0) + rspec-puppet-facts (~> 1.8) + rspec_junit_formatter (~> 0.2) + rubocop (~> 0.49.0) + rubocop-i18n (~> 1.2.0) + rubocop-rspec (~> 1.16.0) + simplecov (>= 0.14.1, < 1.0.0) + simplecov-console (~> 0.4.2) + specinfra (= 2.67.3) + puppet-strings (2.1.0) + rgen + yard (~> 0.9.5) puppet-syntax (2.4.1) rake - puppetlabs_spec_helper (2.6.2) + puppet_pot_generator (1.0.1) + puppet + puppetlabs_spec_helper (2.9.1) mocha (~> 1.0) puppet-lint (~> 2.0) puppet-syntax (~> 2.0) rspec-puppet (~> 2.0) - rake (12.3.0) + rainbow (2.2.2) + rake + rake (12.3.1) + rest-client (2.0.2) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 4.0) + netrc (~> 0.8) + rgen (0.8.2) rspec (3.7.0) rspec-core (~> 3.7.0) rspec-expectations (~> 3.7.0) @@ -44,17 +131,67 @@ GEM rspec-mocks (3.7.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.7.0) - rspec-puppet (2.6.9) + rspec-puppet (2.6.14) rspec + rspec-puppet-facts (1.9.0) + facter + facterdb (>= 0.5.0) + json + mcollective-client + puppet rspec-support (3.7.1) + rspec_junit_formatter (0.4.1) + rspec-core (>= 2, < 4, != 2.12.0) + rubocop (0.49.1) + parallel (~> 1.10) + parser (>= 2.3.3.1, < 3.0) + powerpack (~> 0.1) + rainbow (>= 1.99.1, < 3.0) + ruby-progressbar (~> 1.7) + unicode-display_width (~> 1.0, >= 1.0.1) + rubocop-i18n (1.2.0) + rubocop (~> 0.49.0) + rubocop-rspec (1.16.0) + rubocop (>= 0.49.0) + ruby-progressbar (1.9.0) + sfl (2.3) + simplecov (0.16.1) + docile (~> 1.1) + json (>= 1.8, < 3) + simplecov-html (~> 0.10.0) + simplecov-console (0.4.2) + ansi + hirb + simplecov + simplecov-html (0.10.2) + slop (3.6.0) + spdx-licenses (1.2.0) + specinfra (2.67.3) + net-scp + net-ssh (>= 2.7, < 5.0) + net-telnet + sfl + stomp (1.4.4) + systemu (2.6.5) + text (1.3.1) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.5) + unicode-display_width (1.4.0) + url (0.3.2) + yard (0.9.15) PLATFORMS ruby - universal-darwin-17 DEPENDENCIES + fast_gettext + json (<= 2.0.4) puppet - puppetlabs_spec_helper + puppet-module-posix-default-r2.4 + puppet-module-posix-dev-r2.4 + puppet-module-win-default-r2.4 + puppet-module-win-dev-r2.4 BUNDLED WITH 1.16.1 diff --git a/Rakefile b/Rakefile index 1b8de3e..204fb18 100644 --- a/Rakefile +++ b/Rakefile @@ -1,11 +1,75 @@ -require "puppetlabs_spec_helper/rake_tasks" +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? -begin - if Gem::Specification::find_by_name("puppet-lint") - require "puppet-lint/tasks/puppet-lint" - PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "vendor/**/*.pp"] - task :default => [:spec, :lint] +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 -rescue Gem::LoadError - task :default => :spec end + diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..4a5b227 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,52 @@ +--- +version: 1.1.x.{build} +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: ~> 4.0 + RUBY_VERSION: 21 + CHECK: parallel_spec + - + PUPPET_GEM_VERSION: ~> 4.0 + RUBY_VERSION: 21-x64 + CHECK: parallel_spec + - + PUPPET_GEM_VERSION: ~> 5.0 + RUBY_VERSION: 24 + CHECK: parallel_spec + - + PUPPET_GEM_VERSION: ~> 5.0 + RUBY_VERSION: 24-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 914c724..21f7170 100644 --- a/metadata.json +++ b/metadata.json @@ -2,16 +2,28 @@ "name": "choria-choria", "version": "0.10.0", "author": "R.I.Pienaar ", - "license": "Apache-2.0", "summary": "Install and manage the Choria plugin for MCollective", + "license": "Apache-2.0", "source": "https://github.com/choria-io/puppet-choria", "project_page": "https://github.com/choria-io/puppet-choria", "issues_url": "https://github.com/choria-io/puppet-choria/issues", "dependencies": [ - { "name": "puppetlabs/stdlib", "version_requirement": ">= 4.24.0 < 5.0.0" }, - { "name": "puppetlabs/apt", "version_requirement": ">= 4.5.1 < 6.0.0" }, - { "name": "choria/mcollective_choria", "version_requirement": ">= 0.9.0 < 2.0.0" }, - { "name": "choria/mcollective", "version_requirement": ">= 0.6.0 < 2.0.0" } + { + "name": "puppetlabs/stdlib", + "version_requirement": ">= 4.24.0 < 5.0.0" + }, + { + "name": "puppetlabs/apt", + "version_requirement": ">= 4.5.1 < 6.0.0" + }, + { + "name": "choria/mcollective_choria", + "version_requirement": ">= 0.9.0 < 2.0.0" + }, + { + "name": "choria/mcollective", + "version_requirement": ">= 0.6.0 < 2.0.0" + } ], "operatingsystem_support": [ { @@ -113,5 +125,8 @@ "name": "puppet", "version_requirement": ">= 4.9.0" } - ] + ], + "pdk-version": "1.6.1", + "template-url": "file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git", + "template-ref": "1.6.1-0-g6b0d497" } diff --git a/spec/default_facts.yml b/spec/default_facts.yml new file mode 100644 index 0000000..3248be5 --- /dev/null +++ b/spec/default_facts.yml @@ -0,0 +1,8 @@ +# Use default_module_facts.yml for module specific facts. +# +# Facts specified here will override the values provided by rspec-puppet-facts. +--- +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 d58ed12..e69d11d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,9 +1,45 @@ -require "rspec-puppet/spec_helper" -fixture_path = File.expand_path(File.join(__FILE__, "..", "fixtures")) +require 'puppetlabs_spec_helper/module_spec_helper' +require 'rspec-puppet-facts' + +begin + require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb')) +rescue LoadError => loaderror + warn "Could not require spec_helper_local: #{loaderror.message}" +end + +include RspecPuppetFacts + +default_facts = { + puppetversion: Puppet.version, + facterversion: Facter.version, +} + +default_facts_path = File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')) +default_module_facts_path = File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')) + +if File.exist?(default_facts_path) && File.readable?(default_facts_path) + default_facts.merge!(YAML.safe_load(File.read(default_facts_path))) +end + +if File.exist?(default_module_facts_path) && File.readable?(default_module_facts_path) + default_facts.merge!(YAML.safe_load(File.read(default_module_facts_path))) +end RSpec.configure do |c| - c.module_path = File.join(fixture_path, "modules") - c.manifest_dir = File.join(fixture_path, "manifests") - c.environmentpath = File.join(Dir.pwd, "spec") + 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 + 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