diff options
author | Bobosila Victor <vbobosila1@gmail.com> | 2021-09-24 13:18:41 +0300 |
---|---|---|
committer | Bobosila Victor <vbobosila1@gmail.com> | 2021-09-30 14:30:03 +0300 |
commit | ec516a229afbedb0eefe401a8eefecc27004f6ac (patch) | |
tree | 5beb73211d54f6020d882a172e716bccf04fe748 | |
parent | 0d92e9f24280df1082ec8dfa2baf8778b853e0ca (diff) | |
download | puppet-augeas_core-ec516a229afbedb0eefe401a8eefecc27004f6ac.tar.gz puppet-augeas_core-ec516a229afbedb0eefe401a8eefecc27004f6ac.tar.bz2 |
(MODULES-11197) Update puppetlabs-augeas_core to latest pdk template
Also updated `.sync` file to include the `auto_release.yml` workflow
-rw-r--r-- | .devcontainer/Dockerfile | 6 | ||||
-rw-r--r-- | .devcontainer/devcontainer.json | 23 | ||||
-rw-r--r-- | .github/workflows/auto_release.yml | 84 | ||||
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | .gitlab-ci.yml | 41 | ||||
-rw-r--r-- | .pdkignore | 5 | ||||
-rw-r--r-- | .rubocop.yml | 419 | ||||
-rw-r--r-- | .sync.yml | 36 | ||||
-rw-r--r-- | Gemfile | 58 | ||||
-rw-r--r-- | Rakefile | 41 | ||||
-rw-r--r-- | lib/puppet/provider/augeas/augeas.rb | 72 | ||||
-rw-r--r-- | lib/puppet/type/augeas.rb | 2 | ||||
-rw-r--r-- | lib/puppet_x/augeas/util/parser.rb | 62 | ||||
-rw-r--r-- | metadata.json | 6 | ||||
-rw-r--r-- | rakelib/commits.rake | 25 | ||||
-rw-r--r-- | spec/spec_helper.rb | 20 | ||||
-rw-r--r-- | spec/unit/puppet_x/augeas/util/parser_spec.rb | 3 | ||||
-rw-r--r-- | spec/unit/type/augeas_spec.rb | 8 |
18 files changed, 686 insertions, 226 deletions
diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..12ed4ff --- /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 <your-package-list-here> + diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..f1a55dc --- /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/.github/workflows/auto_release.yml b/.github/workflows/auto_release.yml new file mode 100644 index 0000000..e028483 --- /dev/null +++ b/.github/workflows/auto_release.yml @@ -0,0 +1,84 @@ +name: "Auto release" + +on: + workflow_dispatch: + +env: + HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6 + HONEYCOMB_DATASET: litmus tests + CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + auto_release: + name: "Automatic release prep" + runs-on: ubuntu-20.04 + + steps: + - name: "Honeycomb: Start recording" + uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1 + with: + apikey: ${{ env.HONEYCOMB_WRITEKEY }} + dataset: ${{ env.HONEYCOMB_DATASET }} + job-status: ${{ job.status }} + + - name: "Honeycomb: start first step" + run: | + echo STEP_ID="auto-release" >> $GITHUB_ENV + echo STEP_START=$(date +%s) >> $GITHUB_ENV + + - name: "Checkout Source" + if: ${{ github.repository_owner == 'puppetlabs' }} + uses: actions/checkout@v2 + with: + fetch-depth: 0 + persist-credentials: false + + - name: "PDK Release prep" + uses: docker://puppet/iac_release:ci + with: + args: 'release prep --force' + env: + CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: "Get Version" + if: ${{ github.repository_owner == 'puppetlabs' }} + id: gv + run: | + echo "::set-output name=ver::$(jq --raw-output .version metadata.json)" + + - name: "Commit changes" + if: ${{ github.repository_owner == 'puppetlabs' }} + run: | + git config --local user.email "${{ github.repository_owner }}@users.noreply.github.com" + git config --local user.name "GitHub Action" + git add . + git commit -m "Release prep v${{ steps.gv.outputs.ver }}" + + - name: Create Pull Request + id: cpr + uses: puppetlabs/peter-evans-create-pull-request@v3 + if: ${{ github.repository_owner == 'puppetlabs' }} + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "Release prep v${{ steps.gv.outputs.ver }}" + branch: "release-prep" + delete-branch: true + title: "Release prep v${{ steps.gv.outputs.ver }}" + body: | + Automated release-prep through [pdk-templates](https://github.com/puppetlabs/pdk-templates/blob/main/moduleroot/.github/workflows/auto_release.yml.erb) from commit ${{ github.sha }}. + Please verify before merging: + - [ ] last [nightly](https://github.com/${{ github.repository }}/actions/workflows/nightly.yml) run is green + - [ ] [Changelog](https://github.com/${{ github.repository }}/blob/release-prep/CHANGELOG.md) is readable and has no unlabeled pull requests + - [ ] Ensure the [changelog](https://github.com/${{ github.repository }}/blob/release-prep/CHANGELOG.md) version and [metadata](https://github.com/${{ github.repository }}/blob/release-prep/metadata.json) version match + labels: "maintenance" + + - name: PR outputs + if: ${{ github.repository_owner == 'puppetlabs' }} + run: | + echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" + + - name: "Honeycomb: Record finish step" + if: ${{ always() }} + run: | + buildevents step $TRACE_ID $STEP_ID $STEP_START 'Finished auto release workflow' @@ -25,3 +25,4 @@ .project .envrc /inventory.yaml +/spec/fixtures/litmus_inventory.yaml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 81e6d76..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- -stages: - - syntax - - unit - -cache: - paths: - - vendor/bundle - -before_script: - - bundle -v - - rm Gemfile.lock || true - - gem update --system $RUBYGEMS_VERSION - - gem --version - - bundle -v - - bundle install --without system_tests --path vendor/bundle --jobs $(nproc) - -syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop-Ruby 2.5.3-Puppet ~> 6: - stage: syntax - image: ruby:2.5.3 - script: - - bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop - variables: - PUPPET_GEM_VERSION: '~> 6' - -parallel_spec-Ruby 2.5.3-Puppet ~> 6: - stage: unit - image: ruby:2.5.3 - script: - - bundle exec rake parallel_spec - variables: - PUPPET_GEM_VERSION: '~> 6' - -parallel_spec-Ruby 2.4.5-Puppet ~> 5: - stage: unit - image: ruby:2.4.5 - script: - - bundle exec rake parallel_spec - variables: - PUPPET_GEM_VERSION: '~> 5' - @@ -25,13 +25,16 @@ .project .envrc /inventory.yaml +/spec/fixtures/litmus_inventory.yaml /appveyor.yml +/.editorconfig /.fixtures.yml /Gemfile /.gitattributes /.gitignore /.gitlab-ci.yml /.pdkignore +/.puppet-lint.rc /Rakefile /rakelib/ /.rspec @@ -40,3 +43,5 @@ /.yardopts /spec/ /.vscode/ +/.sync.yml +/.devcontainer/ diff --git a/.rubocop.yml b/.rubocop.yml index ef46b51..8a8251f 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,17 +18,9 @@ AllCops: - "**/Puppetfile" - "**/Vagrantfile" - "**/Guardfile" -Metrics/LineLength: +Layout/LineLength: Description: People have wide screens, use them. Max: 200 - Enabled: false -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. @@ -37,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. @@ -69,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 @@ -82,6 +77,8 @@ Layout/IndentHeredoc: Enabled: false Metrics/BlockNesting: Enabled: false +Metrics/LineLength: + Enabled: false Style/AccessorMethodName: Enabled: false Style/DoubleNegation: @@ -102,20 +99,164 @@ 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 -GetText/DecorateStringFormattingUsingInterpolation: +Layout/ArgumentAlignment: Enabled: false -GetText/DecorateStringFormattingUsingPercent: +Layout/BeginEndAlignment: + Enabled: false +Layout/ClosingHeredocIndentation: + Enabled: false +Layout/EmptyComment: + Enabled: false +Layout/EmptyLineAfterGuardClause: + Enabled: false +Layout/EmptyLinesAroundArguments: + Enabled: false +Layout/EmptyLinesAroundAttributeAccessor: Enabled: false Layout/EndOfLine: Enabled: false +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: @@ -132,19 +273,263 @@ 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/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 @@ -24,26 +24,13 @@ Enabled: false Gemfile: optional: - ':development': - - gem: 'github_changelog_generator' - git: 'https://github.com/skywinder/github-changelog-generator' - ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018' - condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')" - required: - ':system_tests': - - gem: 'puppet-module-posix-system-r#{minor_version}' - platforms: ruby - - gem: 'puppet-module-win-system-r#{minor_version}' - platforms: - - mswin - - mingw - - x64_mingw + ":development": - gem: beaker - version: '~> 3.34' + version: '~> 4.30' from_env: BEAKER_VERSION - gem: beaker-abs from_env: BEAKER_ABS_VERSION - version: '~> 0.5' + version: '~> 0.9' - gem: beaker-pe - gem: beaker-hostgenerator from_env: BEAKER_HOSTGENERATOR_VERSION @@ -51,9 +38,20 @@ Gemfile: from_env: BEAKER_RSPEC_VERSION - gem: beaker-puppet from_env: BEAKER_PUPPET_VERSION - version: '~> 0.16' - ':development': - - gem: puppet-strings + version: '~> 1.22' + - gem: github_changelog_generator + - gem: beaker-module_install_helper + - gem: beaker-puppet_install_helper + - gem: nokogiri + +appveyor.yml: + delete: true +.travis.yml: + delete: true +.github/workflows/auto_release.yml: + unmanaged: false +.gitlab-ci.yml: + delete: true Rakefile: changelog_version_tag_pattern: '%s' @@ -17,41 +17,27 @@ ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments minor_version = ruby_version_segments[0..1].join('.') group :development do - gem "parallel_tests", '>= 2.14.1', '< 2.14.3', require: false - gem "metadata-json-lint", '>= 2.0.2', '< 3.0.0', require: false - gem "rspec-puppet-facts", '~> 1.10.0', require: false - gem "rspec_junit_formatter", '~> 0.2', require: false - gem "rubocop", '~> 0.49.0', require: false - gem "rubocop-rspec", '~> 1.16.0', require: false - gem "rubocop-i18n", '~> 1.2.0', require: false - gem "puppetlabs_spec_helper", '>= 2.9.0', '< 3.0.0', require: false - gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') - gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') - gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') - gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') - gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-posix-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby] - gem "puppet-module-win-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-strings", require: false - gem "github_changelog_generator", require: false, git: 'https://github.com/skywinder/github-changelog-generator', ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018' if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2') -end - -group :system_tests do - gem "puppet-module-posix-system-r#{minor_version}", '~> 0.5', require: false, platforms: [:ruby] - gem "puppet-module-win-system-r#{minor_version}", '~> 0.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 4') - gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.5') + 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 "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 4.30') + gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.9') gem "beaker-pe", require: false gem "beaker-hostgenerator" gem "beaker-rspec" - gem "beaker-puppet", *location_for(ENV['BEAKER_PUPPET_VERSION'] || '~> 1.0') + gem "beaker-puppet", *location_for(ENV['BEAKER_PUPPET_VERSION'] || '~> 1.22') + gem "github_changelog_generator", require: false + gem "beaker-module_install_helper", require: false + gem "beaker-puppet_install_helper", require: false + gem "nokogiri", require: false end - -group :release do - gem "puppet-blacksmith", '~> 3.4', require: false - gem "pdk", *location_for(ENV['PDK_VERSION'] || '~> 2') +group :system_tests do + 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] end puppet_version = ENV['PUPPET_GEM_VERSION'] @@ -68,16 +54,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 @@ -1,3 +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' @@ -50,7 +53,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", @@ -58,11 +61,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 @@ -70,42 +73,16 @@ else desc 'Generate a Changelog from GitHub' task :changelog do raise <<EOM -The changelog tasks depends on unreleased features of the github_changelog_generator gem. +The changelog tasks depends on recent features of the github_changelog_generator gem. Please manually add it to your .sync.yml for now, and run `pdk update`: --- Gemfile: optional: ':development': - gem: 'github_changelog_generator' - git: 'https://github.com/skywinder/github-changelog-generator' - ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018' - condition: "Gem::Version.new(RUBY_VERSION.dup) >= 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 -desc "verify that commit messages match CONTRIBUTING.md requirements" -task(:commits) do - # This rake task looks at the summary from every commit from this branch not - # in the branch targeted for a PR. - commit_range = 'HEAD^..HEAD' - puts "Checking commits #{commit_range}" - %x{git log --no-merges --pretty=%s #{commit_range}}.each_line do |commit_summary| - # This regex tests for the currently supported commit summary tokens. - # The exception tries to explain it in more full. - if /^\((maint|packaging|doc|docs|modules-\d+)\)|revert/i.match(commit_summary).nil? - raise "\n\n\n\tThis commit summary didn't match CONTRIBUTING.md guidelines:\n" \ - "\n\t\t#{commit_summary}\n" \ - "\tThe commit summary (i.e. the first line of the commit message) should start with one of:\n" \ - "\t\t(MODULES-<digits>) # this is most common and should be a ticket at tickets.puppet.com\n" \ - "\t\t(docs)\n" \ - "\t\t(docs)(DOCUMENT-<digits>)\n" \ - "\t\t(packaging)\n" - "\t\t(maint)\n" \ - "\n\tThis test for the commit summary is case-insensitive.\n\n\n" - else - puts "#{commit_summary}" - end - puts "...passed" - end -end diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb index b0a3e4f..8ab6e7a 100644 --- a/lib/puppet/provider/augeas/augeas.rb +++ b/lib/puppet/provider/augeas/augeas.rb @@ -86,7 +86,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do sc = StringScanner.new(line) cmd = sc.scan(%r{\w+|==|!=}) formals = COMMANDS[cmd] - fail(_('Unknown command %{cmd}') % { cmd: cmd }) unless formals + raise(_('Unknown command %{cmd}') % { cmd: cmd }) unless formals argline << cmd narg = 0 formals.each do |f| @@ -104,13 +104,13 @@ Puppet::Type.type(:augeas).provide(:augeas) do nbracket -= 1 if ch == ']' inSingleTick = !inSingleTick if ch == "'" inDoubleTick = !inDoubleTick if ch == '"' - fail(_('unmatched [')) if nbracket < 0 + raise(_('unmatched [')) if nbracket < 0 break if (nbracket == 0 && !inSingleTick && !inDoubleTick && (ch =~ %r{\s})) || sc.eos? end len = sc.pos - start len -= 1 unless sc.eos? p = sc.string[start, len] - fail(_('missing path argument %{narg} for %{cmd}') % { narg: narg, cmd: cmd }) if p.nil? + raise(_('missing path argument %{narg} for %{cmd}') % { narg: narg, cmd: cmd }) if p.nil? # Rip off any ticks if they are there. p = p[1, (p.size - 2)] if p[0, 1] == "'" || p[0, 1] == '"' @@ -122,7 +122,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do end elsif f == :string delim = sc.peek(1) - if delim == "'" || delim == '"' + if ["'", '"'].include?(delim) sc.getch argline << sc.scan(%r{([^\\#{delim}]|(\\.))*}) # Unescape the delimiter so it's actually possible to have a @@ -136,12 +136,12 @@ Puppet::Type.type(:augeas).provide(:augeas) do else argline << sc.scan(%r{[^\s]+}) end - fail(_('missing string argument %{narg} for %{cmd}') % { narg: narg, cmd: cmd }) unless argline[-1] + raise(_('missing string argument %{narg} for %{cmd}') % { narg: narg, cmd: cmd }) unless argline[-1] elsif f == :comparator argline << sc.scan(%r{(==|!=|=~|<=|>=|<|>)}) unless argline[-1] puts sc.rest - fail(_('invalid comparator for command %{cmd}') % { cmd: cmd }) + raise(_('invalid comparator for command %{cmd}') % { cmd: cmd }) end elsif f == :int argline << sc.scan(%r{\d+}).to_i @@ -227,7 +227,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do return_value = false # validate and tear apart the command - fail(_('Invalid command: %{cmd}') % { cmd: cmd_array.join(' ') }) if cmd_array.length < 4 + raise(_('Invalid command: %{cmd}') % { cmd: cmd_array.join(' ') }) if cmd_array.length < 4 _ = cmd_array.shift path = cmd_array.shift comparator = cmd_array.shift @@ -258,7 +258,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do return_value = false # validate and tear apart the command - fail(_('Invalid command: %{cmd}') % { cmd: cmd_array.join(' ') }) if cmd_array.length < 3 + raise(_('Invalid command: %{cmd}') % { cmd: cmd_array.join(' ') }) if cmd_array.length < 3 _ = cmd_array.shift path = cmd_array.shift @@ -268,7 +268,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do # Get the match paths from augeas result = @aug.match(path) || [] - fail(_("Error trying to get path '%{path}'") % { path: path }) if result == -1 + raise(_("Error trying to get path '%{path}'") % { path: path }) if result == -1 # Get the values of the match paths from augeas values = result.map { |r| @aug.get(r) } @@ -286,7 +286,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do new_array = parse_to_array(arg) return_value = (values == new_array) rescue - fail(_('Invalid array in command: %{cmd}') % { cmd: cmd_array.join(' ') }) + raise(_('Invalid array in command: %{cmd}') % { cmd: cmd_array.join(' ') }) end when '!=' begin @@ -294,7 +294,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do new_array = parse_to_array(arg) return_value = (values != new_array) rescue - fail(_('Invalid array in command: %{cmd}') % { cmd: cmd_array.join(' ') }) + raise(_('Invalid array in command: %{cmd}') % { cmd: cmd_array.join(' ') }) end end !!return_value @@ -306,7 +306,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do return_value = false # validate and tear apart the command - fail(_('Invalid command: %{cmd}') % { cmd: cmd_array.join(' ') }) if cmd_array.length < 3 + raise(_('Invalid command: %{cmd}') % { cmd: cmd_array.join(' ') }) if cmd_array.length < 3 _ = cmd_array.shift path = cmd_array.shift @@ -316,12 +316,12 @@ Puppet::Type.type(:augeas).provide(:augeas) do # Get the values from augeas result = @aug.match(path) || [] - fail(_("Error trying to match path '%{path}'") % { path: path }) if result == -1 + raise(_("Error trying to match path '%{path}'") % { path: path }) if result == -1 # Now do the work case verb when 'size' - fail(_('Invalid command: %{cmd}') % { cmd: cmd_array.join(' ') }) if clause_array.length != 2 + raise(_('Invalid command: %{cmd}') % { cmd: cmd_array.join(' ') }) if clause_array.length != 2 comparator = clause_array.shift arg = clause_array.shift return_value = case comparator @@ -342,7 +342,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do new_array = parse_to_array(arg) return_value = (result == new_array) rescue - fail(_('Invalid array in command: %{cmd}') % { cmd: cmd_array.join(' ') }) + raise(_('Invalid array in command: %{cmd}') % { cmd: cmd_array.join(' ') }) end when '!=' begin @@ -350,7 +350,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do new_array = parse_to_array(arg) return_value = (result != new_array) rescue - fail(_('Invalid array in command: %{cmd}') % { cmd: cmd_array.join(' ') }) + raise(_('Invalid array in command: %{cmd}') % { cmd: cmd_array.join(' ') }) end end !!return_value @@ -438,7 +438,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do when 'match' then return_value = process_match(cmd_array) end rescue StandardError => e - fail(_("Error sending command '%{command}' with params %{param}/%{message}") % { command: command, param: cmd_array[1..-1].inspect, message: e.message }) + raise(_("Error sending command '%{command}' with params %{param}/%{message}") % { command: command, param: cmd_array[1..-1].inspect, message: e.message }) end end @@ -453,7 +453,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do save_result = @aug.save unless save_result print_put_errors - fail(_('Save failed, see debug output for details')) + raise(Puppet::Error, _('Save failed, see debug output for details')) end saved_files = @aug.match('/augeas/events/saved') @@ -495,7 +495,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do do_execute_changes unless @aug.save print_put_errors - fail(_('Save failed, see debug output for details')) + raise(Puppet::Error, _('Save failed, see debug output for details')) end :executed @@ -508,7 +508,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do def do_execute_changes commands = parse_commands(resource[:changes]) commands.each do |cmd_array| - fail(_('invalid command %{cmd}') % { value0: cmd_array.join[' '] }) if cmd_array.length < 2 + raise(_('invalid command %{cmd}') % { value0: cmd_array.join[' '] }) if cmd_array.length < 2 command = cmd_array[0] cmd_array.shift begin @@ -516,37 +516,37 @@ Puppet::Type.type(:augeas).provide(:augeas) do when 'set' debug("sending command '#{command}' with params #{cmd_array.inspect}") rv = aug.set(cmd_array[0], cmd_array[1]) - fail(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) unless rv + raise(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) unless rv when 'setm' if aug.respond_to?(command) debug("sending command '#{command}' with params #{cmd_array.inspect}") rv = aug.setm(cmd_array[0], cmd_array[1], cmd_array[2]) - fail(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if rv == -1 + raise(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if rv == -1 else - fail(_("command '%{command}' not supported in installed version of ruby-augeas") % { command: command }) + raise(_("command '%{command}' not supported in installed version of ruby-augeas") % { command: command }) end when 'rm', 'remove' debug("sending command '#{command}' with params #{cmd_array.inspect}") rv = aug.rm(cmd_array[0]) - fail(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if rv == -1 + raise(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if rv == -1 when 'clear' debug("sending command '#{command}' with params #{cmd_array.inspect}") rv = aug.clear(cmd_array[0]) - fail(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) unless rv + raise(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) unless rv when 'clearm' # Check command exists ... doesn't currently in ruby-augeas 0.4.1 if aug.respond_to?(command) debug("sending command '#{command}' with params #{cmd_array.inspect}") rv = aug.clearm(cmd_array[0], cmd_array[1]) - fail(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) unless rv + raise(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) unless rv else - fail(_("command '%{command}' not supported in installed version of ruby-augeas") % { command: command }) + raise(_("command '%{command}' not supported in installed version of ruby-augeas") % { command: command }) end when 'touch' debug("sending command '#{command}' (match, set) with params #{cmd_array.inspect}") if aug.match(cmd_array[0]).empty? rv = aug.clear(cmd_array[0]) - fail(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) unless rv + raise(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) unless rv end when 'insert', 'ins' label = cmd_array[0] @@ -555,31 +555,31 @@ Puppet::Type.type(:augeas).provide(:augeas) do case where when 'before' then before = true when 'after' then before = false - else fail(_("Invalid value '%{where}' for where param") % { where: where }) + else raise(_("Invalid value '%{where}' for where param") % { where: where }) end debug("sending command '#{command}' with params #{[label, where, path].inspect}") rv = aug.insert(path, label, before) - fail(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if rv == -1 + raise(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if rv == -1 when 'defvar' debug("sending command '#{command}' with params #{cmd_array.inspect}") rv = aug.defvar(cmd_array[0], cmd_array[1]) - fail(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) unless rv + raise(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) unless rv when 'defnode' debug("sending command '#{command}' with params #{cmd_array.inspect}") rv = aug.defnode(cmd_array[0], cmd_array[1], cmd_array[2]) - fail(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) unless rv + raise(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) unless rv when 'mv', 'move' debug("sending command '#{command}' with params #{cmd_array.inspect}") rv = aug.mv(cmd_array[0], cmd_array[1]) - fail(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if rv == -1 + raise(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if rv == -1 when 'rename' debug("sending command '#{command}' with params #{cmd_array.inspect}") rv = aug.rename(cmd_array[0], cmd_array[1]) - fail(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if rv == -1 - else fail(_("Command '%{command}' is not supported") % { command: command }) + raise(_("Error sending command '%{command}' with params %{params}") % { command: command, params: cmd_array.inspect }) if rv == -1 + else raise(_("Command '%{command}' is not supported") % { command: command }) end rescue StandardError => e - fail(_("Error sending command '%{command}' with params %{params}/%{message}") % { command: command, params: cmd_array.inspect, message: e.message }) + raise(_("Error sending command '%{command}' with params %{params}/%{message}") % { command: command, params: cmd_array.inspect, message: e.message }) end end end diff --git a/lib/puppet/type/augeas.rb b/lib/puppet/type/augeas.rb index 20366f6..37683a2 100644 --- a/lib/puppet/type/augeas.rb +++ b/lib/puppet/type/augeas.rb @@ -162,7 +162,7 @@ Puppet::Type.newtype(:augeas) do validate do has_lens = !self[:lens].nil? has_incl = !self[:incl].nil? - fail(_('You must specify both the lens and incl parameters, or neither.')) if has_lens != has_incl + raise(Puppet::Error, _('You must specify both the lens and incl parameters, or neither.')) if has_lens != has_incl end newparam(:show_diff, boolean: true, parent: Puppet::Parameter::Boolean) do diff --git a/lib/puppet_x/augeas/util/parser.rb b/lib/puppet_x/augeas/util/parser.rb index 1abf42f..271e11c 100644 --- a/lib/puppet_x/augeas/util/parser.rb +++ b/lib/puppet_x/augeas/util/parser.rb @@ -1,27 +1,29 @@ # rubocop:disable Style/Documentation module PuppetX; end + module PuppetX::Augeas; end + module PuppetX::Augeas::Util; end # rubocop:enable Style/Documentation # Container for helpers to parse user provided data contained in manifests. module PuppetX::Augeas::Util::Parser - TOKEN_ARRAY_CLOSE = %r{\s*\]\s*} - TOKEN_ARRAY_OPEN = %r{\s*\[\s*} - TOKEN_ARRAY_SEPARATOR = %r{\s*,\s*} - TOKEN_CLOSE_CURLY = %r|}| - TOKEN_DOUBLE_QUOTE = %r{"} - TOKEN_DOUBLE_QUOTE_ESCAPED_CHAR = %r{\\(["\\abtnvfres0-7xu])} - TOKEN_DOUBLE_QUOTE_UNESCAPED_CHAR = %r{[^"\\]} - TOKEN_HEX_CHAR = %r{[0-9a-fA-F]{1,2}} - TOKEN_OCTAL_CHAR = %r{[0-7]{1,3}} - TOKEN_OPEN_CURLY = %r|{| - TOKEN_SINGLE_QUOTE = %r{'} - TOKEN_SINGLE_QUOTE_ESCAPED_CHAR = %r{\\(['\\])} - TOKEN_SINGLE_QUOTE_UNESCAPED_CHAR = %r{[^'\\]} - TOKEN_SPACE = %r{\s} - TOKEN_UNICODE_LONG_HEX_CHAR = %r{[0-9a-fA-F]{1,6}} - TOKEN_UNICODE_SHORT_HEX_CHAR = %r{[0-9a-fA-F]{4}} + TOKEN_ARRAY_CLOSE = %r{\s*\]\s*}.freeze + TOKEN_ARRAY_OPEN = %r{\s*\[\s*}.freeze + TOKEN_ARRAY_SEPARATOR = %r{\s*,\s*}.freeze + TOKEN_CLOSE_CURLY = %r|}|.freeze + TOKEN_DOUBLE_QUOTE = %r{"}.freeze + TOKEN_DOUBLE_QUOTE_ESCAPED_CHAR = %r{\\(["\\abtnvfres0-7xu])}.freeze + TOKEN_DOUBLE_QUOTE_UNESCAPED_CHAR = %r{[^"\\]}.freeze + TOKEN_HEX_CHAR = %r{[0-9a-fA-F]{1,2}}.freeze + TOKEN_OCTAL_CHAR = %r{[0-7]{1,3}}.freeze + TOKEN_OPEN_CURLY = %r|{|.freeze + TOKEN_SINGLE_QUOTE = %r{'}.freeze + TOKEN_SINGLE_QUOTE_ESCAPED_CHAR = %r{\\(['\\])}.freeze + TOKEN_SINGLE_QUOTE_UNESCAPED_CHAR = %r{[^'\\]}.freeze + TOKEN_SPACE = %r{\s}.freeze + TOKEN_UNICODE_LONG_HEX_CHAR = %r{[0-9a-fA-F]{1,6}}.freeze + TOKEN_UNICODE_SHORT_HEX_CHAR = %r{[0-9a-fA-F]{4}}.freeze # Parse a string into the (nearly) equivalent Ruby array. This only handles # arrays with string members (double-, or single-quoted), and does not @@ -88,34 +90,34 @@ module PuppetX::Augeas::Util::Parser return nil if match.nil? case scanner[1] - when '\\' then return '\\' - when '"' then return '"' - when 'a' then return "\a" - when 'b' then return "\b" - when 't' then return "\t" - when 'n' then return "\n" - when 'v' then return "\v" - when 'f' then return "\f" - when 'r' then return "\r" - when 'e' then return "\e" - when 's' then return "\s" + when '\\' then '\\' + when '"' then '"' + when 'a' then "\a" + when 'b' then "\b" + when 't' then "\t" + when 'n' then "\n" + when 'v' then "\v" + when 'f' then "\f" + when 'r' then "\r" + when 'e' then "\e" + when 's' then "\s" when %r{[0-7]} # Back the scanner up by one byte so we can grab all of the potential # octal digits at the same time. scanner.pos = scanner.pos - 1 octal_character = scanner.scan(TOKEN_OCTAL_CHAR) - return octal_character.to_i(8).chr + octal_character.to_i(8).chr when 'x' hex_character = scanner.scan(TOKEN_HEX_CHAR) return nil if hex_character.nil? hex_character.to_i(16).chr when 'u' - return unicode_short_hex_character(scanner) || unicode_long_hex_characters(scanner) + unicode_short_hex_character(scanner) || unicode_long_hex_characters(scanner) else # Not a valid escape sequence as far as we're concerned. - return nil + nil end end private :double_quote_escaped_char diff --git a/metadata.json b/metadata.json index 835ce0b..4ab4c81 100644 --- a/metadata.json +++ b/metadata.json @@ -45,7 +45,7 @@ "version_requirement": ">= 6.0.0 < 8.0.0" } ], - "pdk-version": "1.14.0", - "template-url": "https://github.com/puppetlabs/pdk-templates#1.14.0", - "template-ref": "1.14.0-0-g1bf3a4e" + "pdk-version": "2.2.0", + "template-url": "https://github.com/puppetlabs/pdk-templates#2.2.0", + "template-ref": "tags/2.2.0-0-g2381db6" } diff --git a/rakelib/commits.rake b/rakelib/commits.rake new file mode 100644 index 0000000..a900ee2 --- /dev/null +++ b/rakelib/commits.rake @@ -0,0 +1,25 @@ +desc "verify that commit messages match CONTRIBUTING.md requirements" +task(:commits) do + # This rake task looks at the summary from every commit from this branch not + # in the branch targeted for a PR. + commit_range = 'HEAD^..HEAD' + puts "Checking commits #{commit_range}" + %x{git log --no-merges --pretty=%s #{commit_range}}.each_line do |commit_summary| + # This regex tests for the currently supported commit summary tokens. + # The exception tries to explain it in more full. + if /^\((maint|packaging|doc|docs|modules-\d+)\)|revert/i.match(commit_summary).nil? + raise "\n\n\n\tThis commit summary didn't match CONTRIBUTING.md guidelines:\n" \ + "\n\t\t#{commit_summary}\n" \ + "\tThe commit summary (i.e. the first line of the commit message) should start with one of:\n" \ + "\t\t(MODULES-<digits>) # this is most common and should be a ticket at tickets.puppet.com\n" \ + "\t\t(docs)\n" \ + "\t\t(docs)(DOCUMENT-<digits>)\n" \ + "\t\t(packaging)\n" + "\t\t(maint)\n" \ + "\n\tThis test for the commit summary is case-insensitive.\n\n\n" + else + puts "#{commit_summary}" + end + puts "...passed" + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 29615cd..9b1fa6f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +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' @@ -31,16 +37,28 @@ default_facts.each do |fact, value| end RSpec.configure do |c| - c.mock_with :rspec c.default_facts = default_facts c.before :each do # set to strictest setting for testing # by default Puppet runs at warning level Puppet.settings[:strict] = :warning + Puppet.settings[:strict_variables] = true end c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] c.after(:suite) do end + + # Filter backtrace noise + backtrace_exclusion_patterns = [ + %r{spec_helper}, + %r{gems}, + ] + + if c.respond_to?(:backtrace_exclusion_patterns) + c.backtrace_exclusion_patterns = backtrace_exclusion_patterns + elsif c.respond_to?(:backtrace_clean_patterns) + c.backtrace_clean_patterns = backtrace_exclusion_patterns + end end # Ensures that a module is defined diff --git a/spec/unit/puppet_x/augeas/util/parser_spec.rb b/spec/unit/puppet_x/augeas/util/parser_spec.rb index f8b5b2b..9769d76 100644 --- a/spec/unit/puppet_x/augeas/util/parser_spec.rb +++ b/spec/unit/puppet_x/augeas/util/parser_spec.rb @@ -92,7 +92,8 @@ describe PuppetX::Augeas::Util::Parser do end it 'allows multi-character unicode hexadecimal character escapes with \\u{...}' do - expect(parse_to_array('["\u{7}", "\u{20}", "\u{100}", "\u{2026}", "\u{1F464}", "\u{100000}", "\u{53 74 72 69 6E 67}"]')).to eq(["\a", ' ', "\u{100}", "\u{2026}", "\u{1F464}", "\u{100000}", 'String']) + expect(parse_to_array('["\u{7}", "\u{20}", "\u{100}", "\u{2026}", "\u{1F464}", "\u{100000}", "\u{53 74 72 69 6E 67}"]')).to eq(["\a", ' ', "\u{100}", "\u{2026}", "\u{1F464}", "\u{100000}", + 'String']) end end diff --git a/spec/unit/type/augeas_spec.rb b/spec/unit/type/augeas_spec.rb index ac3ffa1..f397d74 100644 --- a/spec/unit/type/augeas_spec.rb +++ b/spec/unit/type/augeas_spec.rb @@ -36,21 +36,21 @@ describe augeas do params = [:name, :context, :onlyif, :changes, :root, :load_path, :type_check, :show_diff] properties.each do |property| - it "should have a #{property} property" do + it "has a #{property} property" do expect(augeas.attrclass(property).ancestors).to be_include(Puppet::Property) end - it "should have documentation for its #{property} property" do + it "has documentation for its #{property} property" do expect(augeas.attrclass(property).doc).to be_instance_of(String) end end params.each do |param| - it "should have a #{param} parameter" do + it "has a #{param} parameter" do expect(augeas.attrclass(param).ancestors).to be_include(Puppet::Parameter) end - it "should have documentation for its #{param} parameter" do + it "has documentation for its #{param} parameter" do expect(augeas.attrclass(param).doc).to be_instance_of(String) end end |