diff --git a/.gitignore b/.gitignore index 6dfe023..56efb9c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,22 @@ -.*.sw? -/pkg -/spec/fixtures -/.rspec_system -/.vagrant -/.bundle -/vendor -/Gemfile.lock -/junit -/log +.*.sw[op] +.metadata .yardoc -coverage +.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 +.DS_Store diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..35e4209 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,70 @@ +--- +stages: + - test_2.4.1 + - test_2.1.9 + +before_script: + - bundle -v + - rm Gemfile.lock || true + - gem update --system + - gem update bundler + - gem --version + - bundle -v + - bundle install --without system_tests + +rubocop-2.4.1: + stage: test_2.4.1 + image: ruby:2.4.1 + script: + - bundle exec rake rubocop + +syntax-2.4.1: + stage: test_2.4.1 + image: ruby:2.4.1 + script: + - bundle exec rake syntax lint + +metadata-2.4.1: + stage: test_2.4.1 + image: ruby:2.4.1 + script: + - bundle exec rake metadata_lint + +rspec-puppet-2.4.1: + stage: test_2.4.1 + image: ruby:2.4.1 + variables: + PUPPET_GEM_VERSION: ~> 4.0 + CHECK: spec + script: + - bundle update + - bundle exec rake $CHECK + +rubocop-2.1.9: + stage: test_2.1.9 + image: ruby:2.1.9 + script: + - bundle exec rake rubocop + +syntax-2.1.9: + stage: test_2.1.9 + image: ruby:2.1.9 + script: + - bundle exec rake syntax lint + +metadata-2.1.9: + stage: test_2.1.9 + image: ruby:2.1.9 + script: + - bundle exec rake metadata_lint + +rspec-puppet-2.1.9: + stage: test_2.1.9 + image: ruby:2.1.9 + variables: + PUPPET_GEM_VERSION: ~> 4.0 + CHECK: spec + script: + - bundle update + - bundle exec rake $CHECK + diff --git a/.pdkignore b/.pdkignore new file mode 100644 index 0000000..56efb9c --- /dev/null +++ b/.pdkignore @@ -0,0 +1,22 @@ +.*.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 +.DS_Store diff --git a/.rspec b/.rspec index 4cd92bf..16f9cdb 100644 --- a/.rspec +++ b/.rspec @@ -1,3 +1,2 @@ ---format documentation --color ---fail-fast +--format documentation diff --git a/.rubocop.yml b/.rubocop.yml index c74c8f9..40a58e0 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,462 +1,107 @@ +--- +require: rubocop-rspec AllCops: + DisplayCopNames: true + TargetRubyVersion: '2.1' + Include: + - "./**/*.rb" Exclude: - # Ignore HTML related things - - '**/*.erb' - # Ignore vendored gems - - 'vendor/**/*' - # Ignore code from test fixtures - - 'spec/fixtures/**/*' - -Lint/ConditionPosition: - Enabled: true - -Lint/ElseLayout: - Enabled: true - -Lint/UnreachableCode: - Enabled: true - -Lint/UselessComparison: - Enabled: true - -Lint/EnsureReturn: - Enabled: true - -Lint/HandleExceptions: - Enabled: true - -Lint/ShadowingOuterLocalVariable: - Enabled: true - -Lint/LiteralInInterpolation: - Enabled: true - -Style/RedundantReturn: - Enabled: true - -Lint/AmbiguousOperator: + - bin/* + - ".vendor/**/*" + - Gemfile + - Rakefile + - pkg/**/* + - spec/fixtures/**/* + - vendor/**/* +Metrics/LineLength: + Description: People have wide screens, use them. + Max: 200 +RSpec/BeforeAfterAll: + Description: Beware of using after(:all) as it may cause state to leak between tests. + A necessary evil in acceptance testing. + Exclude: + - spec/acceptance/**/*.rb +RSpec/HookArgument: + Description: Prefer explicit :each argument, matching existing module's style + EnforcedStyle: each +Style/BlockDelimiters: + Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to + be consistent then. + EnforcedStyle: braces_for_chaining +Style/ClassAndModuleChildren: + Description: Compact style reduces the required amount of indentation. + EnforcedStyle: compact +Style/EmptyElse: + Description: Enforce against empty else clauses, but allow `nil` for clarity. + EnforcedStyle: empty +Style/FormatString: + Description: Following the main puppet project's style, prefer the % format format. + EnforcedStyle: percent +Style/FormatStringToken: + Description: Following the main puppet project's style, prefer the simpler template + tokens over annotated ones. + EnforcedStyle: template +Style/Lambda: + Description: Prefer the keyword for easier discoverability. + EnforcedStyle: literal +Style/RegexpLiteral: + Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168 + EnforcedStyle: percent_r +Style/TernaryParentheses: + Description: Checks for use of parentheses around ternary conditions. Enforce parentheses + on complex expressions for better readability, but seriously consider breaking + it up. + EnforcedStyle: require_parentheses_when_complex +Style/TrailingCommaInArguments: + Description: Prefer always trailing comma on multiline argument lists. This makes + diffs, and re-ordering nicer. + EnforcedStyleForMultiline: comma +Style/TrailingCommaInLiteral: + Description: Prefer always trailing comma on multiline literals. This makes diffs, + and re-ordering nicer. + EnforcedStyleForMultiline: comma +Style/SymbolArray: + Description: Using percent style obscures symbolic intent of array's contents. + EnforcedStyle: brackets +RSpec/MessageSpies: + EnforcedStyle: receive +Style/CollectionMethods: Enabled: true - -Lint/AssignmentInCondition: +Style/MethodCalledOnDoEndBlock: Enabled: true - -Layout/SpaceBeforeComment: +Style/StringMethods: Enabled: true - -# DISABLED - not useful -Style/HashSyntax: +Layout/EndOfLine: Enabled: false - -# USES: as shortcut for non nil&valid checking a = x() and a.empty? -# DISABLED - not useful -Style/AndOr: +Metrics/AbcSize: Enabled: false - -# DISABLED - not useful -Style/RedundantSelf: - Enabled: false - -# DISABLED - not useful -Metrics/MethodLength: - Enabled: false - Metrics/BlockLength: Enabled: false - -# DISABLED - not useful -Style/WhileUntilModifier: - Enabled: false - -# DISABLED - the offender is just haskell envy -Lint/AmbiguousRegexpLiteral: - Enabled: false - -# DISABLED -Security/Eval: - Enabled: false - -# DISABLED -Lint/BlockAlignment: - Enabled: false - -# DISABLED -Lint/DefEndAlignment: - Enabled: false - -# DISABLED -Lint/EndAlignment: - Enabled: false - -# DISABLED -Lint/DeprecatedClassMethods: - Enabled: false - -# DISABLED -Lint/Loop: - Enabled: false - -# DISABLED -Lint/ParenthesesAsGroupedExpression: - Enabled: false - -Lint/RescueException: - Enabled: false - -Lint/StringConversionInInterpolation: - Enabled: false - -Lint/UnusedBlockArgument: - Enabled: false - -Lint/UnusedMethodArgument: - Enabled: false - -Lint/UselessAccessModifier: - Enabled: true - -Lint/UselessAssignment: - Enabled: true - -Lint/Void: - Enabled: true - -Layout/AccessModifierIndentation: - Enabled: false - -Naming/AccessorMethodName: - Enabled: false - -Style/Alias: - Enabled: false - -Layout/AlignArray: - Enabled: false - -Layout/AlignHash: - Enabled: false - -Layout/AlignParameters: - Enabled: false - -Metrics/BlockNesting: - Enabled: false - -Style/AsciiComments: - Enabled: false - -Style/Attr: - Enabled: false - -Style/BracesAroundHashParameters: - Enabled: false - -Style/CaseEquality: - Enabled: false - -Layout/CaseIndentation: - Enabled: false - -Style/CharacterLiteral: - Enabled: false - -Style/ClassAndModuleChildren: - Enabled: false - -Style/ClassCheck: - Enabled: false - Metrics/ClassLength: Enabled: false - -Style/ClassMethods: - Enabled: false - -Style/ClassVars: - Enabled: false - -Style/WhenThen: - Enabled: false - -# DISABLED - not useful -Style/WordArray: - Enabled: false - -Style/UnneededPercentQ: - Enabled: false - -Layout/Tab: - Enabled: false - -Layout/SpaceInsideBlockBraces: - Enabled: false - -Layout/SpaceInsideBrackets: - Enabled: false - -Layout/SpaceInsideHashLiteralBraces: - Enabled: false - -Layout/SpaceInsideParens: - Enabled: false - -Layout/LeadingCommentSpace: - Enabled: false - -Layout/SpaceBeforeFirstArg: - Enabled: false - -Layout/SpaceAroundKeyword: - Enabled: false - -Layout/SpaceAfterMethodName: - Enabled: false - -Layout/SpaceAfterSemicolon: - Enabled: false - -Layout/SpaceAroundOperators: - Enabled: false - -Layout/SpaceBeforeBlockBraces: - Enabled: false - -Layout/SpaceBeforeComma: - Enabled: false - -Style/CollectionMethods: - Enabled: false - -Layout/CommentIndentation: - Enabled: false - -Style/ColonMethodCall: - Enabled: false - -Style/CommentAnnotation: - Enabled: false - Metrics/CyclomaticComplexity: Enabled: false - -Naming/ConstantName: - Enabled: false - -Style/Documentation: - Enabled: false - -Style/DefWithParentheses: - Enabled: false - -Style/PreferredHashMethods: - Enabled: false - -Layout/DotPosition: - Enabled: false - -# DISABLED - used for converting to bool -Style/DoubleNegation: - Enabled: false - -Style/EachWithObject: - Enabled: false - -Layout/EmptyLineBetweenDefs: - Enabled: false - -Layout/IndentArray: - Enabled: false - -Layout/IndentHash: - Enabled: false - -Layout/IndentationConsistency: - Enabled: false - -Layout/IndentationWidth: - Enabled: false - -Layout/EmptyLines: - Enabled: false - -Layout/EmptyLinesAroundAccessModifier: - Enabled: false - -Layout/EmptyLinesAroundBlockBody: - Enabled: false - -Style/EmptyLiteral: +Metrics/MethodLength: Enabled: false - -Metrics/LineLength: +Metrics/ModuleLength: Enabled: false - -Style/MethodCallWithoutArgsParentheses: +Metrics/ParameterLists: Enabled: false - -Style/MethodDefParentheses: +Metrics/PerceivedComplexity: Enabled: false - -Style/LineEndConcatenation: +RSpec/DescribeClass: Enabled: false - -Layout/TrailingWhitespace: +RSpec/ExampleLength: Enabled: false - -Style/StringLiterals: +RSpec/MessageExpectation: Enabled: false - -Style/TrailingCommaInLiteral: +RSpec/MultipleExpectations: Enabled: false - -Style/GlobalVars: +RSpec/NestedGroups: Enabled: false - -Style/GuardClause: +Style/AsciiComments: Enabled: false - Style/IfUnlessModifier: Enabled: false - -Style/MultilineIfThen: - Enabled: false - -Layout/MultilineMethodCallIndentation: - Enabled: false - -Style/NegatedIf: - Enabled: false - -Style/NegatedWhile: - Enabled: false - -Style/Next: - Enabled: false - -Style/SingleLineBlockParams: - Enabled: false - -Style/SingleLineMethods: - Enabled: false - -Style/SpecialGlobalVars: - Enabled: false - -Style/TrivialAccessors: - Enabled: false - -Style/UnlessElse: - Enabled: false - -Style/VariableInterpolation: - Enabled: false - -Naming/VariableName: - Enabled: false - -Style/WhileUntilDo: - Enabled: false - -Style/EvenOdd: - Enabled: false - -Naming/FileName: - Enabled: false - -Style/For: - Enabled: false - -Style/Lambda: - Enabled: false - -Naming/MethodName: - Enabled: false - -Style/MultilineTernaryOperator: - Enabled: false - -Style/NilComparison: - Enabled: false - -Style/FormatString: - Enabled: false - -Style/MultilineBlockChain: - Enabled: false - -Layout/MultilineHashBraceLayout: - Enabled: false - -Style/Semicolon: - Enabled: false - -Style/SignalException: - Enabled: false - -Style/NonNilCheck: - Enabled: false - -Style/Not: - Enabled: false - -Style/NumericLiterals: - Enabled: false - -Style/OneLineConditional: - Enabled: false - -Style/ParenthesesAroundCondition: - Enabled: false - -Style/PercentLiteralDelimiters: - Enabled: false - -Style/PerlBackrefs: - Enabled: false - -Naming/PredicateName: - Enabled: false - -Style/RedundantException: - Enabled: false - -Style/SelfAssignment: - Enabled: false - -Style/Proc: - Enabled: false - -Style/RaiseArgs: - Enabled: false - -Style/RedundantBegin: - Enabled: false - -Style/RescueModifier: - Enabled: false - -Style/RegexpLiteral: - Enabled: false - -Lint/UnderscorePrefixedVariableName: - Enabled: false - -Metrics/ParameterLists: - Enabled: false - -Lint/RequireParentheses: - Enabled: false - -Layout/SpaceBeforeFirstArg: - Enabled: false - -Style/ModuleFunction: - Enabled: false - -Lint/Debugger: - Enabled: false - -Style/IfWithSemicolon: - Enabled: false - -Style/Encoding: +Style/SymbolProc: Enabled: false diff --git a/.travis.yml b/.travis.yml index cdb20f6..6b1f5fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,48 @@ --- +sudo: false +dist: trusty language: ruby -bundler_args: --without development system_tests -before_install: rm Gemfile.lock || true +cache: bundler +before_install: + - bundle -v + - rm Gemfile.lock || true + - gem update --system + - gem update bundler + - gem --version + - bundle -v +script: + - 'bundle exec rake $CHECK' +bundler_args: --without system_tests rvm: - - 2.0.0 - - 2.1.0 -script: bundle exec rake test + - 2.4.1 env: - - PUPPET_GEM_VERSION="~> 3.8.0" STRICT_VARIABLES=yes - - PUPPET_GEM_VERSION="~> 3.8.0" STRICT_VARIABLES=yes FUTURE_PARSER=yes + - PUPPET_GEM_VERSION="~> 5.0" CHECK=spec +matrix: + fast_finish: true + include: + - + env: CHECK=rubocop + - + env: CHECK="syntax lint" + - + env: CHECK=metadata_lint + - + env: CHECK=spec + - + env: PUPPET_GEM_VERSION="~> 4.0" CHECK=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/Gemfile b/Gemfile index 2c238e1..655b014 100644 --- a/Gemfile +++ b/Gemfile @@ -1,32 +1,126 @@ -source "https://rubygems.org" - -group :test do - gem "metadata-json-lint" - gem "puppet", ENV['PUPPET_GEM_VERSION'] || '~> 3.8.0' - gem "puppet-lint-absolute_classname-check" - gem "puppet-lint-classes_and_types_beginning_with_digits-check" - gem "puppet-lint-leading_zero-check" - gem "puppet-lint-trailing_comma-check" - gem "puppet-lint-unquoted_string-check" - gem "puppet-lint-version_comparison-check" - gem "puppetlabs_spec_helper" - gem "rake" - gem "rspec", '~> 3.0' # works with '~> 3.6.0' - gem "rspec-puppet" - gem "rspec-puppet-facts" - gem 'rubocop' # works with '0.51.0' - gem 'simplecov', '>= 0.11.0' - gem 'simplecov-console' +source ENV['GEM_SOURCE'] || 'https://rubygems.org' + +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 "guard-rake" - gem "travis" - gem "travis-lint" + 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 "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'] + +def puppet_older_than?(version) + puppet_version = ENV['PUPPET_GEM_VERSION'] + !puppet_version.nil? && + Gem::Version.correct?(puppet_version) && + Gem::Requirement.new("< #{version}").satisfied_by?(Gem::Version.new(puppet_version.dup)) +end + +gems = {} + +gems['puppet'] = location_for(puppet_version) + +# If facter or hiera versions have been specified via the environment +# variables, use those versions. If not, and if the puppet version is < 3.5.0, +# use known good versions of both for puppet < 3.5.0. +if facter_version + gems['facter'] = location_for(facter_version) +elsif puppet_type == :gem && puppet_older_than?('3.5.0') + gems['facter'] = ['>= 1.6.11', '<= 1.7.5', require: false] end -group :system_tests do - gem "beaker" - gem "beaker-puppet_install_helper" - gem "beaker-rspec" +if hiera_version + gems['hiera'] = location_for(ENV['HIERA_GEM_VERSION']) +elsif puppet_type == :gem && puppet_older_than?('3.5.0') + gems['hiera'] = ['>= 1.0.0', '<= 1.3.0', require: false] +end + +if Gem.win_platform? && (puppet_type != :gem || puppet_older_than?('3.5.0')) + # For Puppet gems < 3.5.0 (tested as far back as 3.0.0) on Windows + if puppet_type == :gem + gems['ffi'] = ['1.9.0', require: false] + gems['minitar'] = ['0.5.4', require: false] + gems['win32-eventlog'] = ['0.5.3', '<= 0.6.5', require: false] + gems['win32-process'] = ['0.6.5', '<= 0.7.5', require: false] + gems['win32-security'] = ['~> 0.1.2', '<= 0.2.5', require: false] + gems['win32-service'] = ['0.7.2', '<= 0.8.8', require: false] + else + gems['ffi'] = ['~> 1.9.0', require: false] + gems['minitar'] = ['~> 0.5.4', require: false] + gems['win32-eventlog'] = ['~> 0.5', '<= 0.6.5', require: false] + gems['win32-process'] = ['~> 0.6', '<= 0.7.5', require: false] + gems['win32-security'] = ['~> 0.1', '<= 0.2.5', require: false] + gems['win32-service'] = ['~> 0.7', '<= 0.8.8', require: false] + end + + gems['win32-dir'] = ['~> 0.3', '<= 0.4.9', require: false] + + if RUBY_VERSION.start_with?('1.') + gems['win32console'] = ['1.3.2', require: false] + # sys-admin was removed in Puppet 3.7.0 and doesn't compile under Ruby 2.x + gems['sys-admin'] = ['1.5.6', require: false] + end + + # Puppet < 3.7.0 requires these. + # Puppet >= 3.5.0 gem includes these as requirements. + # The following versions are tested to work with 3.0.0 <= puppet < 3.7.0. + gems['win32-api'] = ['1.4.8', require: false] + gems['win32-taskscheduler'] = ['0.2.2', require: false] + gems['windows-api'] = ['0.4.3', require: false] + gems['windows-pr'] = ['1.2.3', require: false] +elsif Gem.win_platform? + # 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/Rakefile b/Rakefile index aec8e82..81381e0 100644 --- a/Rakefile +++ b/Rakefile @@ -1,62 +1,2 @@ -require 'rubygems' -require 'bundler/setup' - require 'puppetlabs_spec_helper/rake_tasks' -require 'puppet/version' -require 'puppet/vendor/semantic/lib/semantic' unless Puppet.version.to_f < 3.6 -require 'puppet-lint/tasks/puppet-lint' require 'puppet-syntax/tasks/puppet-syntax' -require 'metadata-json-lint/rake_task' -require 'rubocop/rake_task' - -# These gems aren't always present, for instance -# on Travis with --without development -begin -rescue LoadError # rubocop:disable Lint/HandleExceptions -end - -RuboCop::RakeTask.new - -exclude_paths = [ - "bundle/**/*", - "pkg/**/*", - "vendor/**/*", - "spec/**/*", -] - -# Coverage from puppetlabs-spec-helper requires rcov which -# doesn't work in anything since 1.8.7 -Rake::Task[:coverage].clear - -Rake::Task[:lint].clear - -PuppetLint.configuration.relative = true -PuppetLint.configuration.disable_80chars -PuppetLint.configuration.disable_class_inherits_from_params_class -PuppetLint.configuration.disable_class_parameter_defaults -PuppetLint.configuration.fail_on_warnings = false - -PuppetLint::RakeTask.new :lint do |config| - config.ignore_paths = exclude_paths -end - -PuppetSyntax.exclude_paths = exclude_paths - -desc "Run acceptance tests" -RSpec::Core::RakeTask.new(:acceptance) do |t| - t.pattern = 'spec/acceptance' -end - -desc "Populate CONTRIBUTORS file" -task :contributors do - system("git log --format='%aN' | sort -u > CONTRIBUTORS") -end - -desc "Run syntax, lint, and spec tests." -task :test => %i[ - metadata_lint - syntax - lint - rubocop - spec -] diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..5fd5e89 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,57 @@ +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 + - + RUBY_VERSION: 24-x64 + CHECK: metadata_lint + - + RUBY_VERSION: 24-x64 + CHECK: rubocop + - + PUPPET_GEM_VERSION: ~> 4.0 + RUBY_VERSION: 21 + CHECK: spec + - + PUPPET_GEM_VERSION: ~> 4.0 + RUBY_VERSION: 21-x64 + CHECK: spec + - + PUPPET_GEM_VERSION: ~> 5.0 + RUBY_VERSION: 24 + CHECK: spec + - + PUPPET_GEM_VERSION: ~> 5.0 + RUBY_VERSION: 24-x64 + CHECK: 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 260186a..9280cf3 100644 --- a/metadata.json +++ b/metadata.json @@ -1,66 +1,104 @@ { "name": "ssm-munin", "version": "0.1.0", "author": "ssm", - "license": "Apache-2.0", "summary": "Configure munin master, node and plugins", + "license": "Apache-2.0", "source": "https://github.com/ssm/ssm-munin", + "project_page": "https://github.com/ssm/ssm-munin", + "issues_url": "https://github.com/ssm/ssm-munin/issues", "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": ">= 2.3.0" } ], - "project_page": "https://github.com/ssm/ssm-munin", - "issues_url": "https://github.com/ssm/ssm-munin/issues", "operatingsystem_support": [ { "operatingsystem": "Archlinux", - "operatingsystemrelease": [ "4" ] + "operatingsystemrelease": [ + "4" + ] }, { "operatingsystem": "CentOS", - "operatingsystemrelease": [ "5", "6", "7" ] + "operatingsystemrelease": [ + "5", + "6", + "7" + ] }, { "operatingsystem": "Debian", - "operatingsystemrelease": [ "6", "7", "8" ] + "operatingsystemrelease": [ + "6", + "7", + "8" + ] }, { "operatingsystem": "OracleLinux", - "operatingsystemrelease": [ "5", "6", "7" ] + "operatingsystemrelease": [ + "5", + "6", + "7" + ] }, { "operatingsystem": "RedHat", - "operatingsystemrelease": [ "5", "6", "7" ] + "operatingsystemrelease": [ + "5", + "6", + "7" + ] }, { "operatingsystem": "Scientific", - "operatingsystemrelease": [ "5", "6", "7" ] + "operatingsystemrelease": [ + "5", + "6", + "7" + ] }, { "operatingsystem": "SmartOS" }, { "operatingsystem": "Ubuntu", - "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] + "operatingsystemrelease": [ + "10.04", + "12.04", + "14.04" + ] }, { "operatingsystem": "FreeBSD", - "operatingsystemrelease": [ "9", "10" ] + "operatingsystemrelease": [ + "9", + "10" + ] }, { "operatingsystem": "DragonFly" }, { "operatingsystem": "OpenBSD" } ], + "requirements": [ + { + "name": "puppet", + "version_requirement": ">= 4.7.0 < 6.0.0" + } + ], "tags": [ "munin", "monitoring", "graphing", "performance", "trending" - ] + ], + "pdk-version": "1.4.1", + "template-url": "file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git", + "template-ref": "1.4.1-0-g52adbbb" } 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 23d3e29..efd225b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,20 +1,30 @@ 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 -require 'simplecov' -require 'simplecov-console' +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 -SimpleCov.start do - add_filter '/spec' - add_filter '/vendor' - formatter SimpleCov::Formatter::MultiFormatter.new([ - SimpleCov::Formatter::HTMLFormatter, - SimpleCov::Formatter::Console - ]) +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 -shared_context :unsupported do - let(:facts) { { osfamily: 'Unsupported' } } +RSpec.configure do |c| + c.default_facts = default_facts end