diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..12ed4ff1 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,6 @@ +FROM puppet/pdk:latest + +# [Optional] Uncomment this section to install additional packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..f1a55dc3 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,23 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.140.1/containers/puppet +{ + "name": "Puppet Development Kit (Community)", + "dockerFile": "Dockerfile", + + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "puppet.puppet-vscode", + "rebornix.Ruby" + ] + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "pdk --version", +} diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile new file mode 100644 index 00000000..0814c5e6 --- /dev/null +++ b/.gitpod.Dockerfile @@ -0,0 +1,18 @@ +FROM gitpod/workspace-full +RUN sudo wget https://apt.puppet.com/puppet-tools-release-bionic.deb && \ + wget https://apt.puppetlabs.com/puppet6-release-bionic.deb && \ + sudo dpkg -i puppet6-release-bionic.deb && \ + sudo dpkg -i puppet-tools-release-bionic.deb && \ + sudo apt-get update && \ + sudo apt-get install -y pdk zsh puppet-agent && \ + sudo apt-get clean && \ + sudo rm -rf /var/lib/apt/lists/* +RUN sudo usermod -s $(which zsh) gitpod && \ + sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" && \ + echo "plugins=(git gitignore github gem pip bundler python ruby docker docker-compose)" >> /home/gitpod/.zshrc && \ + echo 'PATH="$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/puppetlabs/bin:/opt/puppetlabs/puppet/bin"' >> /home/gitpod/.zshrc && \ + sudo /opt/puppetlabs/puppet/bin/gem install puppet-debugger hub -N && \ + mkdir -p /home/gitpod/.config/puppet && \ + /opt/puppetlabs/puppet/bin/ruby -r yaml -e "puts ({'disabled' => true}).to_yaml" > /home/gitpod/.config/puppet/analytics.yml +RUN rm -f puppet6-release-bionic.deb puppet-tools-release-bionic.deb +ENTRYPOINT /usr/bin/zsh diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 00000000..18406c50 --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,9 @@ +image: + file: .gitpod.Dockerfile + +tasks: + - init: pdk bundle install + +vscode: + extensions: + - puppet.puppet-vscode@1.0.0:oSzfTkDf6Cmc1jOjgW33VA== diff --git a/.pdkignore b/.pdkignore index e6215cd0..bb3fc212 100644 --- a/.pdkignore +++ b/.pdkignore @@ -32,6 +32,7 @@ /.gitignore /.gitlab-ci.yml /.pdkignore +/.puppet-lint.rc /Rakefile /rakelib/ /.rspec @@ -40,3 +41,6 @@ /.yardopts /spec/ /.vscode/ +/.sync.yml +/.devcontainer/ +/.editorconfig diff --git a/.puppet-lint.rc b/.puppet-lint.rc index cc96ece0..e5cc4f8d 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1 +1,2 @@ +--fail-on-warnings --relative diff --git a/.rubocop.yml b/.rubocop.yml index bab25db5..8f782e74 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,12 +1,12 @@ --- require: +- rubocop-performance - rubocop-rspec -- rubocop-i18n AllCops: DisplayCopNames: true - TargetRubyVersion: '2.1' + TargetRubyVersion: '2.4' Include: - - "./**/*.rb" + - "**/*.rb" Exclude: - bin/* - ".vendor/**/*" @@ -18,16 +18,9 @@ AllCops: - "**/Puppetfile" - "**/Vagrantfile" - "**/Guardfile" -Metrics/LineLength: +Layout/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/**/* - 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. @@ -36,6 +29,9 @@ RSpec/BeforeAfterAll: RSpec/HookArgument: Description: Prefer explicit :each argument, matching existing module's style EnforcedStyle: each +RSpec/DescribeSymbol: + Exclude: + - spec/unit/facter/**/*.rb Style/BlockDelimiters: Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to be consistent then. @@ -68,7 +64,7 @@ Style/TrailingCommaInArguments: Description: Prefer always trailing comma on multiline argument lists. This makes diffs, and re-ordering nicer. EnforcedStyleForMultiline: comma -Style/TrailingCommaInLiteral: +Style/TrailingCommaInArrayLiteral: Description: Prefer always trailing comma on multiline literals. This makes diffs, and re-ordering nicer. EnforcedStyleForMultiline: comma @@ -83,26 +79,170 @@ Style/Documentation: - spec/**/* Style/WordArray: EnforcedStyle: brackets +Performance/AncestorsInclude: + Enabled: true +Performance/BigDecimalWithNumericArgument: + Enabled: true +Performance/BlockGivenWithExplicitBlock: + Enabled: true +Performance/CaseWhenSplat: + Enabled: true +Performance/ConstantRegexp: + Enabled: true +Performance/MethodObjectAsBlock: + Enabled: true +Performance/RedundantSortBlock: + Enabled: true +Performance/RedundantStringChars: + Enabled: true +Performance/ReverseFirst: + Enabled: true +Performance/SortReverse: + Enabled: true +Performance/Squeeze: + Enabled: true +Performance/StringInclude: + Enabled: true +Performance/Sum: + Enabled: true Style/CollectionMethods: Enabled: true Style/MethodCalledOnDoEndBlock: Enabled: true Style/StringMethods: Enabled: true -GetText/DecorateFunctionMessage: +Bundler/InsecureProtocolSource: + Enabled: false +Gemspec/DuplicatedAssignment: + Enabled: false +Gemspec/OrderedDependencies: + Enabled: false +Gemspec/RequiredRubyVersion: + Enabled: false +Gemspec/RubyVersionGlobalsUsage: + Enabled: false +Layout/ArgumentAlignment: + Enabled: false +Layout/BeginEndAlignment: + Enabled: false +Layout/ClosingHeredocIndentation: Enabled: false -GetText/DecorateStringFormattingUsingInterpolation: +Layout/EmptyComment: Enabled: false -GetText/DecorateStringFormattingUsingPercent: +Layout/EmptyLineAfterGuardClause: + Enabled: false +Layout/EmptyLinesAroundArguments: + Enabled: false +Layout/EmptyLinesAroundAttributeAccessor: Enabled: false Layout/EndOfLine: Enabled: false -Layout/IndentHeredoc: +Layout/FirstArgumentIndentation: + Enabled: false +Layout/HashAlignment: + Enabled: false +Layout/HeredocIndentation: + Enabled: false +Layout/LeadingEmptyLines: + Enabled: false +Layout/SpaceAroundMethodCallOperator: + Enabled: false +Layout/SpaceInsideArrayLiteralBrackets: + Enabled: false +Layout/SpaceInsideReferenceBrackets: + Enabled: false +Lint/BigDecimalNew: + Enabled: false +Lint/BooleanSymbol: + Enabled: false +Lint/ConstantDefinitionInBlock: + Enabled: false +Lint/DeprecatedOpenSSLConstant: + Enabled: false +Lint/DisjunctiveAssignmentInConstructor: + Enabled: false +Lint/DuplicateElsifCondition: + Enabled: false +Lint/DuplicateRequire: + Enabled: false +Lint/DuplicateRescueException: + Enabled: false +Lint/EmptyConditionalBody: + Enabled: false +Lint/EmptyFile: + Enabled: false +Lint/ErbNewArguments: + Enabled: false +Lint/FloatComparison: + Enabled: false +Lint/HashCompareByIdentity: + Enabled: false +Lint/IdentityComparison: + Enabled: false +Lint/InterpolationCheck: + Enabled: false +Lint/MissingCopEnableDirective: + Enabled: false +Lint/MixedRegexpCaptureTypes: + Enabled: false +Lint/NestedPercentLiteral: + Enabled: false +Lint/NonDeterministicRequireOrder: + Enabled: false +Lint/OrderedMagicComments: + Enabled: false +Lint/OutOfRangeRegexpRef: + Enabled: false +Lint/RaiseException: + Enabled: false +Lint/RedundantCopEnableDirective: + Enabled: false +Lint/RedundantRequireStatement: + Enabled: false +Lint/RedundantSafeNavigation: + Enabled: false +Lint/RedundantWithIndex: + Enabled: false +Lint/RedundantWithObject: + Enabled: false +Lint/RegexpAsCondition: + Enabled: false +Lint/ReturnInVoidContext: + Enabled: false +Lint/SafeNavigationConsistency: + Enabled: false +Lint/SafeNavigationWithEmpty: + Enabled: false +Lint/SelfAssignment: + Enabled: false +Lint/SendWithMixinArgument: + Enabled: false +Lint/ShadowedArgument: + Enabled: false +Lint/StructNewOverride: + Enabled: false +Lint/ToJSON: + Enabled: false +Lint/TopLevelReturnWithArgument: + Enabled: false +Lint/TrailingCommaInAttributeDeclaration: + Enabled: false +Lint/UnreachableLoop: + Enabled: false +Lint/UriEscapeUnescape: + Enabled: false +Lint/UriRegexp: + Enabled: false +Lint/UselessMethodDefinition: + Enabled: false +Lint/UselessTimes: Enabled: false Metrics/AbcSize: Enabled: false Metrics/BlockLength: Enabled: false +Metrics/BlockNesting: + Enabled: false Metrics/ClassLength: Enabled: false Metrics/CyclomaticComplexity: @@ -115,19 +255,265 @@ Metrics/ParameterLists: Enabled: false Metrics/PerceivedComplexity: Enabled: false +Migration/DepartmentName: + Enabled: false +Naming/AccessorMethodName: + Enabled: false +Naming/BlockParameterName: + Enabled: false +Naming/HeredocDelimiterCase: + Enabled: false +Naming/HeredocDelimiterNaming: + Enabled: false +Naming/MemoizedInstanceVariableName: + Enabled: false +Naming/MethodParameterName: + Enabled: false +Naming/RescuedExceptionsVariableName: + Enabled: false +Naming/VariableNumber: + Enabled: false +Performance/BindCall: + Enabled: false +Performance/DeletePrefix: + Enabled: false +Performance/DeleteSuffix: + Enabled: false +Performance/InefficientHashSearch: + Enabled: false +Performance/UnfreezeString: + Enabled: false +Performance/UriDefaultParser: + Enabled: false +RSpec/Be: + Enabled: false +RSpec/Capybara/CurrentPathExpectation: + Enabled: false +RSpec/Capybara/FeatureMethods: + Enabled: false +RSpec/Capybara/VisibilityMatcher: + Enabled: false +RSpec/ContextMethod: + Enabled: false +RSpec/ContextWording: + Enabled: false RSpec/DescribeClass: Enabled: false +RSpec/EmptyHook: + Enabled: false +RSpec/EmptyLineAfterExample: + Enabled: false +RSpec/EmptyLineAfterExampleGroup: + Enabled: false +RSpec/EmptyLineAfterHook: + Enabled: false RSpec/ExampleLength: Enabled: false -RSpec/MessageExpectation: +RSpec/ExampleWithoutDescription: + Enabled: false +RSpec/ExpectChange: + Enabled: false +RSpec/ExpectInHook: + Enabled: false +RSpec/FactoryBot/AttributeDefinedStatically: + Enabled: false +RSpec/FactoryBot/CreateList: + Enabled: false +RSpec/FactoryBot/FactoryClassName: + Enabled: false +RSpec/HooksBeforeExamples: + Enabled: false +RSpec/ImplicitBlockExpectation: + Enabled: false +RSpec/ImplicitSubject: + Enabled: false +RSpec/LeakyConstantDeclaration: + Enabled: false +RSpec/LetBeforeExamples: + Enabled: false +RSpec/MissingExampleGroupArgument: Enabled: false RSpec/MultipleExpectations: Enabled: false +RSpec/MultipleMemoizedHelpers: + Enabled: false +RSpec/MultipleSubjects: + Enabled: false RSpec/NestedGroups: Enabled: false +RSpec/PredicateMatcher: + Enabled: false +RSpec/ReceiveCounts: + Enabled: false +RSpec/ReceiveNever: + Enabled: false +RSpec/RepeatedExampleGroupBody: + Enabled: false +RSpec/RepeatedExampleGroupDescription: + Enabled: false +RSpec/RepeatedIncludeExample: + Enabled: false +RSpec/ReturnFromStub: + Enabled: false +RSpec/SharedExamples: + Enabled: false +RSpec/StubbedMock: + Enabled: false +RSpec/UnspecifiedException: + Enabled: false +RSpec/VariableDefinition: + Enabled: false +RSpec/VoidExpect: + Enabled: false +RSpec/Yield: + Enabled: false +Security/Open: + Enabled: false +Style/AccessModifierDeclarations: + Enabled: false +Style/AccessorGrouping: + Enabled: false Style/AsciiComments: Enabled: false +Style/BisectedAttrAccessor: + Enabled: false +Style/CaseLikeIf: + Enabled: false +Style/ClassEqualityComparison: + Enabled: false +Style/ColonMethodDefinition: + Enabled: false +Style/CombinableLoops: + Enabled: false +Style/CommentedKeyword: + Enabled: false +Style/Dir: + Enabled: false +Style/DoubleCopDisableDirective: + Enabled: false +Style/EmptyBlockParameter: + Enabled: false +Style/EmptyLambdaParameter: + Enabled: false +Style/Encoding: + Enabled: false +Style/EvalWithLocation: + Enabled: false +Style/ExpandPathArguments: + Enabled: false +Style/ExplicitBlockArgument: + Enabled: false +Style/ExponentialNotation: + Enabled: false +Style/FloatDivision: + Enabled: false +Style/FrozenStringLiteralComment: + Enabled: false +Style/GlobalStdStream: + Enabled: false +Style/HashAsLastArrayItem: + Enabled: false +Style/HashLikeCase: + Enabled: false +Style/HashTransformKeys: + Enabled: false +Style/HashTransformValues: + Enabled: false Style/IfUnlessModifier: Enabled: false +Style/KeywordParametersOrder: + Enabled: false +Style/MinMax: + Enabled: false +Style/MixinUsage: + Enabled: false +Style/MultilineWhenThen: + Enabled: false +Style/NegatedUnless: + Enabled: false +Style/NumericPredicate: + Enabled: false +Style/OptionalBooleanParameter: + Enabled: false +Style/OrAssignment: + Enabled: false +Style/RandomWithOffset: + Enabled: false +Style/RedundantAssignment: + Enabled: false +Style/RedundantCondition: + Enabled: false +Style/RedundantConditional: + Enabled: false +Style/RedundantFetchBlock: + Enabled: false +Style/RedundantFileExtensionInRequire: + Enabled: false +Style/RedundantRegexpCharacterClass: + Enabled: false +Style/RedundantRegexpEscape: + Enabled: false +Style/RedundantSelfAssignment: + Enabled: false +Style/RedundantSort: + Enabled: false +Style/RescueStandardError: + Enabled: false +Style/SingleArgumentDig: + Enabled: false +Style/SlicingWithRange: + Enabled: false +Style/SoleNestedConditional: + Enabled: false +Style/StderrPuts: + Enabled: false +Style/StringConcatenation: + Enabled: false +Style/Strip: + Enabled: false Style/SymbolProc: Enabled: false +Style/TrailingBodyOnClass: + Enabled: false +Style/TrailingBodyOnMethodDefinition: + Enabled: false +Style/TrailingBodyOnModule: + Enabled: false +Style/TrailingCommaInHashLiteral: + Enabled: false +Style/TrailingMethodEndStatement: + Enabled: false +Style/UnpackFirst: + Enabled: false +Lint/DuplicateBranch: + Enabled: false +Lint/DuplicateRegexpCharacterClassElement: + Enabled: false +Lint/EmptyBlock: + Enabled: false +Lint/EmptyClass: + Enabled: false +Lint/NoReturnInBeginEndBlocks: + Enabled: false +Lint/ToEnumArguments: + Enabled: false +Lint/UnexpectedBlockArity: + Enabled: false +Lint/UnmodifiedReduceAccumulator: + Enabled: false +Performance/CollectionLiteralInLoop: + Enabled: false +Style/ArgumentsForwarding: + Enabled: false +Style/CollectionCompact: + Enabled: false +Style/DocumentDynamicEvalDefinition: + Enabled: false +Style/NegatedIfElseCondition: + Enabled: false +Style/NilLambda: + Enabled: false +Style/RedundantArgument: + Enabled: false +Style/SwapValues: + Enabled: false diff --git a/.sync.yml b/.sync.yml index e94097d5..008cad1a 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,16 +1,26 @@ --- +common: + disable_legacy_facts: true + appveyor.yml: delete: true .gitlab-ci.yml: delete: true +.gitpod.Dockerfile: + unmanaged: false +.gitpod.yml: + unmanaged: false + .rubocop_todo.yml: delete: true .travis.yml: - simplecov: true - deploy: true + dist: focal + simplecov: false + before_install_pre: + - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin || true user: rehanone secure: "WiS9j4aI93DobVH/O/z6aHKOY8UL2hwn4+fflKuhvZzJPxfsYYfvQsyX43qetpVAIW7DCZLfO1QQlLF1/ywhe8Y9XRy923R6E7WckYPCGtGBpeTdS7p3Biss2H+ikxI9/5UFlewrdFxLxqgKz8lGLCt8zL1r7ggPWjJBfWEBtk2J9mj4BRTTGt6SWTSHwkdqjloQsPu32SXWY4nsU+87p+lO49YTOH2cS+54/DRCpccPl2AL+kXISDGiDZtlMyGdL2c0Z1e8etmOxbHN2X80YyOQY2GiKdGhzVfx5TDPElDXkOO5JkkZWmsz2D6BJYvu+s9awIJ6/pzGFDghZIK2MSgfUjJd9Vwt1lm48kHKsJ3DsSRIOHK+2ft/3nUl8y7j7KKQMcKKVN35/0uy/cXnD4acuxCh84e5bc0pmYy0gxLhLF6C9Ahv8pls7HhA+jaoUBNXIgCb685w6EgrkaeGMx1vz7VfZo56viod/zZ7XCXg8o5s7vthKMtYLnuGIEl2DvBC3KKtGvl4RnzFVUcZcB5lHgLZozskcwuWFtqd/AgqdIVRzKc6KmRWo8TkE/qOV79MaUpKGONmLMQfsz01HMn4m/NAmu4J55kFgFYkrkwy+9c/3Z9Ytce7goOnyxYYd0fFfaSM8vJCl7oe8Zb3znK2atMmpQAfDwYBwUNe1jU=" docker_sets: @@ -23,17 +33,63 @@ appveyor.yml: - set: docker/debian-8 - set: docker/centos-8 - set: docker/centos-7 + - set: docker/opensuse-15 + docker_defaults: + dist: focal + branches: + - master + remove_branches: + - main + +.pdkignore: + paths: + - /.editorconfig Gemfile: required: + ':development': + - gem: 'puppet-lint-absolute_template_path' + - gem: 'puppet-lint-absolute_classname-check' + - gem: 'puppet-lint-alias-check' + - gem: 'puppet-lint-classes_and_types_beginning_with_digits-check' + - gem: 'puppet-lint-concatenated_template_files-check' + - gem: 'puppet-lint-file_ensure-check' + - gem: 'puppet-lint-file_source_rights-check' + - gem: 'puppet-lint-leading_zero-check' + - gem: 'puppet-lint-resource_reference_syntax' + - gem: 'puppet-lint-strict_indent-check' + - gem: 'puppet-lint-top_scope_facts-check' + - gem: 'puppet-lint-topscope-variable-check' + - gem: 'puppet-lint-trailing_comma-check' + - gem: 'puppet-lint-unquoted_string-check' + - gem: 'puppet-lint-variable_contains_upcase' + - gem: 'puppet-lint-version_comparison-check' + # https://github.com/puppetlabs/pdk-templates#enabling-beaker-system-tests ':system_tests': - gem: 'puppet-module-posix-system-r#{minor_version}' + version: '~> 1.0' platforms: ruby - gem: 'puppet-module-win-system-r#{minor_version}' + version: '~> 1.0' platforms: - mswin - mingw - x64_mingw + - gem: 'beaker' + version: '~> 4.0' + - gem: 'beaker-hostgenerator' + - gem: 'beaker-puppet' + - gem: 'beaker-puppet_install_helper' + - gem: 'beaker-module_install_helper' + - gem: 'beaker-rspec' + - gem: 'beaker-docker' + +Rakefile: + linter_fail_on_warnings: true + +spec/spec_helper.rb: + mock_with: ':rspec' + coverage_report: true spec/spec.opts: delete: true diff --git a/.travis.yml b/.travis.yml index 233b1b65..b91eb1d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,10 @@ --- os: linux -dist: xenial +dist: focal language: ruby cache: bundler before_install: + - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin || true - bundle -v - rm -f Gemfile.lock - "# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner" @@ -13,7 +14,7 @@ before_install: - gem --version - bundle -v script: - - 'SIMPLECOV=yes bundle exec rake $CHECK' + - 'bundle exec rake $CHECK' bundler_args: --without system_tests rvm: - 2.5.7 @@ -29,7 +30,7 @@ jobs: include: - bundler_args: --with system_tests - dist: trusty + dist: focal env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/ubuntu-20.04 BEAKER_TESTMODE=apply rvm: 2.5.7 script: bundle exec rake beaker @@ -38,7 +39,7 @@ jobs: sudo: required - bundler_args: --with system_tests - dist: trusty + dist: focal env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/ubuntu-18.04 BEAKER_TESTMODE=apply rvm: 2.5.7 script: bundle exec rake beaker @@ -47,7 +48,7 @@ jobs: sudo: required - bundler_args: --with system_tests - dist: trusty + dist: focal env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/ubuntu-16.04 BEAKER_TESTMODE=apply rvm: 2.5.7 script: bundle exec rake beaker @@ -56,7 +57,7 @@ jobs: sudo: required - bundler_args: --with system_tests - dist: trusty + dist: focal env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/ubuntu-14.04 BEAKER_TESTMODE=apply rvm: 2.5.7 script: bundle exec rake beaker @@ -65,7 +66,7 @@ jobs: sudo: required - bundler_args: --with system_tests - dist: trusty + dist: focal env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/debian-10 BEAKER_TESTMODE=apply rvm: 2.5.7 script: bundle exec rake beaker @@ -74,7 +75,7 @@ jobs: sudo: required - bundler_args: --with system_tests - dist: trusty + dist: focal env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/debian-9 BEAKER_TESTMODE=apply rvm: 2.5.7 script: bundle exec rake beaker @@ -83,7 +84,7 @@ jobs: sudo: required - bundler_args: --with system_tests - dist: trusty + dist: focal env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/debian-8 BEAKER_TESTMODE=apply rvm: 2.5.7 script: bundle exec rake beaker @@ -92,7 +93,7 @@ jobs: sudo: required - bundler_args: --with system_tests - dist: trusty + dist: focal env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/centos-8 BEAKER_TESTMODE=apply rvm: 2.5.7 script: bundle exec rake beaker @@ -101,20 +102,25 @@ jobs: sudo: required - bundler_args: --with system_tests - dist: trusty + dist: focal env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/centos-7 BEAKER_TESTMODE=apply rvm: 2.5.7 script: bundle exec rake beaker services: docker stage: acceptance sudo: required + - + bundler_args: --with system_tests + dist: focal + env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/opensuse-15 BEAKER_TESTMODE=apply + rvm: 2.5.7 + script: bundle exec rake beaker + services: docker + stage: acceptance + sudo: required - 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.5 - stage: spec - env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec rvm: 2.5.7 @@ -124,8 +130,8 @@ jobs: stage: deploy branches: only: - - master - /^v\d/ + - master notifications: email: false deploy: diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 61777827..2f1e4f73 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,6 +1,6 @@ { "recommendations": [ - "jpogran.puppet-vscode", + "puppet.puppet-vscode", "rebornix.Ruby" ] } diff --git a/CHANGELOG.md b/CHANGELOG.md index 725fda9e..ac1c29ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,18 +1,18 @@ ## 2.3.2 (May 1, 2020) -Improvements: +**Improvements:** - Added support for Ubuntu 20.04. ## 2.3.1 (April 12, 2020) -Improvements: +**Improvements:** - Updated `pdk` templates. ## 2.3.0 (February 14, 2020) -Improvements: +**Improvements:** - Added support for CentOS 8. - Updated os support matrix. @@ -20,7 +20,7 @@ Improvements: ## 2.2.0 (August 25, 2019) -Improvements: +**Improvements:** - Added support for Debian 10. - Updated os support matrix. @@ -28,7 +28,7 @@ Improvements: ## 2.1.3 (June 15, 2019) -Improvements: +**Improvements:** - Updated minimum `puppet` version to 5.5.10. - Updated os support matrix. @@ -36,30 +36,30 @@ Improvements: ## 2.1.2 (January 21, 2019) -Improvements: +**Improvements:** - Change the default value for override_template from `true` to `false`. This change is due to the upstream PR [#7498](https://github.com/robbyrussell/oh-my-zsh/pull/7498). ## 2.1.1 (January 5, 2019) -Bugfixes: +**Bugfixes:** - Fix the issue with multiple line replacement for plugins section in the zshrc template. [#14](https://github.com/rehanone/puppet-ohmyzsh/pull/14) -Improvements: +**Improvements:** - Updated `pdk` templates. ## 2.1.0 (October 14, 2018) -Improvements: +**Improvements:** - Updated `pdk` templates. - Added support for `puppet` version 6. ## 2.0.5 (September 1, 2018) -Improvements: +**Improvements:** - Updated `pdk` templates. - Added tests for Ubuntu 18.04 release. @@ -68,13 +68,13 @@ Improvements: ## 2.0.4 (May 19, 2018) -Improvements: +**Improvements:** - Updated documentation. ## 2.0.3 (May 9, 2018) -Improvements: +**Improvements:** - Updated `pdk` templates. - Updated minimum required `puppet` version to `4.10.0`. @@ -82,23 +82,23 @@ Improvements: ## 2.0.2 (April 23, 2018) -Improvements: +**Improvements:** - Updated module data to `hiera 5`. - Improved acceptance tests. ## 2.0.1 (April 22, 2018) -Improvements: +**Improvements:** - Updated documentation. -Bugfixes: +**Bugfixes:** - Fixed the dependency cycle issues. ## 2.0.0 (April 22, 2018) -Features: +**Features:** - Initial release diff --git a/Gemfile b/Gemfile index 57770cbd..405d33c1 100644 --- a/Gemfile +++ b/Gemfile @@ -17,21 +17,41 @@ 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 "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 "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 "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 2.8.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "puppet-module-posix-default-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby] + gem "puppet-module-posix-dev-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby] + gem "puppet-module-win-default-r#{minor_version}", '~> 1.0', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "puppet-module-win-dev-r#{minor_version}", '~> 1.0', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "puppet-lint-absolute_template_path", require: false + gem "puppet-lint-absolute_classname-check", require: false + gem "puppet-lint-alias-check", require: false + gem "puppet-lint-classes_and_types_beginning_with_digits-check", require: false + gem "puppet-lint-concatenated_template_files-check", require: false + gem "puppet-lint-file_ensure-check", require: false + gem "puppet-lint-file_source_rights-check", require: false + gem "puppet-lint-leading_zero-check", require: false + gem "puppet-lint-resource_reference_syntax", require: false + gem "puppet-lint-strict_indent-check", require: false + gem "puppet-lint-top_scope_facts-check", require: false + gem "puppet-lint-topscope-variable-check", require: false + gem "puppet-lint-trailing_comma-check", require: false + gem "puppet-lint-unquoted_string-check", require: false + gem "puppet-lint-variable_contains_upcase", require: false + gem "puppet-lint-version_comparison-check", require: false + gem "puppet-lint-legacy_facts-check", require: false end group :system_tests do - gem "puppet-module-posix-system-r#{minor_version}", require: false, platforms: [:ruby] - gem "puppet-module-win-system-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "puppet-module-posix-system-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby] + gem "puppet-module-win-system-r#{minor_version}", '~> 1.0', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "beaker", '~> 4.0', require: false + gem "beaker-hostgenerator", require: false + gem "beaker-puppet", require: false + gem "beaker-puppet_install_helper", require: false + gem "beaker-module_install_helper", require: false + gem "beaker-rspec", require: false + gem "beaker-docker", require: false end puppet_version = ENV['PUPPET_GEM_VERSION'] @@ -48,16 +68,6 @@ gems['puppet'] = location_for(puppet_version) 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 diff --git a/README.md b/README.md index 990b20a9..ef638cb8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # rehan-ohmyzsh -[![Puppet Forge](http://img.shields.io/puppetforge/v/rehan/ohmyzsh.svg)](https://forge.puppetlabs.com/rehan/ohmyzsh) [![Build Status](https://travis-ci.org/rehanone/puppet-ohmyzsh.svg?branch=master)](https://travis-ci.org/rehanone/puppet-ohmyzsh) +[![Puppet Forge](http://img.shields.io/puppetforge/v/rehan/ohmyzsh.svg)](https://forge.puppetlabs.com/rehan/ohmyzsh) [![Build Status](https://travis-ci.com/rehanone/puppet-ohmyzsh.svg?branch=master)](https://travis-ci.com/rehanone/puppet-ohmyzsh) #### Table of Contents 1. [Overview](#overview) diff --git a/Rakefile b/Rakefile index cb7ed0cc..46697826 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,6 @@ # frozen_string_literal: true +require 'bundler' 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' @@ -41,6 +42,7 @@ def changelog_future_release end PuppetLint.configuration.send('disable_relative') +PuppetLint.configuration.fail_on_warnings = true if Bundler.rubygems.find_name('github_changelog_generator').any? GitHubChangelogGenerator::RakeTask.new :changelog do |config| @@ -52,7 +54,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", @@ -60,11 +62,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 @@ -72,16 +74,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/manifests/fetch/theme.pp b/manifests/fetch/theme.pp index 7a3af586..5f62c08b 100644 --- a/manifests/fetch/theme.pp +++ b/manifests/fetch/theme.pp @@ -33,16 +33,20 @@ } } elsif $source != undef { file { $fullpath: - ensure => present, + ensure => file, source => $source, owner => $name, + group => $name, + mode => '0644', require => File[$themepath], } } elsif $content != undef { file { $fullpath: - ensure => present, + ensure => file, content => $content, owner => $name, + group => $name, + mode => '0644', require => File[$themepath], } } else { diff --git a/manifests/install.pp b/manifests/install.pp index 30a93a82..1233a889 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -22,23 +22,22 @@ # # Copyright 2014 # -define ohmyzsh::install( - Enum[present, latest] - $ensure = latest, - Boolean $set_sh = false, - Boolean $disable_auto_update = false, - Boolean $override_template = false, +define ohmyzsh::install ( + Enum[present, latest] $ensure = latest, + Boolean $set_sh = false, + Boolean $disable_auto_update = false, + Boolean $override_template = false, ) { include ohmyzsh - if ! defined(Package['git']) { + if !defined(Package['git']) { package { 'git': ensure => present, } } - if ! defined(Package['zsh']) { + if !defined(Package['zsh']) { package { 'zsh': ensure => present, } @@ -82,7 +81,7 @@ } if $set_sh { - if ! defined(User[$name]) { + if !defined(User[$name]) { user { "ohmyzsh::user ${name}": ensure => present, name => $name, diff --git a/manifests/plugins.pp b/manifests/plugins.pp index 32bee5bb..aec1505b 100644 --- a/manifests/plugins.pp +++ b/manifests/plugins.pp @@ -25,9 +25,9 @@ Array[String] $plugins = ['git'], Hash[String, Struct[{ - source => Enum[git], - url => Stdlib::Httpsurl, - ensure => Enum[present, latest] + source => Enum[git], + url => Stdlib::Httpsurl, + ensure => Enum[present, latest] }] ] $custom_plugins = {}, ) { @@ -60,6 +60,6 @@ path => "${home}/.zshrc", line => "plugins=(${plugins_real})", match => '^plugins=', - require => Ohmyzsh::Install[$name] + require => Ohmyzsh::Install[$name], } } diff --git a/manifests/theme.pp b/manifests/theme.pp index 87f6f19d..97577b50 100644 --- a/manifests/theme.pp +++ b/manifests/theme.pp @@ -37,7 +37,6 @@ path => "${home}/.zshrc", line => "ZSH_THEME=\"${theme}\"", match => '^ZSH_THEME', - require => Ohmyzsh::Install[$name] + require => Ohmyzsh::Install[$name], } - } diff --git a/metadata.json b/metadata.json index 71319e75..06c42b3d 100644 --- a/metadata.json +++ b/metadata.json @@ -10,11 +10,11 @@ "dependencies": [ { "name": "puppetlabs-stdlib", - "version_requirement": ">= 5.0.0 < 7.0.0" + "version_requirement": ">= 5.0.0 < 8.0.0" }, { "name": "puppetlabs-vcsrepo", - "version_requirement": ">= 2.0.0 < 4.0.0" + "version_requirement": ">= 2.0.0 < 5.0.0" }, { "name": "rehan-wget", @@ -65,7 +65,6 @@ { "operatingsystem": "SLES", "operatingsystemrelease": [ - "11", "12", "15" ] @@ -84,18 +83,15 @@ "14.04", "16.04", "18.04", - "18.10", - "19.04", - "19.10", "20.04" ] }, { "operatingsystem": "FreeBSD", "operatingsystemrelease": [ - "10", "11", - "12" + "12", + "13" ] }, { @@ -109,7 +105,8 @@ "5.0", "5.2", "5.4", - "5.6" + "5.6", + "5.8" ] }, { @@ -119,7 +116,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 5.5.10 < 7.0.0" + "version_requirement": ">= 5.5.10 < 8.0.0" } ], "tags": [ @@ -127,7 +124,7 @@ "ohmyzsh", "oh-my-zsh" ], - "pdk-version": "1.17.0", - "template-url": "pdk-default#1.17.0", - "template-ref": "tags/1.17.0-0-gd3a4319" + "pdk-version": "2.1.0", + "template-url": "pdk-default#2.1.0", + "template-ref": "tags/2.1.0-0-ga675ea5" } diff --git a/spec/acceptance/nodesets/docker/opensuse-15.yml b/spec/acceptance/nodesets/docker/opensuse-15.yml new file mode 100644 index 00000000..8fcc2abe --- /dev/null +++ b/spec/acceptance/nodesets/docker/opensuse-15.yml @@ -0,0 +1,13 @@ +HOSTS: + opensuse15-64: + docker_cmd: '["/usr/lib/systemd/systemd", "--system"]' + image: opensuse/leap:15 + platform: sles-15-x64 + packaging_platform: sles-15-x64 + docker_image_commands: + - zypper --non-interactive --no-gpg-checks install wget gzip + - wget https://yum.puppet.com/puppet6-release-sles-15.noarch.rpm + - zypper --non-interactive --no-gpg-checks install puppet6-release-sles-15.noarch.rpm + - zypper --non-interactive --no-gpg-checks install puppet-agent + hypervisor: docker + roles: [] diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 35a1408c..16764b6f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,9 @@ # frozen_string_literal: true +RSpec.configure do |c| + c.mock_with :rspec +end + require 'puppetlabs_spec_helper/module_spec_helper' require 'rspec-puppet-facts' @@ -38,9 +42,11 @@ # 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 + RSpec::Puppet::Coverage.report!(0) end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index ff7fe1db..35fb3da1 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,15 +1,15 @@ -require 'puppet' require 'beaker-rspec' +require 'beaker-puppet' require 'beaker/puppet_install_helper' require 'beaker/module_install_helper' -run_puppet_install_helper -install_ca_certs unless ENV['PUPPET_INSTALL_TYPE'] =~ %r{pe}i +UNSUPPORTED_PLATFORMS = ['windows', 'darwin'].freeze + +run_puppet_install_helper unless ENV['BEAKER_provision'] == 'no' +install_ca_certs unless ENV['PUPPET_INSTALL_TYPE'].match?(%r{pe}i) install_module_on(hosts) install_module_dependencies_on(hosts) -UNSUPPORTED_PLATFORMS = ['RedHat', 'Suse', 'windows', 'AIX', 'Solaris'].freeze - RSpec.configure do |c| # Readable test descriptions c.formatter = :documentation @@ -22,35 +22,3 @@ def return_puppet_version (on default, puppet('--version')).output.chomp end - -RSpec.shared_context 'with faked facts' do - let(:facts_d) do - puppet_version = return_puppet_version - if fact('osfamily') =~ %r{windows}i - if fact('kernelmajversion').to_f < 6.0 - 'C:/Documents and Settings/All Users/Application Data/PuppetLabs/facter/facts.d' - else - 'C:/ProgramData/PuppetLabs/facter/facts.d' - end - elsif Puppet::Util::Package.versioncmp(puppet_version, '4.0.0') < 0 && fact('is_pe', '--puppet') == 'true' - '/etc/puppetlabs/facter/facts.d' - else - '/etc/facter/facts.d' - end - end - - before :each do - # No need to create on windows, PE creates by default - if fact('osfamily') !~ %r{windows}i - shell("mkdir -p '#{facts_d}'") - end - end - - after :each do - shell("rm -f '#{facts_d}/fqdn.txt'", acceptable_exit_codes: [0, 1]) - end - - def fake_fact(name, value) - shell("echo #{name}=#{value} > '#{facts_d}/#{name}.txt'") - end -end