diff --git a/.github/workflows/pr_tests.yml b/.github/workflows/pr_tests.yml new file mode 100644 index 0000000..9c689ca --- /dev/null +++ b/.github/workflows/pr_tests.yml @@ -0,0 +1,158 @@ +# Run Puppet checks and test matrix on Pull Requests +# ------------------------------------------------------------------------------ +# NOTICE: **This file is maintained with puppetsync** +# +# This file is updated automatically as part of a puppet module baseline. +# +# The next baseline sync will overwrite any local changes to this file! +# +# ============================================================================== +# +# The testing matrix considers ruby/puppet versions supported by SIMP and PE: +# ------------------------------------------------------------------------------ +# Release Puppet Ruby EOL +# PE 2021.Y 7.x 2.7 2025-02 (LTS) +# PE 2023.Y 8.x 3.2 Biannual updates +# +# https://puppet.com/docs/pe/latest/component_versions_in_recent_pe_releases.html +# https://puppet.com/misc/puppet-enterprise-lifecycle +# ============================================================================== +# +# https://docs.github.com/en/actions/reference/events-that-trigger-workflows +# +--- +name: PR Tests +'on': + pull_request: + types: [opened, reopened, synchronize] + +env: + PUPPET_VERSION: '~> 8' + +jobs: + puppet-syntax: + name: 'Puppet Syntax' + runs-on: ubuntu-latest + env: + BUNDLE_GEMFILE: gem.deps.rb + steps: + - uses: actions/checkout@v3 + - name: "Install Ruby ${{matrix.puppet.ruby_version}}" + uses: ruby/setup-ruby@v1 # ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0 + with: + ruby-version: 3.2 + bundler-cache: true + - run: "bundle exec rake syntax" + + puppet-style: + name: 'Puppet Style' + runs-on: ubuntu-latest + env: + BUNDLE_GEMFILE: gem.deps.rb + steps: + - uses: actions/checkout@v3 + - name: "Install Ruby ${{matrix.puppet.ruby_version}}" + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.2 + bundler-cache: true + - run: "bundle exec rake lint" + - run: "bundle exec rake metadata_lint" + + ruby-style: + name: 'Ruby Style (experimental)' + runs-on: ubuntu-latest + env: + BUNDLE_GEMFILE: gem.deps.rb + steps: + - uses: actions/checkout@v3 + - name: "Install Ruby ${{matrix.puppet.ruby_version}}" + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.2 + bundler-cache: true + - run: | + bundle show + bundle exec rake rubocop + + # file-checks: + # name: 'File checks' + # runs-on: ubuntu-latest + # env: + # BUNDLE_GEMFILE: gem.deps.rb + # steps: + # - uses: actions/checkout@v3 + # - name: 'Install Ruby 3.2' + # uses: ruby/setup-ruby@v1 + # with: + # ruby-version: 3.2 + # bundler-cache: true + # - run: bundle exec rake check:dot_underscore + # - run: bundle exec rake check:test_file + + # releng-checks: + # name: 'RELENG checks' + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v3 + # - name: 'Install Ruby ${{matrix.puppet.ruby_version}}' + # uses: ruby/setup-ruby@v1 + # with: + # ruby-version: 3.2 + # bundler-cache: true + # - name: 'Tags and changelogs' + # run: | + # bundle exec rake pkg:check_version + # bundle exec rake pkg:compare_latest_tag[,true] + # bundle exec rake pkg:create_tag_changelog + # - name: 'Test-build the Puppet module' + # run: 'bundle exec pdk build --force' + + # spec-tests: + # name: 'Puppet Spec' + # needs: [puppet-syntax] + # runs-on: ubuntu-latest + # strategy: + # matrix: + # puppet: + # - label: 'Puppet 7.x [SIMP 6.6/PE 2021.7]' + # puppet_version: '~> 7.0' + # ruby_version: '2.7' + # experimental: false + # - label: 'Puppet 8.x' + # puppet_version: '~> 8.0' + # ruby_version: '3.2' + # experimental: false + # fail-fast: false + # env: + # PUPPET_VERSION: ${{matrix.puppet.puppet_version}} + # steps: + # - uses: actions/checkout@v3 + # - name: 'Install Ruby ${{matrix.puppet.ruby_version}}' + # uses: ruby/setup-ruby@v1 + # with: + # ruby-version: ${{matrix.puppet.ruby_version}} + # bundler-cache: true + # - run: 'command -v rpm || if command -v apt-get; then sudo apt-get update; sudo apt-get install -y rpm; fi ||:' + # - run: 'bundle exec rake spec' + # continue-on-error: ${{matrix.puppet.experimental}} + + yaml-lint: + name: 'YAML Lint' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: "Install yamllint" + run: "pip install yamllint" + - name: "Lint YAML files" + run: "yamllint ." + +# dump_contexts: +# name: 'Examine Context contents' +# runs-on: ubuntu-latest +# steps: +# - name: Dump contexts +# env: +# GITHUB_CONTEXT: ${{ toJson(github) }} +# run: echo "$GITHUB_CONTEXT" +# diff --git a/.puppet-lint.rc b/.puppet-lint.rc new file mode 100644 index 0000000..43eea8e --- /dev/null +++ b/.puppet-lint.rc @@ -0,0 +1,3 @@ +--relative +--ignore-paths +./.vendor/*,./.git/*,./.gems/*,./.modules/*,./.plan.gems/*,./_repos/* diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..5dfc141 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,700 @@ +--- +require: +- rubocop-performance +- rubocop-rspec +- rubocop-rake +AllCops: + NewCops: enable + DisplayCopNames: true + TargetRubyVersion: '2.7' + Include: + - "**/*.rb" + Exclude: + - bin/* + - ".vendor/**/*" + # "**/Gemfile" + # "**/Rakefile" + - pkg/**/* + - spec/fixtures/**/* + - vendor/**/* + - "**/Puppetfile" + - "**/Vagrantfile" + - "**/Guardfile" + - .git/**/* + - .gems/**/* + - .modules/**/* + - .plan.gems/**/* + - _repos/**/* +Layout/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 +RSpec/DescribeSymbol: + Exclude: + - spec/unit/facter/**/*.rb +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/TrailingCommaInArrayLiteral: + 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/Documentation: + Exclude: + - lib/puppet/parser/functions/**/* + - 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 +Bundler/GemFilename: + Enabled: false +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 +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: + Enabled: false +Metrics/BlockNesting: + Enabled: false +Metrics/ClassLength: + Enabled: false +Metrics/CyclomaticComplexity: + Enabled: false +Metrics/MethodLength: + Enabled: false +Metrics/ModuleLength: + Enabled: false +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/Dialect: + Enabled: false +RSpec/ContainExactly: + 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/ExampleWithoutDescription: + Enabled: false +RSpec/ExpectChange: + Enabled: false +RSpec/ExpectInHook: + Enabled: false +RSpec/HooksBeforeExamples: + Enabled: false +RSpec/ImplicitBlockExpectation: + Enabled: false +RSpec/ImplicitSubject: + Enabled: false +RSpec/LeakyConstantDeclaration: + Enabled: false +RSpec/LetBeforeExamples: + Enabled: false +RSpec/MatchArray: + 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/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 +Gemspec/DeprecatedAttributeAssignment: + Enabled: false +# Gemspec/DevelopmentDependencies: +# Enabled: false +Gemspec/RequireMFA: + Enabled: false +Layout/LineContinuationLeadingSpace: + Enabled: false +Layout/LineContinuationSpacing: + Enabled: false +Layout/LineEndStringConcatenationIndentation: + Enabled: false +Layout/SpaceBeforeBrackets: + Enabled: false +Lint/AmbiguousAssignment: + Enabled: false +Lint/AmbiguousOperatorPrecedence: + Enabled: false +Lint/AmbiguousRange: + Enabled: false +Lint/ConstantOverwrittenInRescue: + Enabled: false +Lint/DeprecatedConstants: + Enabled: false +Lint/DuplicateBranch: + Enabled: false +Lint/DuplicateMagicComment: + Enabled: false +# Lint/DuplicateMatchPattern: +# Enabled: false +Lint/DuplicateRegexpCharacterClassElement: + Enabled: false +Lint/EmptyBlock: + Enabled: false +Lint/EmptyClass: + Enabled: false +Lint/EmptyInPattern: + Enabled: false +Lint/IncompatibleIoSelectWithFiberScheduler: + Enabled: false +Lint/LambdaWithoutLiteralBlock: + Enabled: false +Lint/NoReturnInBeginEndBlocks: + Enabled: false +Lint/NonAtomicFileOperation: + Enabled: false +Lint/NumberedParameterAssignment: + Enabled: false +Lint/OrAssignmentToConstant: + Enabled: false +Lint/RedundantDirGlobSort: + Enabled: false +Lint/RefinementImportMethods: + Enabled: false +Lint/RequireRangeParentheses: + Enabled: false +Lint/RequireRelativeSelfPath: + Enabled: false +Lint/SymbolConversion: + Enabled: false +Lint/ToEnumArguments: + Enabled: false +Lint/TripleQuotes: + Enabled: false +Lint/UnexpectedBlockArity: + Enabled: false +Lint/UnmodifiedReduceAccumulator: + Enabled: false +# Lint/UselessRescue: +# Enabled: false +Lint/UselessRuby2Keywords: + Enabled: false +# Metrics/CollectionLiteralLength: +# Enabled: false +Naming/BlockForwarding: + Enabled: false +Performance/CollectionLiteralInLoop: + Enabled: false +Performance/ConcurrentMonotonicTime: + Enabled: false +Performance/MapCompact: + Enabled: false +Performance/RedundantEqualityComparisonBlock: + Enabled: false +Performance/RedundantSplitRegexpArgument: + Enabled: false +Performance/StringIdentifierArgument: + Enabled: false +RSpec/BeEq: + Enabled: false +RSpec/BeNil: + Enabled: false +RSpec/ChangeByZero: + Enabled: false +RSpec/ClassCheck: + Enabled: false +RSpec/DuplicatedMetadata: + Enabled: false +RSpec/ExcessiveDocstringSpacing: + Enabled: false +RSpec/IdenticalEqualityAssertion: + Enabled: false +RSpec/NoExpectationExample: + Enabled: false +RSpec/PendingWithoutReason: + Enabled: false +RSpec/RedundantAround: + Enabled: false +RSpec/SkipBlockInsideExample: + Enabled: false +RSpec/SortMetadata: + Enabled: false +RSpec/SubjectDeclaration: + Enabled: false +RSpec/VerifiedDoubleReference: + Enabled: false +Security/CompoundHash: + Enabled: false +Security/IoMethods: + Enabled: false +Style/ArgumentsForwarding: + Enabled: false +Style/ArrayIntersect: + Enabled: false +Style/CollectionCompact: + Enabled: false +# Style/ComparableClamp: +# Enabled: false +Style/ConcatArrayLiterals: + Enabled: false +# Style/DataInheritance: +# Enabled: false +# Style/DirEmpty: +# Enabled: false +Style/DocumentDynamicEvalDefinition: + Enabled: false +Style/EmptyHeredoc: + Enabled: false +Style/EndlessMethod: + Enabled: false +Style/EnvHome: + Enabled: false +Style/FetchEnvVar: + Enabled: false +# Style/FileEmpty: +# Enabled: false +Style/FileRead: + Enabled: false +Style/FileWrite: + Enabled: false +Style/HashConversion: + Enabled: false +Style/HashExcept: + Enabled: false +Style/IfWithBooleanLiteralBranches: + Enabled: false +Style/InPatternThen: + Enabled: false +Style/MagicCommentFormat: + Enabled: false +Style/MapCompactWithConditionalBlock: + Enabled: false +Style/MapToHash: + Enabled: false +Style/MapToSet: + Enabled: false +Style/MinMaxComparison: + Enabled: false +Style/MultilineInPatternThen: + Enabled: false +Style/NegatedIfElseCondition: + Enabled: false +Style/NestedFileDirname: + Enabled: false +Style/NilLambda: + Enabled: false +Style/NumberedParameters: + Enabled: false +Style/NumberedParametersLimit: + Enabled: false +Style/ObjectThen: + Enabled: false +Style/OpenStructUse: + Enabled: false +Style/OperatorMethodCall: + Enabled: false +Style/QuotedSymbols: + Enabled: false +Style/RedundantArgument: + Enabled: false +Style/RedundantConstantBase: + Enabled: false +Style/RedundantDoubleSplatHashBraces: + Enabled: false +Style/RedundantEach: + Enabled: false +# Style/RedundantHeredocDelimiterQuotes: +# Enabled: false +Style/RedundantInitialize: + Enabled: false +# Style/RedundantLineContinuation: +# Enabled: false +Style/RedundantSelfAssignmentBranch: + Enabled: false +Style/RedundantStringEscape: + Enabled: false +Style/SelectByRegexp: + Enabled: false +Style/StringChars: + Enabled: false +Style/SwapValues: + Enabled: false diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..96a40c5 --- /dev/null +++ b/.yamllint @@ -0,0 +1,18 @@ +--- +extends: default +rules: + line-length: + max: 200 + indentation: + indent-sequences: consistent + comments-indentation: + ignore: | + /data/sync/configs/ + /data/sync/repolists/ +ignore: | + /.git/ + /.gems/ + /.modules/ + /.plan.gems/ + /.vendor/ + /_repos/ diff --git a/Rakefile b/Rakefile index 649b1b3..839913c 100755 --- a/Rakefile +++ b/Rakefile @@ -1,14 +1,37 @@ #!/opt/puppetlabs/bolt/bin/rake -f require 'rake/clean' +require 'puppet-syntax/tasks/puppet-syntax' +require 'puppet-strings/tasks' +require 'puppet-lint/tasks/puppet-lint' +require 'metadata-json-lint/rake_task' +require 'rubocop/rake_task' + +begin + require 'yaml' + exclude_paths = YAML.safe_load(File.read('.rubocop.yml')).dig('AllCops', 'Exclude') +rescue StandardError => e + warn "Failed to load path exclusions: #{e.message}" +end + +PuppetSyntax.exclude_paths = exclude_paths unless exclude_paths.nil? +PuppetSyntax.check_hiera_keys = true + +PuppetLint::RakeTask.new :lint do |config| + config.ignore_paths = exclude_paths unless exclude_paths.nil? +end -BOLT_BIN_PATH="/opt/puppetlabs/bolt/bin" -BOLT_GEM_EXE=File.join(BOLT_BIN_PATH,'gem') -BOLT_PUPPET_EXE=File.join(BOLT_BIN_PATH,'puppet') -BOLT_EXE=File.join(BOLT_BIN_PATH,'bolt') -GEM_HOME='.gems' +RuboCop::RakeTask.new do |task| + task.requires << 'rubocop-rake' +end + +BOLT_BIN_PATH = '/opt/puppetlabs/bolt/bin'.freeze +BOLT_GEM_EXE = File.join(BOLT_BIN_PATH, 'gem') +BOLT_PUPPET_EXE = File.join(BOLT_BIN_PATH, 'puppet') +BOLT_EXE = File.join(BOLT_BIN_PATH, 'bolt') +GEM_HOME = '.gems'.freeze -CLEAN.include( Dir['????????-????-????-????-????????????'].reject{|x| x.strip !~ /^[\h-]{36}$/ } ) -CLEAN.include( [GEM_HOME, 'tmpdir', 'gem.deps.rb.lock'] ) +CLEAN.include(Dir['????????-????-????-????-????????????'].select { |x| x.strip =~ %r{^[\h-]{36}$} }) +CLEAN.include([GEM_HOME, 'tmpdir', 'gem.deps.rb.lock']) CLOBBER << '_repos' @target_name_max_length = 40 @@ -20,16 +43,16 @@ def file_info_string(file) p = Pathname.new(file) target_missing = p.exist? ? false : true if File.symlink?(file) - if target_missing - link_path = p.readlink - else - link_path = p.realpath.relative_path_from(Rake.application.original_dir) - end - out = "#{out.rjust(@target_name_max_length+1)} -> #{link_path}" + link_path = if target_missing + p.readlink + else + p.realpath.relative_path_from(Rake.application.original_dir) + end + out = "#{out.rjust(@target_name_max_length + 1)} -> #{link_path}" else - out = "#{out.rjust(@target_name_max_length+1)} !!! FILE !!!" + out = "#{out.rjust(@target_name_max_length + 1)} !!! FILE !!!" end - out += " !!! MISSING !!!" if target_missing + out += ' !!! MISSING !!!' if target_missing end out end @@ -42,7 +65,6 @@ def repolist_file(name) "data/sync/repolists/#{name}.yaml" end - def display_config_paths(config_file:, repolist_file:) @target_name_max_length = [config_file, repolist_file].map(&:size).max @@ -51,42 +73,42 @@ def display_config_paths(config_file:, repolist_file:) out += "# repolist: #{file_info_string(repolist_file)}\n" puts out - exit 1 if out =~ /MISSING/ + exit 1 if out.include?('MISSING') end - namespace :data do desc "Display puppetsync's latest config paths" - task :files, [:config,:repolist,:verbose] do |t,args| - args.with_defaults(:config => 'latest') - args.with_defaults(:repolist => 'latest') - args.with_defaults(:verbose => false) + task :files, [:config, :repolist, :verbose] do |_t, args| + args.with_defaults(config: 'latest') + args.with_defaults(repolist: 'latest') + args.with_defaults(verbose: false) display_config_paths( config_file: config_file(args.config), - repolist_file: repolist_file(args.repolist) + repolist_file: repolist_file(args.repolist), ) end - task :repolist, [:config,:repolist,:verbose] do |t,args| - args.with_defaults(:config => 'latest') - args.with_defaults(:repolist => 'latest') - args.with_defaults(:verbose => false) - cmd = %Q[#{BOLT_EXE} lookup --plan-hierarchy puppetsync::repos_config \ + desc 'Display puppetsync repo config' + task :repolist, [:config, :repolist, :verbose] do |_t, args| + args.with_defaults(config: 'latest') + args.with_defaults(repolist: 'latest') + args.with_defaults(verbose: false) + cmd = %(#{BOLT_EXE} lookup --plan-hierarchy puppetsync::repos_config \ config="#{args.config}" \ repolist="#{args.repolist}" \ batchlist="" \ --log-level "#{args.verbose ? 'debug' : 'info'}" \ --format json - ].gsub(/ +/, ' ') - stdout = %x[#{cmd}] + ).squeeze(' ') + stdout = `#{cmd}` require 'json' - data = JSON.parse(stdout) + data = JSON.parse(stdout) # rubocop:disable Lint/UselessAssignment require 'yaml' - config_file = "data/sync/configs/#{args.config}.yaml" - repolist_file = "data/sync/repolists/#{args.repolist}.yaml" + config_file = "data/sync/configs/#{args.config}.yaml" # rubocop:disable Lint/UselessAssignment + repolist_file = "data/sync/repolists/#{args.repolist}.yaml" # rubocop:disable Lint/UselessAssignment display_config_paths( config_file: config_file(args.config), - repolist_file: repolist_file(args.repolist) + repolist_file: repolist_file(args.repolist), ) end @@ -99,40 +121,40 @@ Generate latest config REFERENCE.md for puppetsync (TODO: after breaking puppetsync into its own module, document role & profile classes) DESC -task :strings, [:verbose] do |t,args| - args.with_defaults(:verbose => false) - sh %Q[#{BOLT_PUPPET_EXE} strings generate \ - #{args.verbose ? ' --verbose' : '' } --format markdown \ - "{dist,modules}/**/*.{pp,rb,json}"].gsub(/ {3,}/,' ') +task :strings, [:verbose] do |_t, args| + args.with_defaults(verbose: false) + sh %(#{BOLT_PUPPET_EXE} strings generate \ + #{args.verbose ? ' --verbose' : ''} --format markdown \ + "{dist,modules}/**/*.{pp,rb,json}").gsub(%r{ {3,}}, ' ') end namespace :install do desc "Install gems into #{__dir__}/.gems" task :gems do Dir.chdir __dir__ - sh %Q[GEM_HOME="#{GEM_HOME}" "#{BOLT_GEM_EXE}" install -g gem.deps.rb --no-document --no-user-install] - sh %Q[ls -lart] + sh %(GEM_HOME="#{GEM_HOME}" "#{BOLT_GEM_EXE}" install -g gem.deps.rb --no-document --no-user-install) + sh %(ls -lart) end desc "Install Puppet modules from bolt-project.yaml into #{__dir__}/.modules" task :modules do Dir.chdir __dir__ - sh %Q[GEM_HOME="#{GEM_HOME}" "#{BOLT_EXE}" module install --force] + sh %(GEM_HOME="#{GEM_HOME}" "#{BOLT_EXE}" module install --force) end end namespace :list do - desc "Installed gems (pass in true to list only project gems)" - task :gems, :project_only do |t,args| - args.with_defaults(:project_only => false) + desc 'Installed gems (pass in true to list only project gems)' + task :gems, :project_only do |_t, args| + args.with_defaults(project_only: false) Dir.chdir __dir__ - cmd =%Q[GEM_HOME="#{GEM_HOME}" "#{BOLT_GEM_EXE}" list] - cmd ="GEM_PATH= #{cmd}" if args.project_only + cmd = %(GEM_HOME="#{GEM_HOME}" "#{BOLT_GEM_EXE}" list) + cmd = "GEM_PATH= #{cmd}" if args.project_only sh cmd end end desc 'Install prereqs (RubyGems and Puppet modules)' -task :install => ['install:gems', 'install:modules'] +task install: ['install:gems', 'install:modules'] -task :default => :install +task default: :install diff --git a/bolt-project.yaml b/bolt-project.yaml index e465c37..7161187 100644 --- a/bolt-project.yaml +++ b/bolt-project.yaml @@ -14,4 +14,4 @@ modules: - name: puppetlabs/stdlib - name: puppetlabs/ruby_task_helper - name: puppet/format - - name: nwops/debug # only needed for debugging plans with `debug::break` + - name: nwops/debug # only needed for debugging plans with `debug::break` diff --git a/data/common.yaml b/data/common.yaml index 82f65fd..45103cd 100644 --- a/data/common.yaml +++ b/data/common.yaml @@ -9,4 +9,3 @@ classes: profile::obsoletes::files: - '.ruby-version' # Borks RUBY_MATRIX (SIMP-8931, SIMP-8958) - '.travis.yml' # Travis is dead to us (SIMP-9150) - diff --git a/data/project_types/pupmod.yaml b/data/project_types/pupmod.yaml index 84d0b88..8a5efbc 100644 --- a/data/project_types/pupmod.yaml +++ b/data/project_types/pupmod.yaml @@ -3,9 +3,9 @@ classes: - 'role::pupmod' profile::obsoletes::files: - - 'spec/fixtures/site.pp' # Several modules had this incorrect path - - 'spec/fixtures/manifests/site.pp' # Not required since Puppet 3.x - - '.pmtignore' # Now using .pdkignore + - 'spec/fixtures/site.pp' # Several modules had this incorrect path + - 'spec/fixtures/manifests/site.pp' # Not required since Puppet 3.x + - '.pmtignore' # Now using .pdkignore profile::github_actions::absent_action_files: - pr_glci.yml # PR-triggered GLCI actions diff --git a/data/project_types/pupmod_skeleton.yaml b/data/project_types/pupmod_skeleton.yaml index 59b5bf7..c8c4e8e 100644 --- a/data/project_types/pupmod_skeleton.yaml +++ b/data/project_types/pupmod_skeleton.yaml @@ -8,9 +8,9 @@ profile::pupmod::rspec::rspec_path: "%{::repo_path}/skeleton/.rspec" profile::obsoletes::repo_path: "%{::repo_path}/skeleton" profile::obsoletes::files: - - 'spec/fixtures/site.pp' # Several modules had this incorrect path - - 'spec/fixtures/manifests/site.pp' # Not required since Puppet 3.x - - '.pmtignore' # Now using .pdkignore + - 'spec/fixtures/site.pp' # Several modules had this incorrect path + - 'spec/fixtures/manifests/site.pp' # Not required since Puppet 3.x + - '.pmtignore' # Now using .pdkignore profile::github_actions::absent_action_files: - pr_glci.yml # PR-triggered GLCI actions diff --git a/data/repos/rubygem-simp-cli.yaml b/data/repos/rubygem-simp-cli.yaml index ef0b13d..fdb7479 100644 --- a/data/repos/rubygem-simp-cli.yaml +++ b/data/repos/rubygem-simp-cli.yaml @@ -1,15 +1,15 @@ # The rubygem-simp-cli gem is not released to rubygems.org, so we override some # of the GHA files: - +--- profile::github_actions::present_action_files: - - tag_deploy_rubygem__github-rpms.yml # Builds noarch RPMs, doesn't publish to RubyForge + - tag_deploy_rubygem__github-rpms.yml # Builds noarch RPMs, doesn't publish to RubyForge - release_rpms.yml - validate_tokens_asset.yml - add_new_issue_to_triage_project.yml profile::github_actions::absent_action_files: - - pr_glci.yml # PR-triggered GLCI actions - - pr_glci_manual.yml # --> manual trigger for external contributors - - pr_glci_cleanup.yml # --> clean up old GLCI branches + - pr_glci.yml # PR-triggered GLCI actions + - pr_glci_manual.yml # --> manual trigger for external contributors + - pr_glci_cleanup.yml # --> clean up old GLCI branches - tag_deploy_rubygem.yml - tag_deploy_rubygem__github-only.yml diff --git a/data/repos/simp-adapter.yaml b/data/repos/simp-adapter.yaml index 8f8862f..ea694fc 100644 --- a/data/repos/simp-adapter.yaml +++ b/data/repos/simp-adapter.yaml @@ -1,4 +1,3 @@ --- profile::github_actions::present_action_files: "%{alias('profile::github_actions::present_action_files__rpms_el7_el8')}" profile::github_actions::absent_action_files: "%{alias('profile::github_actions::absent_action_files__rpms_el7_el8')}" - diff --git a/data/sync/batches/latest.yaml b/data/sync/batches/latest.yaml index ae042d0..045c705 100644 --- a/data/sync/batches/latest.yaml +++ b/data/sync/batches/latest.yaml @@ -2,15 +2,15 @@ puppetsync::batches_config: delay: 30 repolists: - #- gcp__batch_01 - #- gcp__batch_02 - #- gcp__batch_03 - #- gcp__batch_04 - #- gcp__batch_05 - #- gcp__batch_06 - #- gcp__batch_07 - #- simp_misc - #- rubygems + # - gcp__batch_01 + # - gcp__batch_02 + # - gcp__batch_03 + # - gcp__batch_04 + # - gcp__batch_05 + # - gcp__batch_06 + # - gcp__batch_07 + # - simp_misc + # - rubygems - pupmods__batch_01 - pupmods__batch_02 - pupmods__batch_03 diff --git a/data/sync/configs/20220603-pupmod-systemd-update.yaml b/data/sync/configs/20220603-pupmod-systemd-update.yaml index 421bd24..749308d 100644 --- a/data/sync/configs/20220603-pupmod-systemd-update.yaml +++ b/data/sync/configs/20220603-pupmod-systemd-update.yaml @@ -7,8 +7,8 @@ puppetsync::plan_config: # - simp_unknown plans: sync: - #clone_git_repos: false # set to `false` when applying manual updates on a second run - #clear_before_clone: false # set to `false` when applying manual updates on a second run + # clone_git_repos: false # set to `false` when applying manual updates on a second run + # clear_before_clone: false # set to `false` when applying manual updates on a second run github_api_delay_seconds: 10 stages: ### - install_gems # Uncomment for first-time puppetsync run @@ -18,7 +18,7 @@ puppetsync::plan_config: - modernize_gitlab_files - lint_gitlab_ci ### ### - modernize_fixtures # one-off - - modernize_metadata_json # one-off? + - modernize_metadata_json # one-off? - git_commit_changes - ensure_github_fork - ensure_git_remote diff --git a/data/sync/configs/202300605-rocky8.yaml b/data/sync/configs/202300605-rocky8.yaml index 1747d63..277b2f8 100644 --- a/data/sync/configs/202300605-rocky8.yaml +++ b/data/sync/configs/202300605-rocky8.yaml @@ -7,8 +7,8 @@ puppetsync::plan_config: # - simp_unknown plans: sync: - clone_git_repos: false # set to `false` when applying manual updates on a second run - clear_before_clone: false # set to `false` when applying manual updates on a second run + clone_git_repos: false # set to `false` when applying manual updates on a second run + clear_before_clone: false # set to `false` when applying manual updates on a second run github_api_delay_seconds: 30 stages: # - install_gems # Uncomment for first-time puppetsync run diff --git a/data/sync/configs/20230313-add-gcp-to-glci.yaml b/data/sync/configs/20230313-add-gcp-to-glci.yaml index b26952e..f73d5d9 100644 --- a/data/sync/configs/20230313-add-gcp-to-glci.yaml +++ b/data/sync/configs/20230313-add-gcp-to-glci.yaml @@ -7,8 +7,8 @@ puppetsync::plan_config: # - simp_unknown plans: sync: - #clone_git_repos: false # set to `false` when applying manual updates on a second run - #clear_before_clone: false # set to `false` when applying manual updates on a second run + # clone_git_repos: false # set to `false` when applying manual updates on a second run + # clear_before_clone: false # set to `false` when applying manual updates on a second run github_api_delay_seconds: 10 stages: ### - install_gems # Uncomment for first-time puppetsync run @@ -22,8 +22,8 @@ puppetsync::plan_config: - ensure_github_fork - ensure_git_remote - git_push_to_remote - - ensure_gitlab_remote # No longer needed with new GLCI PR Trigger workflows - - git_push_to_gitlab # No longer needed with new GLCI PR Trigger workflows + - ensure_gitlab_remote # No longer needed with new GLCI PR Trigger workflows + - git_push_to_gitlab # No longer needed with new GLCI PR Trigger workflows - ensure_github_pr approve_github_prs: diff --git a/data/sync/configs/20230313-approve-gce.yaml b/data/sync/configs/20230313-approve-gce.yaml index 89d975c..3bd606c 100644 --- a/data/sync/configs/20230313-approve-gce.yaml +++ b/data/sync/configs/20230313-approve-gce.yaml @@ -8,8 +8,8 @@ puppetsync::plan_config: - simp_unknown plans: sync: - #clone_git_repos: false # set to `false` when applying manual updates on a second run - #clear_before_clone: false # set to `false` when applying manual updates on a second run + # clone_git_repos: false # set to `false` when applying manual updates on a second run + # clear_before_clone: false # set to `false` when applying manual updates on a second run github_api_delay_seconds: 10 stages: - checkout_git_feature_branch_in_each_repo @@ -18,7 +18,7 @@ puppetsync::plan_config: clone_git_repos: false # No need to clone just to approve filter_permitted_repos: false # No need to filter (which requires clone) stages: - #- install_gems + # - install_gems - approve_github_pr_for_each_repo merge_github_prs: @@ -39,7 +39,7 @@ puppetsync::plan_config: git: feature_branch: add_gce - #feature_branch: modernize-gha-workflows-to-avoid-deprecations + # feature_branch: modernize-gha-workflows-to-avoid-deprecations # 0---------1---------2---------3---------4---------5---------6---------7| # (SIMP-XXXXX) 12345678 |+| commit_message: | diff --git a/data/sync/configs/20230403-remove-puppet6.yaml b/data/sync/configs/20230403-remove-puppet6.yaml index f68dc9b..75ee639 100644 --- a/data/sync/configs/20230403-remove-puppet6.yaml +++ b/data/sync/configs/20230403-remove-puppet6.yaml @@ -7,8 +7,8 @@ puppetsync::plan_config: # - simp_unknown plans: sync: - clone_git_repos: false # set to `false` when applying manual updates on a second run - clear_before_clone: false # set to `false` when applying manual updates on a second run + clone_git_repos: false # set to `false` when applying manual updates on a second run + clear_before_clone: false # set to `false` when applying manual updates on a second run github_api_delay_seconds: 30 stages: # - install_gems # Uncomment for first-time puppetsync run @@ -50,7 +50,7 @@ puppetsync::plan_config: Removes puppet 6 from .gitlab-ci.yml This patch moves puppet 6 refs to 7, puppet 7 refs to 8. Then we manually - update all spec nodesets to point to sicura oel boxes and comment out all + update all spec nodesets to point to sicura oel boxes and comment out all pup8 tests. The patch enforces a standardized asset baseline using simp/puppetsync, diff --git a/data/sync/configs/20230417-add-gha-issue-triage-action.yaml b/data/sync/configs/20230417-add-gha-issue-triage-action.yaml index 2790ae6..c092b66 100644 --- a/data/sync/configs/20230417-add-gha-issue-triage-action.yaml +++ b/data/sync/configs/20230417-add-gha-issue-triage-action.yaml @@ -7,8 +7,8 @@ puppetsync::plan_config: - simp_unknown plans: sync: - #clone_git_repos: false # set to `false` when applying manual updates on a second run - #clear_before_clone: false # set to `false` when applying manual updates on a second run + # clone_git_repos: false # set to `false` when applying manual updates on a second run + # clear_before_clone: false # set to `false` when applying manual updates on a second run github_api_delay_seconds: 10 stages: ### - install_gems # Uncomment for first-time puppetsync run diff --git a/data/sync/configs/20230803-almalinux8.yaml b/data/sync/configs/20230803-almalinux8.yaml index d2b7063..ae164cb 100644 --- a/data/sync/configs/20230803-almalinux8.yaml +++ b/data/sync/configs/20230803-almalinux8.yaml @@ -18,7 +18,7 @@ puppetsync::plan_config: ### - lint_gitlab_ci TODO ### - modernize_fixtures # one-off - os_data - - modernize_metadata_json # one-off? + - modernize_metadata_json # one-off? - run_spec_tests - git_commit_changes ### - generate_reference_md diff --git a/data/sync/configs/20231005-puppet8.yaml b/data/sync/configs/20231005-puppet8.yaml index 837ce34..27ac6f4 100644 --- a/data/sync/configs/20231005-puppet8.yaml +++ b/data/sync/configs/20231005-puppet8.yaml @@ -18,7 +18,7 @@ puppetsync::plan_config: ### - lint_gitlab_ci TODO ### - modernize_fixtures # one-off - os_data - - modernize_metadata_json # one-off? + - modernize_metadata_json # one-off? - modernize_spec_helper - run_spec_tests - git_commit_changes diff --git a/data/sync/configs/20231012-el9.yaml b/data/sync/configs/20231012-el9.yaml index ddddf71..53dfd4e 100644 --- a/data/sync/configs/20231012-el9.yaml +++ b/data/sync/configs/20231012-el9.yaml @@ -18,7 +18,7 @@ puppetsync::plan_config: ### - lint_gitlab_ci TODO ### - modernize_fixtures # one-off - os_data - - modernize_metadata_json # one-off? + - modernize_metadata_json # one-off? - modernize_spec_helper - run_spec_tests - git_commit_changes diff --git a/data/sync/configs/20240724-lint-cleanup.yaml b/data/sync/configs/20240724-lint-cleanup.yaml new file mode 100644 index 0000000..a2fe309 --- /dev/null +++ b/data/sync/configs/20240724-lint-cleanup.yaml @@ -0,0 +1,61 @@ +--- +puppetsync::plan_config: + puppetsync: + permitted_project_types: + - pupmod + - rubygem + - simp_unknown + plans: + sync: + # clone_git_repos: false # set to `false` when applying manual updates on a second run + # clear_before_clone: false # set to `false` when applying manual updates on a second run + github_api_delay_seconds: 1 + stages: + - install_gems # Uncomment for first-time puppetsync run + - checkout_git_feature_branch_in_each_repo + - apply_puppet_role +### - modernize_gitlab_files # TODO +### - lint_gitlab_ci TODO +### - modernize_fixtures # one-off +### - os_data +### - modernize_metadata_json +### - run_spec_tests +### - run_gha_tests + - git_commit_changes +### - generate_reference_md + - ensure_github_fork + - ensure_git_remote + - git_push_to_remote + - ensure_github_pr +### - release_pupmod + + approve_github_prs: + clone_git_repos: false # No need to clone just to approve + filter_permitted_repos: false # No need to filter (which requires clone) + stages: + - install_gems + - approve_github_pr_for_each_repo + + merge_github_prs: + clone_git_repos: false # No need to clone just to merge + filter_permitted_repos: false # No need to filter (which requires clone) + stages: + - install_gems + - merge_github_pr_for_each_repo + + git: + feature_branch: 20240724-lint-cleanup + # 0---------1---------2---------3---------4---------5---------6---------7| + # (SIMP-XXXXX) 12345678 |+| + commit_message: | + [puppetsync] Clean up for linters + + Clean up files distributed by puppetsync for various linters. + + Also fix a quoting issue in create-github-release action. + + + github: + pr_user: silug # This should be the account that *submitted* the PRs + # (Used by idempotency checks when approving/merging PRs) + approval_message: ':+1: :ghost:' diff --git a/data/sync/configs/SIMP-9399.yaml b/data/sync/configs/SIMP-9399.yaml index aa25cdd..c490de7 100644 --- a/data/sync/configs/SIMP-9399.yaml +++ b/data/sync/configs/SIMP-9399.yaml @@ -6,8 +6,8 @@ puppetsync::plan_config: - rubygem plans: sync: - #clone_git_repos: false # set to `false` when applying manual updates on a second run - #clear_before_clone: false # set to `false` when applying manual updates on a sceond run + # clone_git_repos: false # set to `false` when applying manual updates on a second run + # clear_before_clone: false # set to `false` when applying manual updates on a sceond run stages: # - install_gems - checkout_git_feature_branch_in_each_repo diff --git a/data/sync/configs/SIMP-9407.yaml b/data/sync/configs/SIMP-9407.yaml index 78d5fb6..a366435 100644 --- a/data/sync/configs/SIMP-9407.yaml +++ b/data/sync/configs/SIMP-9407.yaml @@ -5,8 +5,8 @@ puppetsync::plan_config: - rubygem plans: sync: - clone_git_repos: false # set to `false` when applying manual updates on a second run - clear_before_clone: false # set to `false` when applying manual updates on a sceond run + clone_git_repos: false # set to `false` when applying manual updates on a second run + clear_before_clone: false # set to `false` when applying manual updates on a sceond run stages: # - install_gems ### - checkout_git_feature_branch_in_each_repo diff --git a/data/sync/configs/SIMP-9888.yaml b/data/sync/configs/SIMP-9888.yaml index 68a1e11..f61be0b 100644 --- a/data/sync/configs/SIMP-9888.yaml +++ b/data/sync/configs/SIMP-9888.yaml @@ -15,14 +15,14 @@ puppetsync::plan_config: # - apply_puppet_role # - modernize_gitlab_files # - lint_gitlab_ci - ###- modernize_fixtures + ### - modernize_fixtures - modernize_metadata_json - git_commit_changes - ensure_github_fork - ensure_git_remote - git_push_to_remote - # - ensure_gitlab_remote # No longer needed with new GLCI PR Trigger workflows - # - git_push_to_gitlab # No longer needed with new GLCI PR Trigger workflows + # - ensure_gitlab_remote # No longer needed with new GLCI PR Trigger workflows + # - git_push_to_gitlab # No longer needed with new GLCI PR Trigger workflows - ensure_github_pr approve_github_prs: diff --git a/data/sync/configs/latest.yaml b/data/sync/configs/latest.yaml index bca06c2..2bd7225 120000 --- a/data/sync/configs/latest.yaml +++ b/data/sync/configs/latest.yaml @@ -1 +1 @@ -20240905-iptables-7.yaml \ No newline at end of file +20240724-lint-cleanup.yaml \ No newline at end of file diff --git a/data/sync/configs/pupmod_skeleton.yaml b/data/sync/configs/pupmod_skeleton.yaml index 59106d0..06bf1f4 100644 --- a/data/sync/configs/pupmod_skeleton.yaml +++ b/data/sync/configs/pupmod_skeleton.yaml @@ -5,8 +5,8 @@ puppetsync::plan_config: - pupmod_skeleton plans: sync: - #clone_git_repos: false # set to `false` when applying manual updates on a second run - #clear_before_clone: false # set to `false` when applying manual updates on a second run + # clone_git_repos: false # set to `false` when applying manual updates on a second run + # clear_before_clone: false # set to `false` when applying manual updates on a second run github_api_delay_seconds: 10 stages: ### - install_gems # Uncomment for first-time puppetsync run diff --git a/data/sync/repolists/20220603_pupmods_systemd_update.yaml b/data/sync/repolists/20220603_pupmods_systemd_update.yaml index 5dc8418..9b89d4c 100644 --- a/data/sync/repolists/20220603_pupmods_systemd_update.yaml +++ b/data/sync/repolists/20220603_pupmods_systemd_update.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: https://github.com/simp/pupmod-simp-aide: diff --git a/data/sync/repolists/20230313-add-gcp-to-glci.yaml b/data/sync/repolists/20230313-add-gcp-to-glci.yaml index bb8423b..29f3244 100644 --- a/data/sync/repolists/20230313-add-gcp-to-glci.yaml +++ b/data/sync/repolists/20230313-add-gcp-to-glci.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: https://github.com/simp/pkg-r10k: @@ -171,8 +172,8 @@ puppetsync::repos_config: https://github.com/simp/pupmod-simp-simp_ds389: branch: master - #https://github.com/simp/pupmod-simp-simp_elasticsearch: - #branch: master + # https://github.com/simp/pupmod-simp-simp_elasticsearch: + # branch: master https://github.com/simp/pupmod-simp-simp_firewalld: branch: master @@ -180,8 +181,8 @@ puppetsync::repos_config: https://github.com/simp/pupmod-simp-simp_gitlab: branch: master - #https://github.com/simp/pupmod-simp-simp_grafana: - #branch: master + # https://github.com/simp/pupmod-simp-simp_grafana: + # branch: master https://github.com/simp/pupmod-simp-simp_grub: branch: master @@ -189,8 +190,8 @@ puppetsync::repos_config: https://github.com/simp/pupmod-simp-simp_ipa: branch: master - #https://github.com/simp/pupmod-simp-simp_logstash: - #branch: master + # https://github.com/simp/pupmod-simp-simp_logstash: + # branch: master https://github.com/simp/pupmod-simp-simp_nfs: branch: master @@ -270,9 +271,8 @@ puppetsync::repos_config: https://github.com/simp/simp-adapter: branch: master - # https://github.com/simp/simp-core: - #branch: master + # https://github.com/simp/simp-core: + # branch: master https://github.com/simp/simp-utils: branch: master - diff --git a/data/sync/repolists/20240724-lint-cleanup.yaml b/data/sync/repolists/20240724-lint-cleanup.yaml new file mode 100644 index 0000000..d801572 --- /dev/null +++ b/data/sync/repolists/20240724-lint-cleanup.yaml @@ -0,0 +1,224 @@ +--- +puppetsync::repos_config: + https://github.com/simp/bolt-pulp3: + branch: main + https://github.com/simp/github-action-build-and-sign-pkg-single-rpm: + branch: main + # Test failures - https://github.com/simp/pkg-r10k/pull/31 + # https://github.com/simp/pkg-r10k: + # branch: master + https://github.com/simp/pupmod-simp-acpid: + branch: master + https://github.com/simp/pupmod-simp-aide: + branch: master + https://github.com/simp/pupmod-simp-at: + branch: master + https://github.com/simp/pupmod-simp-auditd: + branch: master + https://github.com/simp/pupmod-simp-autofs: + branch: master + https://github.com/simp/pupmod-simp-chkrootkit: + branch: master + https://github.com/simp/pupmod-simp-clamav: + branch: master + https://github.com/simp/pupmod-simp-compliance_markup: + branch: master + https://github.com/simp/pupmod-simp-cron: + branch: master + https://github.com/simp/pupmod-simp-crypto_policy: + branch: master + https://github.com/simp/pupmod-simp-dconf: + branch: master + https://github.com/simp/pupmod-simp-deferred_resources: + branch: master + https://github.com/simp/pupmod-simp-dhcp: + branch: master + https://github.com/simp/pupmod-simp-ds389: + branch: master + https://github.com/simp/pupmod-simp-fips: + branch: master + https://github.com/simp/pupmod-simp-freeradius: + branch: master + https://github.com/simp/pupmod-simp-gdm: + branch: master + https://github.com/simp/pupmod-simp-gnome: + branch: master + https://github.com/simp/pupmod-simp-hirs_provisioner: + branch: master + https://github.com/simp/pupmod-simp-ima: + branch: master + https://github.com/simp/pupmod-simp-incron: + branch: master + https://github.com/simp/pupmod-simp-iptables: + branch: master + https://github.com/simp/pupmod-simp-issue: + branch: master + https://github.com/simp/pupmod-simp-krb5: + branch: master + https://github.com/simp/pupmod-simp-libreswan: + branch: master + https://github.com/simp/pupmod-simp-libvirt: + branch: master + https://github.com/simp/pupmod-simp-logrotate: + branch: master + https://github.com/simp/pupmod-simp-mate: + branch: master + # Test failures - https://github.com/simp/pupmod-simp-mockup/pull/94 + # https://github.com/simp/pupmod-simp-mockup: + # branch: master + https://github.com/simp/pupmod-simp-mozilla: + branch: master + https://github.com/simp/pupmod-simp-named: + branch: master + https://github.com/simp/pupmod-simp-network: + branch: master + https://github.com/simp/pupmod-simp-nfs: + branch: master + https://github.com/simp/pupmod-simp-ntpd: + branch: master + https://github.com/simp/pupmod-simp-oath: + branch: master + https://github.com/simp/pupmod-simp-oddjob: + branch: master + https://github.com/simp/pupmod-simp-openscap: + branch: master + https://github.com/simp/pupmod-simp-pam: + branch: master + https://github.com/simp/pupmod-simp-pki: + branch: master + https://github.com/simp/pupmod-simp-polkit: + branch: master + https://github.com/simp/pupmod-simp-postfix: + branch: master + https://github.com/simp/pupmod-simp-pupmod: + branch: master + https://github.com/simp/pupmod-simp-resolv: + branch: master + https://github.com/simp/pupmod-simp-rkhunter: + branch: master + https://github.com/simp/pupmod-simp-rsync: + branch: master + https://github.com/simp/pupmod-simp-rsyslog: + branch: master + https://github.com/simp/pupmod-simp-selinux: + branch: master + https://github.com/simp/pupmod-simp-simp: + branch: master + https://github.com/simp/pupmod-simp-simp_apache: + branch: master + https://github.com/simp/pupmod-simp-simp_authselect: + branch: master + https://github.com/simp/pupmod-simp-simp_banners: + branch: master + https://github.com/simp/pupmod-simp-simp_bolt: + branch: master + https://github.com/simp/pupmod-simp-simp_ds389: + branch: master + https://github.com/simp/pupmod-simp-simp_firewalld: + branch: master + https://github.com/simp/pupmod-simp-simp_gitlab: + branch: master + https://github.com/simp/pupmod-simp-simp_grub: + branch: master + https://github.com/simp/pupmod-simp-simp_ipa: + branch: master + https://github.com/simp/pupmod-simp-simp_nfs: + branch: master + https://github.com/simp/pupmod-simp-simp_openldap: + branch: master + https://github.com/simp/pupmod-simp-simp_options: + branch: master + https://github.com/simp/pupmod-simp-simp_pki_service: + branch: master + https://github.com/simp/pupmod-simp-simp_rsyslog: + branch: master + https://github.com/simp/pupmod-simp-simp_snmpd: + branch: master + https://github.com/simp/pupmod-simp-simpkv: + branch: master + https://github.com/simp/pupmod-simp-simplib: + branch: master + https://github.com/simp/pupmod-simp-site: + branch: master + https://github.com/simp/pupmod-simp-ssh: + branch: master + https://github.com/simp/pupmod-simp-sssd: + branch: master + https://github.com/simp/pupmod-simp-stunnel: + branch: master + https://github.com/simp/pupmod-simp-sudo: + branch: master + https://github.com/simp/pupmod-simp-sudosh: + branch: master + https://github.com/simp/pupmod-simp-svckill: + branch: master + https://github.com/simp/pupmod-simp-swap: + branch: master + https://github.com/simp/pupmod-simp-tcpwrappers: + branch: master + https://github.com/simp/pupmod-simp-tftpboot: + branch: master + https://github.com/simp/pupmod-simp-tlog: + branch: master + https://github.com/simp/pupmod-simp-tpm: + branch: master + https://github.com/simp/pupmod-simp-tpm2: + branch: master + https://github.com/simp/pupmod-simp-tuned: + branch: master + https://github.com/simp/pupmod-simp-useradd: + branch: master + https://github.com/simp/pupmod-simp-vnc: + branch: master + https://github.com/simp/pupmod-simp-vsftpd: + branch: master + https://github.com/simp/pupmod-simp-x2go: + branch: master + https://github.com/simp/pupmod-simp-xinetd: + branch: master + # Test failures - https://github.com/simp/puppet-gpasswd/pull/25 + # https://github.com/simp/puppet-gpasswd: + # branch: master + https://github.com/simp/puppetsync: + branch: main + # Test failures - https://github.com/simp/rubygem-simp-beaker-helpers/pull/220 + # https://github.com/simp/rubygem-simp-beaker-helpers: + # branch: master + https://github.com/simp/rubygem-simp-build-helpers: + branch: master + https://github.com/simp/rubygem-simp-cli: + branch: master + https://github.com/simp/rubygem-simp-compliance_engine: + branch: main + # Test failures - https://github.com/simp/rubygem-simp-rake-helpers/pull/216 + # https://github.com/simp/rubygem-simp-rake-helpers: + # branch: master + https://github.com/simp/rubygem-simp-scelint: + branch: master + https://github.com/simp/simp-adapter: + branch: master + # Test failures - https://github.com/simp/simp-core/pull/894 + # https://github.com/simp/simp-core: + # branch: master + https://github.com/simp/simp-doc: + branch: master + https://github.com/simp/simp-environment-skeleton: + branch: master + https://github.com/simp/simp-gpgkeys: + branch: master + https://github.com/simp/simp-rsync-skeleton: + branch: master + # Test failures - https://github.com/simp/simp-selinux-policy/pull/6 + # https://github.com/simp/simp-selinux-policy: + # branch: master + https://github.com/simp/simp-tpm12-simulator: + branch: master + https://github.com/simp/simp-tpm2-simulator: + branch: master + https://github.com/simp/simp-utils: + branch: master + # forks missing from generated config + https://github.com/simp/rubygem-simp-rspec-puppet-facts: + branch: master + https://github.com/simp/pupmod-simp-haveged: + branch: master diff --git a/data/sync/repolists/gcp__batch_01.yaml b/data/sync/repolists/gcp__batch_01.yaml index c66b015..0fd63fa 100644 --- a/data/sync/repolists/gcp__batch_01.yaml +++ b/data/sync/repolists/gcp__batch_01.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: https://github.com/simp/pkg-r10k: @@ -21,8 +22,8 @@ puppetsync::repos_config: https://github.com/simp/pupmod-simp-clamav: branch: master - # https://github.com/simp/pupmod-simp-common: - #branch: master + # https://github.com/simp/pupmod-simp-common: + # branch: master https://github.com/simp/pupmod-simp-compliance_markup: branch: master @@ -35,5 +36,3 @@ puppetsync::repos_config: https://github.com/simp/pupmod-simp-dconf: branch: master - - diff --git a/data/sync/repolists/gcp__batch_02.yaml b/data/sync/repolists/gcp__batch_02.yaml index e284cac..aa6ebe7 100644 --- a/data/sync/repolists/gcp__batch_02.yaml +++ b/data/sync/repolists/gcp__batch_02.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: https://github.com/simp/pupmod-simp-deferred_resources: @@ -38,4 +39,3 @@ puppetsync::repos_config: https://github.com/simp/pupmod-simp-iptables: branch: master - diff --git a/data/sync/repolists/gcp__batch_03.yaml b/data/sync/repolists/gcp__batch_03.yaml index 32a4ac0..44da824 100644 --- a/data/sync/repolists/gcp__batch_03.yaml +++ b/data/sync/repolists/gcp__batch_03.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: https://github.com/simp/pupmod-simp-issue: @@ -38,5 +39,3 @@ puppetsync::repos_config: https://github.com/simp/pupmod-simp-ntpd: branch: master - - diff --git a/data/sync/repolists/gcp__batch_04.yaml b/data/sync/repolists/gcp__batch_04.yaml index f2aac3e..dd2d8aa 100644 --- a/data/sync/repolists/gcp__batch_04.yaml +++ b/data/sync/repolists/gcp__batch_04.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: https://github.com/simp/pupmod-simp-oath: @@ -35,4 +36,3 @@ puppetsync::repos_config: https://github.com/simp/pupmod-simp-rsyslog: branch: master - diff --git a/data/sync/repolists/gcp__batch_05.yaml b/data/sync/repolists/gcp__batch_05.yaml index 17b8a17..75c3126 100644 --- a/data/sync/repolists/gcp__batch_05.yaml +++ b/data/sync/repolists/gcp__batch_05.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: https://github.com/simp/pupmod-simp-selinux: @@ -9,20 +10,20 @@ puppetsync::repos_config: https://github.com/simp/pupmod-simp-simp_apache: branch: master - # https://github.com/simp/pupmod-simp-simp_choria: - #branch: master + # https://github.com/simp/pupmod-simp-simp_choria: + # branch: master - #https://github.com/simp/pupmod-simp-simp_consul: - #branch: master + # https://github.com/simp/pupmod-simp-simp_consul: + # branch: master - #https://github.com/simp/pupmod-simp-simp_docker: - #branch: master + # https://github.com/simp/pupmod-simp-simp_docker: + # branch: master https://github.com/simp/pupmod-simp-simp_ds389: branch: master - #https://github.com/simp/pupmod-simp-simp_elasticsearch: - #branch: master + # https://github.com/simp/pupmod-simp-simp_elasticsearch: + # branch: master https://github.com/simp/pupmod-simp-simp_firewalld: branch: master @@ -30,8 +31,8 @@ puppetsync::repos_config: https://github.com/simp/pupmod-simp-simp_gitlab: branch: master - #https://github.com/simp/pupmod-simp-simp_grafana: - #branch: master + # https://github.com/simp/pupmod-simp-simp_grafana: + # branch: master https://github.com/simp/pupmod-simp-simp_grub: branch: master @@ -39,7 +40,5 @@ puppetsync::repos_config: https://github.com/simp/pupmod-simp-simp_ipa: branch: master - #https://github.com/simp/pupmod-simp-simp_logstash: - #branch: master - - + # https://github.com/simp/pupmod-simp-simp_logstash: + # branch: master diff --git a/data/sync/repolists/gcp__batch_06.yaml b/data/sync/repolists/gcp__batch_06.yaml index aed8cb0..107af7a 100644 --- a/data/sync/repolists/gcp__batch_06.yaml +++ b/data/sync/repolists/gcp__batch_06.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: https://github.com/simp/pupmod-simp-simp_nfs: @@ -35,5 +36,3 @@ puppetsync::repos_config: https://github.com/simp/pupmod-simp-sudosh: branch: master - - diff --git a/data/sync/repolists/gcp__batch_07.yaml b/data/sync/repolists/gcp__batch_07.yaml index c90c3bd..f70406d 100644 --- a/data/sync/repolists/gcp__batch_07.yaml +++ b/data/sync/repolists/gcp__batch_07.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: https://github.com/simp/pupmod-simp-svckill: @@ -6,8 +7,8 @@ puppetsync::repos_config: https://github.com/simp/pupmod-simp-swap: branch: master - # https://github.com/simp/pupmod-simp-sysctl: - #branch: master + # https://github.com/simp/pupmod-simp-sysctl: + # branch: master https://github.com/simp/pupmod-simp-tftpboot: branch: master @@ -42,9 +43,8 @@ puppetsync::repos_config: https://github.com/simp/simp-adapter: branch: master - # https://github.com/simp/simp-core: - #branch: master + # https://github.com/simp/simp-core: + # branch: master https://github.com/simp/simp-utils: branch: master - diff --git a/data/sync/repolists/latest.yaml b/data/sync/repolists/latest.yaml index bca06c2..2bd7225 120000 --- a/data/sync/repolists/latest.yaml +++ b/data/sync/repolists/latest.yaml @@ -1 +1 @@ -20240905-iptables-7.yaml \ No newline at end of file +20240724-lint-cleanup.yaml \ No newline at end of file diff --git a/data/sync/repolists/p+r_test.yaml b/data/sync/repolists/p+r_test.yaml index f6f9c04..f8a1bab 100644 --- a/data/sync/repolists/p+r_test.yaml +++ b/data/sync/repolists/p+r_test.yaml @@ -1,4 +1,4 @@ - +--- puppetsync::repos_config: https://github.com/simp/pupmod-simp-network: diff --git a/data/sync/repolists/pupmod_skeleton.yaml b/data/sync/repolists/pupmod_skeleton.yaml index 70d22f1..1745dad 100644 --- a/data/sync/repolists/pupmod_skeleton.yaml +++ b/data/sync/repolists/pupmod_skeleton.yaml @@ -1,5 +1,4 @@ - +--- puppetsync::repos_config: https://github.com/simp/puppet-module-skeleton: branch: master - diff --git a/data/sync/repolists/pupmods__batch_02.yaml b/data/sync/repolists/pupmods__batch_02.yaml index 886465c..285598d 100644 --- a/data/sync/repolists/pupmods__batch_02.yaml +++ b/data/sync/repolists/pupmods__batch_02.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: # https://github.com/simp/pupmod-simp-acpid: diff --git a/data/sync/repolists/pupmods__batch_03.yaml b/data/sync/repolists/pupmods__batch_03.yaml index 21922a1..879be89 100644 --- a/data/sync/repolists/pupmods__batch_03.yaml +++ b/data/sync/repolists/pupmods__batch_03.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: # https://github.com/simp/pupmod-simp-acpid: diff --git a/data/sync/repolists/pupmods__batch_04.yaml b/data/sync/repolists/pupmods__batch_04.yaml index d26baa8..6f0c5f0 100644 --- a/data/sync/repolists/pupmods__batch_04.yaml +++ b/data/sync/repolists/pupmods__batch_04.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: # https://github.com/simp/pupmod-simp-acpid: @@ -54,26 +55,26 @@ puppetsync::repos_config: # https://github.com/simp/pupmod-simp-gnome: # branch: master # - https://github.com/simp/pupmod-simp-haveged: - branch: master + https://github.com/simp/pupmod-simp-haveged: + branch: master - https://github.com/simp/pupmod-simp-hirs_provisioner: - branch: master + https://github.com/simp/pupmod-simp-hirs_provisioner: + branch: master - https://github.com/simp/pupmod-simp-ima: - branch: master + https://github.com/simp/pupmod-simp-ima: + branch: master - https://github.com/simp/pupmod-simp-incron: - branch: master + https://github.com/simp/pupmod-simp-incron: + branch: master - https://github.com/simp/pupmod-simp-iptables: - branch: master + https://github.com/simp/pupmod-simp-iptables: + branch: master - https://github.com/simp/pupmod-simp-issue: - branch: master + https://github.com/simp/pupmod-simp-issue: + branch: master - https://github.com/simp/pupmod-simp-krb5: - branch: master + https://github.com/simp/pupmod-simp-krb5: + branch: master ### https://github.com/simp/pupmod-simp-libreswan: ### branch: master diff --git a/data/sync/repolists/pupmods__batch_05.yaml b/data/sync/repolists/pupmods__batch_05.yaml index 9f1cfce..ba84552 100644 --- a/data/sync/repolists/pupmods__batch_05.yaml +++ b/data/sync/repolists/pupmods__batch_05.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: # https://github.com/simp/pupmod-simp-acpid: diff --git a/data/sync/repolists/pupmods__batch_06.yaml b/data/sync/repolists/pupmods__batch_06.yaml index e03a735..458dde0 100644 --- a/data/sync/repolists/pupmods__batch_06.yaml +++ b/data/sync/repolists/pupmods__batch_06.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: # https://github.com/simp/pupmod-simp-acpid: diff --git a/data/sync/repolists/pupmods__batch_07.yaml b/data/sync/repolists/pupmods__batch_07.yaml index 5f8f7c0..f949c7f 100644 --- a/data/sync/repolists/pupmods__batch_07.yaml +++ b/data/sync/repolists/pupmods__batch_07.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: # https://github.com/simp/pupmod-simp-acpid: diff --git a/data/sync/repolists/pupmods__batch_08.yaml b/data/sync/repolists/pupmods__batch_08.yaml index 1dadf57..3fb1f3e 100644 --- a/data/sync/repolists/pupmods__batch_08.yaml +++ b/data/sync/repolists/pupmods__batch_08.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: # https://github.com/simp/pupmod-simp-acpid: diff --git a/data/sync/repolists/pupmods__batch_09.yaml b/data/sync/repolists/pupmods__batch_09.yaml index 5e0d41b..df7eb94 100644 --- a/data/sync/repolists/pupmods__batch_09.yaml +++ b/data/sync/repolists/pupmods__batch_09.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: # https://github.com/simp/pupmod-simp-acpid: diff --git a/data/sync/repolists/pupmods__batch_10.yaml b/data/sync/repolists/pupmods__batch_10.yaml index 9ab5bf5..4fcc56f 100644 --- a/data/sync/repolists/pupmods__batch_10.yaml +++ b/data/sync/repolists/pupmods__batch_10.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: # https://github.com/simp/pupmod-simp-acpid: diff --git a/data/sync/repolists/pupmods__batch_11.yaml b/data/sync/repolists/pupmods__batch_11.yaml index 6bd3c1c..321c379 100644 --- a/data/sync/repolists/pupmods__batch_11.yaml +++ b/data/sync/repolists/pupmods__batch_11.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: # https://github.com/simp/pupmod-simp-acpid: diff --git a/data/sync/repolists/pupmods__batch_12.yaml b/data/sync/repolists/pupmods__batch_12.yaml index 19ae8fa..45d91cb 100644 --- a/data/sync/repolists/pupmods__batch_12.yaml +++ b/data/sync/repolists/pupmods__batch_12.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: # https://github.com/simp/pupmod-simp-acpid: diff --git a/data/sync/repolists/pupmods__batch_13.yaml b/data/sync/repolists/pupmods__batch_13.yaml index 33b5ca1..fc8cff1 100644 --- a/data/sync/repolists/pupmods__batch_13.yaml +++ b/data/sync/repolists/pupmods__batch_13.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: # https://github.com/simp/pupmod-simp-acpid: diff --git a/data/sync/repolists/pupmods__batch_14.yaml b/data/sync/repolists/pupmods__batch_14.yaml index bc125ec..4ea113b 100644 --- a/data/sync/repolists/pupmods__batch_14.yaml +++ b/data/sync/repolists/pupmods__batch_14.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: # https://github.com/simp/pupmod-simp-acpid: diff --git a/data/sync/repolists/pupmods_mockup.yaml b/data/sync/repolists/pupmods_mockup.yaml index fa126db..13b0c86 100644 --- a/data/sync/repolists/pupmods_mockup.yaml +++ b/data/sync/repolists/pupmods_mockup.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: https://github.com/simp/pupmod-simp-mockup: diff --git a/data/sync/repolists/pupmods_remaining.yaml b/data/sync/repolists/pupmods_remaining.yaml index ec4d1f9..1e8d6fd 100644 --- a/data/sync/repolists/pupmods_remaining.yaml +++ b/data/sync/repolists/pupmods_remaining.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: https://github.com/simp/pupmod-simp-acpid: diff --git a/data/sync/repolists/pupmods_test.yaml b/data/sync/repolists/pupmods_test.yaml index 01f7b81..eb2055c 100644 --- a/data/sync/repolists/pupmods_test.yaml +++ b/data/sync/repolists/pupmods_test.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: # https://github.com/simp/pupmod-simp-simplib: diff --git a/data/sync/repolists/rubygems.yaml b/data/sync/repolists/rubygems.yaml index 5e0e53d..d86aac9 100644 --- a/data/sync/repolists/rubygems.yaml +++ b/data/sync/repolists/rubygems.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: https://github.com/simp/rubygem-simp-beaker-helpers: diff --git a/data/sync/repolists/rubygems_rubygems_org.yaml b/data/sync/repolists/rubygems_rubygems_org.yaml index 9bebbe5..4e67e1f 100644 --- a/data/sync/repolists/rubygems_rubygems_org.yaml +++ b/data/sync/repolists/rubygems_rubygems_org.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: ### https://github.com/simp/rubygem-simp-beaker-helpers: diff --git a/data/sync/repolists/simp_core.yaml b/data/sync/repolists/simp_core.yaml index 2114023..bb688d0 100644 --- a/data/sync/repolists/simp_core.yaml +++ b/data/sync/repolists/simp_core.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: https://github.com/simp/simp-core: diff --git a/data/sync/repolists/simp_doc.yaml b/data/sync/repolists/simp_doc.yaml index a991f79..8b345e7 100644 --- a/data/sync/repolists/simp_doc.yaml +++ b/data/sync/repolists/simp_doc.yaml @@ -1,3 +1,4 @@ +--- puppetsync::repos_config: https://github.com/simp/simp-doc: diff --git a/data/sync/repolists/simp_misc.yaml b/data/sync/repolists/simp_misc.yaml index a2b0af4..2d38b26 100644 --- a/data/sync/repolists/simp_misc.yaml +++ b/data/sync/repolists/simp_misc.yaml @@ -1,16 +1,17 @@ +--- puppetsync::repos_config: # TODO: determine if gitlab-beaker-cleanup-driver needs its own project type - #https://github.com/simp/gitlab-beaker-cleanup-driver: - # branch: main + # https://github.com/simp/gitlab-beaker-cleanup-driver: + # branch: main # TODO: determine if releng-misc needs its own project type - #https://github.com/simp/releng-misc: - # branch: master + # https://github.com/simp/releng-misc: + # branch: master # TODO: review simp-core's GLCI pipeline customizations - #https://github.com/simp/simp-core: - # branch: master + # https://github.com/simp/simp-core: + # branch: master https://github.com/simp/simp-doc: branch: master diff --git a/dist/puppetsync/files/ensure_jira_subtask.rb b/dist/puppetsync/files/ensure_jira_subtask.rb index 3b310c8..06009d5 100644 --- a/dist/puppetsync/files/ensure_jira_subtask.rb +++ b/dist/puppetsync/files/ensure_jira_subtask.rb @@ -1,4 +1,5 @@ require 'json' +# JiraHelper class class JiraHelper def initialize( username = ENV['JIRA_USER'], @@ -28,8 +29,8 @@ def ensure_subtask(project_string, parent_issue_string, component_name, subtask_ subtask_issuetype_id = issuetype_id(%r{^Sub-task}i) st_summary = subtask_opts[:subtask_title].gsub('%COMPONENT%', component_name) - st_description = (subtask_opts[:subtask_description]) ? subtask_opts[:subtask_description].gsub('%COMPONENT%', component_name) : nil - st_story_points = (subtask_opts[:subtask_story_points]) ? subtask_opts[:subtask_story_points] : nil + st_description = subtask_opts[:subtask_description]&.gsub('%COMPONENT%', component_name) + st_story_points = subtask_opts[:subtask_story_points] ? subtask_opts[:subtask_story_points] : nil component = project.components.select { |x| x.name == component_name } raise("FATAL: could not find component for '#{component_name}' in Jira project '#{project_string}'") if component.empty? @@ -54,26 +55,26 @@ def ensure_subtask(project_string, parent_issue_string, component_name, subtask_ data['id'] = existing_subtasks_for_target.first.attrs['id'] end - if existing_subtasks_for_target.empty? || true - begin - issue = @client.Issue.build data - issue.save! data - if subtask_opts[:subtask_assignee] - st_assignee = @client.User.myself.attrs['accountId'] - issue.save('fields' => { 'assignee' => { 'accountId' => st_assignee } }) - end - rescue JIRA::HTTPError => e - require 'yaml' - warn e.to_yaml - require 'pry' - binding.irb - raise e + # if existing_subtasks_for_target.empty? || true + begin + issue = @client.Issue.build data + issue.save! data + if subtask_opts[:subtask_assignee] + st_assignee = @client.User.myself.attrs['accountId'] + issue.save('fields' => { 'assignee' => { 'accountId' => st_assignee } }) end - issue.fetch - target_subtask_issue_key = issue.key - else - target_subtask_issue_key = existing_subtasks_for_target.first.key + rescue JIRA::HTTPError => e + require 'yaml' + warn e.to_yaml + require 'pry' + binding.irb # rubocop:disable Lint/Debugger + raise e end + issue.fetch + target_subtask_issue_key = issue.key + # else + # target_subtask_issue_key = existing_subtasks_for_target.first.key + # end target_subtask_issue_key end @@ -89,12 +90,12 @@ def undone_target_component_subtasks(project_string, parent_issue_string, compon # # risks: # - Jira supports more than one component ber issue/subtask - _jql = "project = #{project_string} " \ - " AND parent = #{parent_issue_string}" \ - " AND component = #{component_name}" \ - ' AND statuscategory != done' + # FIXME: remains to be seen if this is necessary - ' AND statuscategory != undefined' - @client.Issue.jql(_jql) + jql = "project = #{project_string} " \ + " AND parent = #{parent_issue_string}" \ + " AND component = #{component_name}" \ + ' AND statuscategory != done' + # FIXME: remains to be seen if this is necessary + ' AND statuscategory != undefined' + @client.Issue.jql(jql) end # @param [JIRA::Client] client @@ -115,10 +116,10 @@ def custom_field_id(regex = %r{^story points}i) matching_fields = @client.Field.all.select { |x| x.name =~ regex } raise "ERROR: No fields that match #{regex}" if matching_fields.empty? if matching_fields.size > 1 - raise ( + raise( "ERROR: Too many fields that match #{regex} " \ "(got #{matching_fields.size}, expected 1): \n\n" + - matching_fields.to_yaml + matching_fields.to_yaml, ) end matching_fields.first.id @@ -128,10 +129,10 @@ def issuetype_id(regex = %r{^Sub-task}) matching_fields = @client.Issuetype.all.select { |x| x.name =~ regex } raise "ERROR: No issuetypes that match #{regex}" if matching_fields.empty? if matching_fields.size > 1 - raise ( + raise( "ERROR: Too many fields that match #{regex} " \ "(got #{matching_fields.size}, expected 1): \n\n" + - matching_fields.to_yaml + matching_fields.to_yaml, ) end matching_fields.first.id @@ -155,5 +156,6 @@ def issuetype_id(regex = %r{^Sub-task}) kwargs[:component_name.to_s], Hash[opts.map { |k, v| [k.to_sym, v] }], ) - require 'pry'; binding.pry + require 'pry' + binding.pry # rubocop:disable Lint/Debugger end diff --git a/dist/puppetsync/files/git_repo_remote_tasks.rb b/dist/puppetsync/files/git_repo_remote_tasks.rb index c3b4b11..95662f2 100644 --- a/dist/puppetsync/files/git_repo_remote_tasks.rb +++ b/dist/puppetsync/files/git_repo_remote_tasks.rb @@ -18,18 +18,17 @@ def ensure_remote_exists pid = spawn 'git', 'remote', 'add', @remote_name, @remote_url Process.wait pid - if $CHILD_STATUS.success? - puts "== #{File.basename(dir)} : set remote '#{@remote_name}' to '#{@remote_url}' in #{dir}" - else - raise "ERROR (#{File.basename(dir)}): Failed to set remote '#{@remote_name}' to '#{@remote_url}' in #{dir}" - end + raise "ERROR (#{File.basename(dir)}): Failed to set remote '#{@remote_name}' to '#{@remote_url}' in #{dir}" unless $CHILD_STATUS.success? + puts "== #{File.basename(dir)} : set remote '#{@remote_name}' to '#{@remote_url}' in #{dir}" + end end end def push_to_github_over_https(github_token) - raise "Remote URL '#{@remote_url}` must be https!" unless @remote_url =~ %r{^https}i - require 'pry'; binding.pry + raise "Remote URL '#{@remote_url}` must be https!" unless %r{^https}i.match?(@remote_url) + require 'pry' + binding.pry # rubocop:disable Lint/Debugger # FIXME: no such thing as shl # shl ['git', 'push', remote_name, git_ref, '-f'] end @@ -38,7 +37,7 @@ def push_to_github_over_https(github_token) if $PROGRAM_NAME == __FILE__ require 'pry' repo_path = ARGV[0] - ref = ARGV[0] || 'SIMP-7035' + ref = ARGV[0] || 'SIMP-7035' # rubocop:disable Lint/UselessAssignment remote_url = ARGV[1] || 'https://github.com/op-ct/pupmod-simp-aide' helper = GitRepoRemoteTasks.new(repo_path, remote_url) diff --git a/dist/puppetsync/files/github_pr_forker.rb b/dist/puppetsync/files/github_pr_forker.rb index 49e15d9..1d6bc50 100644 --- a/dist/puppetsync/files/github_pr_forker.rb +++ b/dist/puppetsync/files/github_pr_forker.rb @@ -1,5 +1,6 @@ require 'octokit' +# GitHubPRForker class class GitHubPRForker attr_reader :created_pr, :created_fork @@ -32,9 +33,9 @@ def ensure_fork(upstream_reponame, _opts = {}) def existing_pr(upstream_reponame, target_branch, fork_user, fork_branch) repo_fork = user_fork_of_repo(upstream_reponame, fork_user) prs = @client.pull_requests(upstream_reponame).select do |pr| - pr.user.login == fork_user && \ - pr.head.repo.full_name == repo_fork.full_name && \ - pr.head.ref == fork_branch && \ + pr.user.login == fork_user && + pr.head.repo.full_name == repo_fork.full_name && + pr.head.ref == fork_branch && pr.base.ref == target_branch # TODO: should we test for merged PRs, too? How? end @@ -98,7 +99,7 @@ def approve_pr(pr, approval_message) if my_approvals.empty? warn("== Approving PR #{pr.html_url}") review = @client.create_pull_request_review(pr.base.repo.full_name, pr.number, opts) - elsif old_review = my_approvals.select { |x| x.body =~ Regexp.new(approval_tag) }.last + elsif (old_review = my_approvals.reverse.find { |x| x.body =~ Regexp.new(approval_tag) }) puts '== we have already left an approval with this software; updating' review = @client.update_pull_request_review( pr.base.repo.full_name, pr.number, old_review.id, "#{tagged_approval_message}\n" @@ -175,5 +176,6 @@ def merge_pr(pr) # ##repo_pr = forker.approve_pr(pr, opts[:approval_message] || ':+1: :ghost:') result = forker.merge_pr(pr) puts result - require 'pry'; binding.pry + require 'pry' + binding.pry # rubocop:disable Lint/Debugger end diff --git a/dist/puppetsync/functions/ensure_jira_subtask_for_each_repo.pp b/dist/puppetsync/functions/ensure_jira_subtask_for_each_repo.pp index ed52b5f..d91ebca 100644 --- a/dist/puppetsync/functions/ensure_jira_subtask_for_each_repo.pp +++ b/dist/puppetsync/functions/ensure_jira_subtask_for_each_repo.pp @@ -21,27 +21,27 @@ # Jira API token # (Default: Environment variable `$JIRA_API_TOKEN`) # -# @return [Array[Bolt::Result]] +# @return [Optional[Variant[Result, ApplyResult]]] function puppetsync::ensure_jira_subtask_for_each_repo( TargetSpec $repos, Hash $puppetsync_config, String[1] $jira_username = system::env('JIRA_USER'), Sensitive[String[1]] $jira_token = Sensitive(system::env('JIRA_API_TOKEN')), Stdlib::Absolutepath $extra_gem_path = "#{system::env('PWD')}/.plan.gems" -) { +) >> Optional[Variant[Result, ApplyResult]] { $repos.map |$target| { assert_type( Hash, $puppetsync_config['jira']) $set_assignee = $puppetsync_config['jira']['subtask_assignee'] ? { - true => $puppetsync_config['jira']['subtask_assignee'], + true => $puppetsync_config['jira']['subtask_assignee'], default => undef, } # TODO: This doesn't work and isn't important to fix: always set to undef? $description = $puppetsync_config['jira']['subtask_description'].empty ? { - false => $puppetsync_config['jira']['subtask_description'], + false => $puppetsync_config['jira']['subtask_description'], default => undef, } $story_points = String($puppetsync_config['jira']['subtask_story_points']).empty ? { - false => $puppetsync_config['jira']['subtask_story_points'], + false => $puppetsync_config['jira']['subtask_story_points'], default => undef, } diff --git a/dist/puppetsync/functions/filter_permitted_repos.pp b/dist/puppetsync/functions/filter_permitted_repos.pp index dc5b916..51ad63e 100644 --- a/dist/puppetsync/functions/filter_permitted_repos.pp +++ b/dist/puppetsync/functions/filter_permitted_repos.pp @@ -1,8 +1,8 @@ function puppetsync::filter_permitted_repos( TargetSpec $pf_repos, Hash $puppetsync_config, -){ - $permitted_project_types = $puppetsync_config.dig('puppetsync','permitted_project_types').lest || {[]} +) >> TargetSpec { + $permitted_project_types = $puppetsync_config.dig('puppetsync','permitted_project_types').lest || {[] } $pf_repos.filter |$repo| { if ($repo.facts.dig('project_type') in $permitted_project_types) { true @@ -11,7 +11,7 @@ function puppetsync::filter_permitted_repos( sprintf( "== WARNING: Rejecting target '%s' from repos because its project_type (%s) is not in the permitted project_types (%s)", $repo.name, - ($repo.facts.dig('project_type').lest || {''}), + ($repo.facts.dig('project_type').lest || { '' }), $permitted_project_types.join(', ') ) ) @@ -19,4 +19,3 @@ function puppetsync::filter_permitted_repos( } } } - diff --git a/dist/puppetsync/functions/output_pipeline_results.pp b/dist/puppetsync/functions/output_pipeline_results.pp index 48d6722..c9a2d30 100644 --- a/dist/puppetsync/functions/output_pipeline_results.pp +++ b/dist/puppetsync/functions/output_pipeline_results.pp @@ -4,19 +4,20 @@ function puppetsync::output_pipeline_results( TargetSpec $repos, Stdlib::Absolutepath $project_dir, Hash $project_opts = {}, -){ +) { if $project_opts.dig('list_pipeline_stages') { warning( 'Project is listing pipeline stages; no results to output' ) - return( {} ) + return({}) } - out::message( [ - '', - '================================================================================', - " FINIS ", - '================================================================================', - "time to sort out what happened to:\n\t${repos}", - '--------------------------------------------------------------------------------', - '', + out::message( + [ + '', + '================================================================================', + " FINIS ", + '================================================================================', + "time to sort out what happened to:\n\t${repos}", + '--------------------------------------------------------------------------------', + '', ].join("\n") ) @@ -29,19 +30,19 @@ function puppetsync::output_pipeline_results( $e = $v.dig($key,'data') [ "${e['target']}: ${key}", - {'stage'=>$key } + - $e.filter |$x,$y| { $x in ['action', 'object'] } + - $e.dig('value','_error').lest||{{}}.filter |$x,$y| { $x in ['kind','msg'] } + { 'stage'=> $key } + + $e.filter |$x,$y| { $x in ['action', 'object'] } + + $e.dig('value','_error').lest|| {{} }.filter |$x,$y| { $x in ['kind','msg'] } ] } Hash($pairs) - }.reduce({})|$m,$v|{$m+$v} + }.reduce({})|$m,$v| { $m+$v } out::message( "===== ERRORS (${f_hashes.values.count}): \n\n" ) out::message( $f_hashes.map |$k,$v| { - $banner = "=== ${k}".format::colorize('fatal') - $msg = "${v['action']} ${v['object']} (${v['kind']}):\n${v['msg']}".format::colorize('warning') - "${banner}\n\n${msg}" + $banner = "=== ${k}".format::colorize('fatal') + $msg = "${v['action']} ${v['object']} (${v['kind']}):\n${v['msg']}".format::colorize('warning') + "${banner}\n\n${msg}" }.join("\n\n\n") ) fail_plan( 'Plan complete: failures occured', 'puppetsync--plan-errors', $f_hashes ) } diff --git a/dist/puppetsync/functions/record_stage_results.pp b/dist/puppetsync/functions/record_stage_results.pp index d897d6a..691837b 100644 --- a/dist/puppetsync/functions/record_stage_results.pp +++ b/dist/puppetsync/functions/record_stage_results.pp @@ -7,8 +7,9 @@ function puppetsync::record_stage_results( String[1] $stage_name, Variant[ApplyResult,ResultSet,Result,Array[Result],Array[ResultSet]] $results -){ +) { case $results { + # lint:ignore:unquoted_string_in_case Array[Result]: { warning( "** puppetsync::record_stage_results (${stage_name}): Array[Result], ResultSet" ) $results.each |$result| { puppetsync::record_stage_results($stage_name, $result) } @@ -41,5 +42,6 @@ function puppetsync::record_stage_results( out::message("+++++++ DEFAULT puppetsync::record_stage_results (\$result = Tuple?)") debug::break() } + # lint:endignore } } diff --git a/dist/puppetsync/functions/repo_sync_metadata.pp b/dist/puppetsync/functions/repo_sync_metadata.pp deleted file mode 100644 index fc392cc..0000000 --- a/dist/puppetsync/functions/repo_sync_metadata.pp +++ /dev/null @@ -1,6 +0,0 @@ -class puppetsync::repo_sync_metadata( - String $file, - Stdlib::Absolutepath $repo_dir = $::repo_path, -){ - -} diff --git a/dist/puppetsync/functions/repo_targets_from_repolist.pp b/dist/puppetsync/functions/repo_targets_from_repolist.pp index c8f50da..3de3600 100644 --- a/dist/puppetsync/functions/repo_targets_from_repolist.pp +++ b/dist/puppetsync/functions/repo_targets_from_repolist.pp @@ -8,12 +8,12 @@ # @param inventory_group # Name of inventory group for the repo Targets # -# @param default_moduledir -# Path to directory where repos will be cloned -# # @param project_dir # The bolt project directory. # +# @param default_moduledir +# Path to directory where repos will be cloned +# # @return [TargetSpec] the repo Targets read from the Puppetfile # function puppetsync::repo_targets_from_repolist( @@ -21,22 +21,24 @@ function puppetsync::repo_targets_from_repolist( String[1] $inventory_group, Stdlib::Absolutepath $project_dir, String[1] $default_moduledir = '_repos', -) { - $pf_repos = Hash($repos_config.map |$url, $data| { - [ - $url.basename, - { - 'git_url' => $url, - 'name' => $url.basename, - 'rel_path' => "${default_moduledir}/${url.basename}", - ###'mod_rel_path' => "${default_moduledir}/${url.basename}", # .split(/[-\/]/)[-1], - ### 'install_path' => $default_moduledir, - ###'mod_name' => $url.basename, - 'repo_name' => $url.basename('.git'), # used by function template_git_commit_message() - 'branch' => $data['branch'], - }, - ] - }) +) >> TargetSpec { + $pf_repos = Hash( + $repos_config.map |$url, $data| { + [ + $url.basename, + { + 'git_url' => $url, + 'name' => $url.basename, + 'rel_path' => "${default_moduledir}/${url.basename}", + ###'mod_rel_path' => "${default_moduledir}/${url.basename}", # .split(/[-\/]/)[-1], + ### 'install_path' => $default_moduledir, + ###'mod_name' => $url.basename, + 'repo_name' => $url.basename('.git'), # used by function template_git_commit_message() + 'branch' => $data['branch'], + }, + ] + } + ) # add a localhost Target for each repo # -------------------------------------- @@ -57,7 +59,7 @@ function puppetsync::repo_targets_from_repolist( # automagically configured by bolt to point to its own ruby executable) # This keeps the inventory as cross-platform as possible $localhost = get_target('localhost') - $target.set_config( ['transport'], $localhost.config.dig('transport')) + $target.set_config(['transport'], $localhost.config.dig('transport')) $target.set_config( ['local', 'interpreters', '.rb'], $localhost.config.dig('local', 'interpreters', '.rb') diff --git a/dist/puppetsync/functions/setup_project_repos.pp b/dist/puppetsync/functions/setup_project_repos.pp index 1a1b4c0..83f2aa3 100644 --- a/dist/puppetsync/functions/setup_project_repos.pp +++ b/dist/puppetsync/functions/setup_project_repos.pp @@ -6,7 +6,7 @@ function puppetsync::setup_project_repos( Hash $repos_config, Stdlib::Absolutepath $project_dir = system::env('PWD'), Hash $options = {}, -){ +) >> Array[Target] { $opts = { 'clone_git_repos' => true, 'default_repo_moduledir' => '_repos', @@ -18,7 +18,7 @@ function puppetsync::setup_project_repos( $pf_repos = puppetsync::repo_targets_from_repolist( $repos_config, 'repo_targets', $project_dir, $opts['default_repo_moduledir'] ) - if $pf_repos.size == 0 { fail_plan( "No repos found to sync! Is the repolist set up correctly?" ) } + if $pf_repos.size == 0 { fail_plan( 'No repos found to sync! Is the repolist set up correctly?' ) } out::message( "== project_dir: '${project_dir}'" ) @@ -41,13 +41,13 @@ function puppetsync::setup_project_repos( run_command($cmd, $t) } } else { - warning( '' ) - warning( '== WARNING: **NOT** cloning git repos because $opts["clone_git_repos"] = false!' ) - warning( '== WARNING: This speeds up the start of plans, and is probably fine outside of a puppetsync. HOWEVER:' ) - warning( '== WARNING: * This will stop puppetsync from cloning, adding file-derived facts, and filtering repos (e.g., on project_type)' ) - warning( "== WARNING: * Among other consequences, all repo's project_type will remain 'unknown'." ) - warning( "== WARNING: If things go wrong, make SURE you didn't actually need facts or repo type-filtering!" ) - warning( '' ) + warning('') + warning('== WARNING: **NOT** cloning git repos because $opts["clone_git_repos"] = false!') + warning('== WARNING: This speeds up the start of plans, and is probably fine outside of a puppetsync. HOWEVER:') + warning('== WARNING: * This will stop puppetsync from cloning, adding file-derived facts, and filtering repos (e.g., on project_type)') + warning("== WARNING: * Among other consequences, all repo's project_type will remain 'unknown'.") + warning("== WARNING: If things go wrong, make SURE you didn't actually need facts or repo type-filtering!") + warning('') } puppetsync::setup_repos_facts( $pf_repos ) @@ -57,7 +57,8 @@ function puppetsync::setup_project_repos( } if $repos.size == 0 { - fail_plan( "No repos left to sync after filtering! Do the config's `permitted_project_types` match the repos in the repolist?" ) } + fail_plan( "No repos left to sync after filtering! Do the config's `permitted_project_types` match the repos in the repolist?" ) + } out::message(puppetsync::summarize_repo_targets($repos)) warning(puppetsync::summarize_repo_targets($repos,true)) diff --git a/dist/puppetsync/functions/setup_repos_facts.pp b/dist/puppetsync/functions/setup_repos_facts.pp index f8a2620..e6f8bd3 100644 --- a/dist/puppetsync/functions/setup_repos_facts.pp +++ b/dist/puppetsync/functions/setup_repos_facts.pp @@ -14,13 +14,13 @@ # # [0]: https://puppet.com/docs/puppet/latest/modules_metadata.html#modules_metadata_json_keys # -# @params repos Target objects for each locally checked-out git repo to consider +# @param repos Target objects for each locally checked-out git repo to consider # @return [TargetSpec] The same repos, now with facts function puppetsync::setup_repos_facts( TargetSpec $repos, -){ +) >> TargetSpec { $repos.each |$target| { - $target.add_facts( {'project_attributes' => []} ) + $target.add_facts({ 'project_attributes' => [] }) # pupmod # ------------------------------------------------------------------------ @@ -31,11 +31,11 @@ function puppetsync::setup_repos_facts( default => {}, } - if ['name','version','author','license','summary','dependencies'].all |$k| {$k in $module_metadata} { + if ['name','version','author','license','summary','dependencies'].all |$k| { $k in $module_metadata } { warning( "Repo is a Puppet module (detected ${metadata_json})" ) - unless $target.facts.dig('project_type'){ $target.add_facts({'project_type' => 'pupmod'} ) } - $target.add_facts( {'module_metadata' => $module_metadata } ) - $target.add_facts( {'project_attributes' => ($target.facts['project_attributes'] << 'pupmod')} ) + unless $target.facts.dig('project_type') { $target.add_facts({ 'project_type' => 'pupmod' }) } + $target.add_facts({ 'module_metadata' => $module_metadata }) + $target.add_facts({ 'project_attributes' => ($target.facts['project_attributes'] << 'pupmod') }) } $fixtures = "${target.vars['repo_path']}/.fixtures.yml" @@ -59,23 +59,23 @@ function puppetsync::setup_repos_facts( # pupmod_skeleton # ------------------------------------------------------------------------ $skeleton_metadata_json = "${target.vars['repo_path']}/skeleton/metadata.json.erb" - if ($target.facts['project_type'].empty and file::exists($skeleton_metadata_json)){ + if ($target.facts['project_type'].empty and file::exists($skeleton_metadata_json)) { warning( "Repo is a Puppet module Skeleton (detected ${skeleton_metadata_json})" ) - unless $target.facts.dig('project_type'){ $target.add_facts({'project_type' => 'pupmod_skeleton'} ) } - $target.add_facts( {'project_attributes' => ($target.facts['project_attributes'] << 'pupmod_skeleton')} ) + unless $target.facts.dig('project_type') { $target.add_facts({ 'project_type' => 'pupmod_skeleton' }) } + $target.add_facts({ 'project_attributes' => ($target.facts['project_attributes'] << 'pupmod_skeleton') }) } # rubygem # ------------------------------------------------------------------------ - $gemspecs = glob( [ "${target.vars['repo_path']}/*.gemspec" ] ) + $gemspecs = glob(["${target.vars['repo_path']}/*.gemspec"]) if !$gemspecs.empty { warning( "Repo is a RubyGem (detected ${gemspecs.join(', ')})" ) $gemspec_var = file($gemspecs[0]).match(/Gem::Specification\.new *do *\|(.*?)\|/)[1] #$gem_name = file($gemspecs[0]).split(/${gemspec_var}.name *= */)[1].split(/\"/)[1] $gem_name = file($gemspecs[0]).split("${gemspec_var}.name ")[1].split(/ *= *['"]/)[1].split(/['"]/)[0] - $target.add_facts( {'gem_name' => $gem_name }) - unless $target.facts.dig('project_type'){ $target.add_facts({'project_type' => 'rubygem'}) } - $target.add_facts( {'project_attributes' => ($target.facts['project_attributes'] << 'rubygem')} ) + $target.add_facts({ 'gem_name' => $gem_name }) + unless $target.facts.dig('project_type') { $target.add_facts({ 'project_type' => 'rubygem' }) } + $target.add_facts({ 'project_attributes' => ($target.facts['project_attributes'] << 'rubygem') }) } # simp_unknown (no type yet, but either: @@ -85,12 +85,12 @@ function puppetsync::setup_repos_facts( # ) # ------------------------------------------------------------------------ if ($target.facts['project_type'].empty and ( - $target.vars['mod_data']['repo_name'] == 'pkg-r10k' or - $target.vars['mod_data']['repo_name'].match(/^simp-/) or - $target.vars['repo_url_path'].match(/^simp\//) - )){ - unless $target.facts.dig('project_type'){ - $target.add_facts({'project_type' => 'simp_unknown'}) + $target.vars['mod_data']['repo_name'] == 'pkg-r10k' or + $target.vars['mod_data']['repo_name'].match(/^simp-/) or + $target.vars['repo_url_path'].match(/^simp\//) + )) { + unless $target.facts.dig('project_type') { + $target.add_facts({ 'project_type' => 'simp_unknown' }) } } @@ -98,7 +98,7 @@ function puppetsync::setup_repos_facts( # ------------------------------------------------------------------------ if $target.facts['project_type'].empty { warning( "WARNING: ${target.name} project_type remains 'unknown'" ) - $target.add_facts({'project_type' => 'unknown'}) + $target.add_facts({ 'project_type' => 'unknown' }) } } $repos diff --git a/dist/puppetsync/functions/summarize_repo_targets.pp b/dist/puppetsync/functions/summarize_repo_targets.pp index 7097d32..68f19b9 100644 --- a/dist/puppetsync/functions/summarize_repo_targets.pp +++ b/dist/puppetsync/functions/summarize_repo_targets.pp @@ -3,7 +3,7 @@ function puppetsync::summarize_repo_targets( TargetSpec $repos, Boolean $verbose = false, -){ +) >> String { warning( "=@@@@@ repos.type = '${repos.type}'" ) $t_summ = $repos.map |$idx, $target| { $t_idx = " [${idx}]: ${target.name}" @@ -15,6 +15,5 @@ function puppetsync::summarize_repo_targets( } }.join("\n") - "Targets: ${repos.size}:\n${t_summ}" } diff --git a/dist/puppetsync/functions/summarize_repos_pipeline_results.pp b/dist/puppetsync/functions/summarize_repos_pipeline_results.pp index 0763f18..a303b1f 100644 --- a/dist/puppetsync/functions/summarize_repos_pipeline_results.pp +++ b/dist/puppetsync/functions/summarize_repos_pipeline_results.pp @@ -3,22 +3,26 @@ function puppetsync::summarize_repos_pipeline_results( TargetSpec $repos, Boolean $colorize = false, -) { - format::table({ - title => 'Results', - head => [ 'Repo', 'Result', 'Final Stage' ], - rows => $repos.map |$repo| { - $all_ok = $repo.vars['puppetsync_stage_results'].all |$k,$v| { $v['ok'] } - $stage = $repo.vars['puppetsync_stage_results'].keys[-1].lest || { $repo.vars['puppetsync_stage_results'].count } - if $colorize { - [ - $all_ok ? { true => $repo.name, default => format::colorize( $repo.name, 'warning' ) }, - $all_ok ? { true => format::colorize('ok', 'good'), default => format::colorize('failed','fatal') }, - $all_ok ? { true => $stage, default => format::colorize($stage, 'warning') }, - ] - } else { - [ $repo.name, $all_ok ? { true => 'ok', default => 'failed' }, $stage ] - } +) >> String { + format::table( + { + title => 'Results', + head => ['Repo', 'Result', 'Final Stage'], + rows => $repos.map |$repo| { + $all_ok = $repo.vars['puppetsync_stage_results'].all |$k,$v| { $v['ok'] } + $stage = $repo.vars['puppetsync_stage_results'].keys[-1].lest || { $repo.vars['puppetsync_stage_results'].count } + if $colorize { + [ + # lint:ignore:unquoted_string_in_selector + $all_ok ? { true => $repo.name, default => format::colorize( $repo.name, 'warning' ) }, + # lint:endignore + $all_ok ? { true => format::colorize('ok', 'good'), default => format::colorize('failed','fatal') }, + $all_ok ? { true => $stage, default => format::colorize($stage, 'warning') }, + ] + } else { + [$repo.name, $all_ok ? { true => 'ok', default => 'failed' }, $stage] + } + }, } - }) + ) } diff --git a/dist/puppetsync/functions/template_git_commit_message.pp b/dist/puppetsync/functions/template_git_commit_message.pp index 0ede6c6..b4c2ed8 100644 --- a/dist/puppetsync/functions/template_git_commit_message.pp +++ b/dist/puppetsync/functions/template_git_commit_message.pp @@ -5,7 +5,7 @@ function puppetsync::template_git_commit_message( Target $repo, Hash $puppetsync_config, -){ +) >> String { $commmit_template = $puppetsync_config.dig('git','commit_message').lest || { fail("ERROR: ${repo.name} missing required var ['git']['commit_message']") } diff --git a/dist/puppetsync/lib/puppet/functions/puppetsync/pipeline_stage.rb b/dist/puppetsync/lib/puppet/functions/puppetsync/pipeline_stage.rb index ca532d3..0f725d3 100644 --- a/dist/puppetsync/lib/puppet/functions/puppetsync/pipeline_stage.rb +++ b/dist/puppetsync/lib/puppet/functions/puppetsync/pipeline_stage.rb @@ -10,20 +10,20 @@ def pipeline_stage(targets, stage_name, opts = {}, &code) # Skip stage - if opts && opts.key?('stages') && !(opts['stages'] || []).include?(stage_name) + if opts&.key?('stages') && !opts['stages']&.include?(stage_name) Puppet.warning("!!! skipping stage '#{stage_name}'") call_function('out::message', "===== SKIPPING PIPELINE STAGE DUE TO CONFIGURATION: #{stage_name}") return [] end - if opts && opts.key?('list_pipeline_stages') && (opts['list_pipeline_stages'] || false) + if opts&.key?('list_pipeline_stages') && opts['list_pipeline_stages'] call_function('out::message', "- #{stage_name}") return [] end # Only run targets that have succeeded in all stages so far Puppet.warning("== Preparing stage '#{stage_name}'") - ok_targets = targets.select { |repo| repo.vars['puppetsync_stage_results'].all? { |k,v| v['ok']}} + ok_targets = targets.select { |repo| repo.vars['puppetsync_stage_results'].all? { |_k, v| v['ok'] } } # Run stage block Puppet.warning('filtered ok stages before running') @@ -40,16 +40,16 @@ def pipeline_stage(targets, stage_name, opts = {}, &code) else STDERR.puts '############ WARNING: results are NOT a Bolt::Result' Puppet.warning "############ WARNING: results are NOT a Bolt::Result (file:#{__FILE__}, stage: #{stage_name}, class: #{results.class}" - if results.kind_of? Array + if results.is_a? Array Puppet.warning "############ WARNING: ARRAY.size: #{results.size}" Puppet.warning "############ WARNING: ARRAY.first class: #{results.first.class}" end - begin - require 'pry'; binding.pry + require 'pry' + binding.pry # rubocop:disable Lint/Debugger rescue LoadError => e - puts "==============================================================", e.message + puts '==============================================================', e.message end end ok_targets diff --git a/dist/puppetsync/plans/approve_github_prs.pp b/dist/puppetsync/plans/approve_github_prs.pp index 66daf19..ae5323b 100644 --- a/dist/puppetsync/plans/approve_github_prs.pp +++ b/dist/puppetsync/plans/approve_github_prs.pp @@ -36,7 +36,7 @@ # @author Chris Tessmer # # ------------------------------------------------------------------------------ -plan puppetsync::approve_github_prs( +plan puppetsync::approve_github_prs ( TargetSpec $targets = get_targets('default'), Stdlib::Absolutepath $project_dir = system::env('PWD'), String[1] $batchlist = '---', @@ -54,7 +54,7 @@ 'clone_git_repos' => false, # Don't need to clone repos just to approve PRs 'filter_permitted_repos' => false, # Assume all matching PRs are permitted repo types 'github_api_delay_seconds' => 1, - } + getvar('puppetsync_config.puppetsync.plans.approve_github_prs').lest || {{}} + $options + } + getvar('puppetsync_config.puppetsync.plans.approve_github_prs').lest || {{} } + $options $repos = puppetsync::setup_project_repos( $puppetsync_config, diff --git a/dist/puppetsync/plans/init.pp b/dist/puppetsync/plans/init.pp index 0e0eae5..b80320b 100644 --- a/dist/puppetsync/plans/init.pp +++ b/dist/puppetsync/plans/init.pp @@ -92,7 +92,7 @@ # @author Chris Tessmer # # ------------------------------------------------------------------------------ -plan puppetsync( +plan puppetsync ( TargetSpec $targets = get_targets('default'), Stdlib::Absolutepath $project_dir = system::env('PWD'), String[1] $batchlist = '---', @@ -106,11 +106,10 @@ Sensitive[String[1]] $gitlab_token = Sensitive(system::env('GITLAB_API_TOKEN')), Hash $options = {}, ) { - $opts = { 'clone_git_repos' => true, 'github_api_delay_seconds' => 5, - } + getvar('puppetsync_config.puppetsync.plans.sync').lest || {{}} + $options + } + getvar('puppetsync_config.puppetsync.plans.sync').lest || {{} } + $options $repos = puppetsync::setup_project_repos( $puppetsync_config, $repos_config, $project_dir, $opts ) $feature_branch = getvar('puppetsync_config.git.feature_branch') @@ -179,7 +178,6 @@ ) } - $repos.puppetsync::pipeline_stage( # -------------------------------------------------------------------------- 'apply_puppet_role', @@ -190,7 +188,7 @@ '_description' => "Apply Puppet role ${puppet_role}", '_noop' => false, _catch_errors => true, - ){ + ) { if $puppet_role { include $puppet_role } else { @@ -218,7 +216,7 @@ } Hash.new({ - 'file' => $file_path, + 'file' => $file_path, }) } } @@ -239,7 +237,7 @@ } Hash.new({ - 'file' => "${dir_path}/.gitlab-ci.yml", + 'file' => "${dir_path}/.gitlab-ci.yml", }) } } @@ -260,7 +258,7 @@ } Hash.new({ - 'file' => "${dir_path}/.gitlab-ci.yml", + 'file' => "${dir_path}/.gitlab-ci.yml", }) } } @@ -281,7 +279,7 @@ } Hash.new({ - 'file' => "${dir_path}/.gitlab-ci.yml", + 'file' => "${dir_path}/.gitlab-ci.yml", }) } } @@ -318,7 +316,7 @@ default => "${repo.vars['repo_path']}/.fixtures.yml", } Hash.new({ - 'filename' => $file_path, + 'filename' => $file_path, }) } } @@ -334,7 +332,7 @@ '_catch_errors' => true, ) |$repo| { Hash.new({ - 'path' => "${repo.vars['repo_path']}" + 'path' => "${repo.vars['repo_path']}", }) } } @@ -354,7 +352,7 @@ default => "${repo.vars['repo_path']}/metadata.json", } Hash.new({ - 'filename' => $file_path, + 'filename' => $file_path, }) } } @@ -370,11 +368,26 @@ '_catch_errors' => true, ) |$repo| { Hash.new({ - 'path' => "${repo.vars['repo_path']}" + 'path' => "${repo.vars['repo_path']}", }) } } + $repos.puppetsync::pipeline_stage( + # -------------------------------------------------------------------------- + 'run_gha_tests', + # -------------------------------------------------------------------------- + $opts + ) |$ok_repos, $stage_name| { + run_task_with('puppetsync::run_gha_tests', + $ok_repos, + '_catch_errors' => true, + ) |$repo| { + Hash.new({ + 'path' => "${repo.vars['repo_path']}", + }) + } + } $repos.puppetsync::pipeline_stage( # -------------------------------------------------------------------------- @@ -382,7 +395,7 @@ # -------------------------------------------------------------------------- $opts ) |$ok_repos, $stage_name| { - $commit_message = $puppetsync_config.dig('git','commit_message').lest || {''} + $commit_message = $puppetsync_config.dig('git','commit_message').lest || { '' } run_task_with( 'puppetsync::generate_reference_md', $ok_repos, @@ -401,7 +414,7 @@ # -------------------------------------------------------------------------- $opts ) |$ok_repos, $stage_name| { - $commit_message = $puppetsync_config.dig('git','commit_message').lest || {''} + $commit_message = $puppetsync_config.dig('git','commit_message').lest || { '' } run_task_with( 'puppetsync::git_commit', $ok_repos, @@ -414,7 +427,6 @@ } } - $repos.puppetsync::pipeline_stage( # -------------------------------------------------------------------------- 'ensure_github_fork', @@ -424,10 +436,10 @@ $results = run_task_with( 'puppetsync::ensure_github_fork', $ok_repos, '_catch_errors' => true ) |$repo| {{ - 'extra_gem_path' => $extra_gem_path, - 'github_repo' => $repo.vars['repo_url_path'], - 'github_authtoken' => $github_token.unwrap, - }} + 'extra_gem_path' => $extra_gem_path, + 'github_repo' => $repo.vars['repo_url_path'], + 'github_authtoken' => $github_token.unwrap, + } } $ok_repos.each |$repo| { if $results.ok { @@ -447,7 +459,7 @@ # -------------------------------------------------------------------------- $opts ) |$ok_repos, $stage_name| { - $ok_repos.each |$repo| {$repo.set_var('remote_name', 'user_forked_repo')} + $ok_repos.each |$repo| { $repo.set_var('remote_name', 'user_forked_repo') } $results = run_task_with( 'puppetsync::ensure_git_remote', $ok_repos, '_catch_errors' => true ) |$repo| { @@ -460,13 +472,13 @@ $results.each |$r| { if !$r.ok { - out::message( @("END") + $msg = @("END") Running puppetsync::ensure_git_remote failed on ${r.target.name}: ${r.error.msg} ${r.error.details} - END - ) + | END + out::message($msg) } } } @@ -489,7 +501,6 @@ } } - $repos.puppetsync::pipeline_stage( # -------------------------------------------------------------------------- 'ensure_gitlab_remote', @@ -501,7 +512,7 @@ ) |$repo| { { 'repo_path' => $repo.vars['repo_path'], - 'remote_url' => $repo.vars['user_repo_fork']['ssh_url'].regsubst($puppetsync_config['github']['pr_user'],'simp').regsubst('github','gitlab'), + 'remote_url' => $repo.vars['user_repo_fork']['ssh_url'].regsubst($puppetsync_config['github']['pr_user'], 'simp').regsubst('github','gitlab'), # lint:ignore:140chars 'remote_name' => 'gitlab_repo', } } @@ -523,7 +534,6 @@ } } - # TODO if any repos were forked, wait 5 minutes for GitHub to catch up $repos.puppetsync::pipeline_stage( @@ -554,8 +564,8 @@ out::message( "-- GitHub user's PR: '${results.first.value['pr_url']}'${created_status}") } else { out::message( - [ "Running puppetsync::ensure_github_pr failed on ${repo.name}:", - $results.first.error.msg,'','', $results.first.error.details,'', ].join("\n") + ["Running puppetsync::ensure_github_pr failed on ${repo.name}:", + $results.first.error.msg,'','', $results.first.error.details,'',].join("\n") ) } ctrl::sleep($opts['github_api_delay_seconds']) @@ -569,7 +579,7 @@ # -------------------------------------------------------------------------- $opts ) |$ok_repos, $stage_name| { - $commit_message = $puppetsync_config.dig('git','commit_message').lest || {''} + $commit_message = $puppetsync_config.dig('git','commit_message').lest || { '' } run_task_with( 'puppetsync::release_pupmod', $ok_repos, diff --git a/dist/puppetsync/plans/merge_github_prs.pp b/dist/puppetsync/plans/merge_github_prs.pp index ac2e542..eb7937c 100644 --- a/dist/puppetsync/plans/merge_github_prs.pp +++ b/dist/puppetsync/plans/merge_github_prs.pp @@ -24,7 +24,7 @@ # @author Chris Tessmer # # ------------------------------------------------------------------------------ -plan puppetsync::merge_github_prs( +plan puppetsync::merge_github_prs ( TargetSpec $targets = get_targets('default'), Stdlib::Absolutepath $project_dir = system::env('PWD'), String[1] $batchlist = '---', @@ -41,7 +41,7 @@ 'clone_git_repos' => false, # Don't need to clone repos just to approve PRs 'filter_permitted_repos' => false, # Assume all matching PRs are permitted repo types 'github_api_delay_seconds' => 1, - } + getvar('puppetsync_config.puppetsync.plans.merge_github_prs').lest || {{}} + $options + } + getvar('puppetsync_config.puppetsync.plans.merge_github_prs').lest || {{} } + $options $repos = puppetsync::setup_project_repos( $puppetsync_config, diff --git a/dist/puppetsync/plans/release_pupmod.pp b/dist/puppetsync/plans/release_pupmod.pp index 2a5f072..28ebcde 100644 --- a/dist/puppetsync/plans/release_pupmod.pp +++ b/dist/puppetsync/plans/release_pupmod.pp @@ -51,7 +51,7 @@ 'clone_git_repos' => true, # Need to clone repos in order to tag and push 'filter_permitted_repos' => true, # Assume all matching PRs are permitted repo types 'github_api_delay_seconds' => 1, - } + getvar('puppetsync_config.puppetsync.plans.release_pupmod').lest || {{}} + $options + } + getvar('puppetsync_config.puppetsync.plans.release_pupmod').lest || { {} } + $options # lint:ignore:manifest_whitespace_opening_brace_before lint:ignore:140chars $repos = puppetsync::setup_project_repos( $puppetsync_config, @@ -72,7 +72,6 @@ $opts ) |$ok_repos, $stage_name| { $ok_repos.map |$repo| { - $metadata_json_path = $repo.facts['project_type'] ? { 'pupmod' => "${repo.vars['repo_path']}/metadata.json", default => fail("ERROR: This plan can only release pupmods - ${repo.vars['repo_name']} is type '${repo.facts['project_type']}'"), diff --git a/dist/puppetsync/spec/functions/parse_puppetfile_spec.rb b/dist/puppetsync/spec/functions/parse_puppetfile_spec.rb index fbd2df7..4c49823 100644 --- a/dist/puppetsync/spec/functions/parse_puppetfile_spec.rb +++ b/dist/puppetsync/spec/functions/parse_puppetfile_spec.rb @@ -20,7 +20,37 @@ end let(:pf_modules_hash) do - {"modules/stdlib"=>{"git"=>"https://github.com/puppetlabs/puppetlabs-stdlib.git", "tag"=>"v6.2.0", "name"=>"stdlib", "rel_path"=>"modules/stdlib", "mod_rel_path"=>"modules/stdlib", "mod_name"=>"stdlib", "install_path"=>"modules", "repo_name"=>"puppetlabs-stdlib"}, "modules/simplib"=>{"git"=>"git@github.com:simp/pupmod-simp-simplib.git", "tag"=>"4.2.0", "name"=>"simplib", "rel_path"=>"modules/simplib", "mod_rel_path"=>"modules/simplib", "mod_name"=>"simplib", "install_path"=>"modules", "repo_name"=>"pupmod-simp-simplib"}, "_repos/simp-acpid"=>{"git"=>"https://github.com/simp/pupmod-simp-acpid", "name"=>"simp-acpid", "rel_path"=>"_repos/simp-acpid", "mod_rel_path"=>"_repos/acpid", "mod_name"=>"acpid", "install_path"=>"_repos", "repo_name"=>"pupmod-simp-acpid"}} + { + 'modules/stdlib' => { + 'git' => 'https://github.com/puppetlabs/puppetlabs-stdlib.git', + 'tag' => 'v6.2.0', + 'name' => 'stdlib', + 'rel_path' => 'modules/stdlib', + 'mod_rel_path' => 'modules/stdlib', + 'mod_name' => 'stdlib', + 'install_path' => 'modules', + 'repo_name' => 'puppetlabs-stdlib', + }, + 'modules/simplib' => { + 'git' => 'git@github.com:simp/pupmod-simp-simplib.git', + 'tag' => '4.2.0', + 'name' => 'simplib', + 'rel_path' => 'modules/simplib', + 'mod_rel_path' => 'modules/simplib', + 'mod_name' => 'simplib', + 'install_path' => 'modules', + 'repo_name' => 'pupmod-simp-simplib', + }, + '_repos/simp-acpid' => { + 'git' => 'https://github.com/simp/pupmod-simp-acpid', + 'name' => 'simp-acpid', + 'rel_path' => '_repos/simp-acpid', + 'mod_rel_path' => '_repos/acpid', + 'mod_name' => 'acpid', + 'install_path' => '_repos', + 'repo_name' => 'pupmod-simp-acpid', + }, + } end context 'when a simple array is passed' do diff --git a/dist/puppetsync/spec/spec_helper.rb b/dist/puppetsync/spec/spec_helper.rb index 6cd5e8d..2a6674c 100644 --- a/dist/puppetsync/spec/spec_helper.rb +++ b/dist/puppetsync/spec/spec_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + RSpec.configure do |c| c.mock_with :rspec end diff --git a/dist/puppetsync/tasks/approve_github_pr.rb b/dist/puppetsync/tasks/approve_github_pr.rb old mode 100644 new mode 100755 index dad5cf0..7f9492b --- a/dist/puppetsync/tasks/approve_github_pr.rb +++ b/dist/puppetsync/tasks/approve_github_pr.rb @@ -10,8 +10,9 @@ # require_relative '../../ruby_task_helper/files/task_helper.rb' +# Bolt task class class MyTask < TaskHelper - def task(name: nil, **kwargs) + def task(name: nil, **kwargs) # rubocop:disable Lint/UnusedMethodArgument Dir["#{kwargs[:extra_gem_path]}/gems/*/lib"].each { |path| $LOAD_PATH << path } # for octokit require_relative '../../puppetsync/files/github_pr_forker.rb' diff --git a/dist/puppetsync/tasks/checkout_git_feature_branch_in_each_repo.rb b/dist/puppetsync/tasks/checkout_git_feature_branch_in_each_repo.rb index 9c11bb7..46cda1f 100644 --- a/dist/puppetsync/tasks/checkout_git_feature_branch_in_each_repo.rb +++ b/dist/puppetsync/tasks/checkout_git_feature_branch_in_each_repo.rb @@ -13,12 +13,11 @@ def checkout_modules_to_branch(branch, repo_paths) status = 'checked_out' warn "NOTICE: branch '#{branch}' already exists; checking it out" pid = spawn 'git', 'checkout', branch, '-q' - Process.wait pid else warn "NOTICE: creating branch '#{branch}'" pid = spawn 'git', 'checkout', '-b', branch, '-q' - Process.wait pid end + Process.wait pid if $CHILD_STATUS.success? warn "== #{File.basename(dir).ljust(mx)} : checked out git branch '#{branch}' in #{dir}" results[dir] = status diff --git a/dist/puppetsync/tasks/comment_puppet8_spec_tests.rb b/dist/puppetsync/tasks/comment_puppet8_spec_tests.rb index 93774ac..f5b40f4 100755 --- a/dist/puppetsync/tasks/comment_puppet8_spec_tests.rb +++ b/dist/puppetsync/tasks/comment_puppet8_spec_tests.rb @@ -4,7 +4,6 @@ # ARGF hack to allow use run the task directly as a ruby script while testing if ARGF.filename == '-' - stdin = '' warn "ARGF.file.lineno: '#{ARGF.file.lineno}'" stdin = ARGF.file.read warn "== stdin: '#{stdin}'" @@ -14,35 +13,35 @@ file = ARGF.filename end -#Returns the spot in the file that is no longer managed by puppet +# Returns the spot in the file that is no longer managed by puppet def get_index(input_file, str) content = File.read(input_file) start_idx = nil - content.lines.each_with_index do | line,idx | - if line =~ /#{str}/ + content.lines.each_with_index do |line, idx| + if %r{#{str}}.match?(line) start_idx = idx return start_idx end end - warn("No index match") + warn('No index match') start_idx = 0 end warn "file: '#{file}'" -start_index = get_index(file, "^# Repo-specific content") -ci_file = File.readlines("#{file}") +start_index = get_index(file, '^# Repo-specific content') # rubocop:disable Lint/UselessAssignment +ci_file = File.readlines(file.to_s) -#Comments out oel sections +# Comments out oel sections comment = false -ci_file.each_with_index do | line,idx | - if line =~ /(^pup8.*)/ +ci_file.each_with_index do |line, _idx| + if %r{(^pup8.*)}.match?(line) comment = true end - if line =~ /(^\n)/ + if %r{(^\n)}.match?(line) comment = false end if comment == true line.prepend('#') end end -File.open(file, "w") { |out| out.puts ci_file } +File.open(file, 'w') { |out| out.puts ci_file } diff --git a/dist/puppetsync/tasks/ensure_git_remote.rb b/dist/puppetsync/tasks/ensure_git_remote.rb old mode 100644 new mode 100755 index a33c4c9..846f25a --- a/dist/puppetsync/tasks/ensure_git_remote.rb +++ b/dist/puppetsync/tasks/ensure_git_remote.rb @@ -10,8 +10,9 @@ require_relative '../../ruby_task_helper/files/task_helper.rb' require_relative '../../puppetsync/files/git_repo_remote_tasks.rb' +# Bolt task class class MyTask < TaskHelper - def task(name: nil, **kwargs) + def task(name: nil, **kwargs) # rubocop:disable Lint/UnusedMethodArgument helper = GitRepoRemoteTasks.new(kwargs[:repo_path], kwargs[:remote_url], kwargs[:remote_name]) helper.ensure_remote_exists { diff --git a/dist/puppetsync/tasks/ensure_github_fork.rb b/dist/puppetsync/tasks/ensure_github_fork.rb old mode 100644 new mode 100755 index 9677697..ab1d523 --- a/dist/puppetsync/tasks/ensure_github_fork.rb +++ b/dist/puppetsync/tasks/ensure_github_fork.rb @@ -10,8 +10,9 @@ # require_relative '../../ruby_task_helper/files/task_helper.rb' +# Bolt task class class MyTask < TaskHelper - def task(name: nil, **kwargs) + def task(name: nil, **kwargs) # rubocop:disable Lint/UnusedMethodArgument # Ensure that extra gem paths are loaded (to find octokit) Dir["#{kwargs[:extra_gem_path]}/gems/*/lib"].each { |path| $LOAD_PATH << path } require_relative '../../puppetsync/files/github_pr_forker.rb' diff --git a/dist/puppetsync/tasks/ensure_github_pr.rb b/dist/puppetsync/tasks/ensure_github_pr.rb old mode 100644 new mode 100755 index ae54050..d681be5 --- a/dist/puppetsync/tasks/ensure_github_pr.rb +++ b/dist/puppetsync/tasks/ensure_github_pr.rb @@ -10,8 +10,9 @@ # require_relative '../../ruby_task_helper/files/task_helper.rb' +# Bolt task class class MyTask < TaskHelper - def task(name: nil, **kwargs) + def task(name: nil, **kwargs) # rubocop:disable Lint/UnusedMethodArgument # Ensure that extra gem paths are loaded (to find octokit) Dir["#{kwargs[:extra_gem_path]}/gems/*/lib"].each { |path| $LOAD_PATH << path } require_relative '../../puppetsync/files/github_pr_forker.rb' diff --git a/dist/puppetsync/tasks/ensure_jira_subtask.rb b/dist/puppetsync/tasks/ensure_jira_subtask.rb old mode 100644 new mode 100755 index 92a07bd..52e3d8d --- a/dist/puppetsync/tasks/ensure_jira_subtask.rb +++ b/dist/puppetsync/tasks/ensure_jira_subtask.rb @@ -3,8 +3,9 @@ require_relative '../../puppetsync/files/ensure_jira_subtask.rb' require_relative '../../ruby_task_helper/files/task_helper.rb' +# Bolt task class class MyTask < TaskHelper - def task(name: nil, **kwargs) + def task(name: nil, **kwargs) # rubocop:disable Lint/UnusedMethodArgument # Ensure that extra gem paths are loaded (to find jira-ruby) Dir["#{kwargs[:extra_gem_path]}/gems/*/lib"].each { |path| $LOAD_PATH << path } api = JiraHelper.new( diff --git a/dist/puppetsync/tasks/generate_reference_md.rb b/dist/puppetsync/tasks/generate_reference_md.rb index 875c876..1adbfaa 100755 --- a/dist/puppetsync/tasks/generate_reference_md.rb +++ b/dist/puppetsync/tasks/generate_reference_md.rb @@ -6,24 +6,24 @@ require 'tempfile' require 'tmpdir' -BUNDLER_EXE=ENV['BUNDLER_EXE'] || "/opt/puppetlabs/bolt/bin/bundle" -RAKE_EXE=ENV['RAKE_EXE'] || "/opt/puppetlabs/bolt/bin/rake" -BUNDLE_PATH=ENV['BUNDLE_PATH']||'../../.vendor/bundle' +BUNDLER_EXE = ENV['BUNDLER_EXE'] || '/opt/puppetlabs/bolt/bin/bundle' +RAKE_EXE = ENV['RAKE_EXE'] || '/opt/puppetlabs/bolt/bin/rake' +BUNDLE_PATH = ENV['BUNDLE_PATH'] || '../../.vendor/bundle' def tmp_bundle_rake_execs(repo_path, tasks, save_rake_stdout: false) Dir.mktmpdir('tmp_bundle_rake_execs') do |tmp_dir| Dir.chdir repo_path gemfile_lock = false if File.exist?('Gemfile.lock') - gemfile_lock = File.expand_path('Gemfile.lock',tmp_dir) + gemfile_lock = File.expand_path('Gemfile.lock', tmp_dir) FileUtils.cp File.join(repo_path, 'Gemfile.lock'), gemfile_lock end results = [] - rake_stdout_files={} + rake_stdout_files = {} require 'bundler' require 'rake' Bundler.with_unbundled_env do - #sh "#{BUNDLER_EXE} config path .vendor/bundle &> /dev/null" + # sh "#{BUNDLER_EXE} config path .vendor/bundle &> /dev/null" sh "#{BUNDLER_EXE} install --path '#{BUNDLE_PATH}' &> /dev/null" tasks.each do |task| puts @@ -41,18 +41,16 @@ def tmp_bundle_rake_execs(repo_path, tasks, save_rake_stdout: false) FileUtils.rm('Gemfile.lock') end end - unless results.all?{ |x| x } + unless results.all? { |x| x } warn 'bad result' end return rake_stdout_files if save_rake_stdout end end - # ARGF hack to allow use run the task directly as a ruby script while testing metadata_json_path = false if ARGF.filename == '-' - stdin = '' warn "ARGF.file.lineno: '#{ARGF.file.lineno}'" stdin = ARGF.file.read warn "== stdin: '#{stdin}'" @@ -69,14 +67,14 @@ def tmp_bundle_rake_execs(repo_path, tasks, save_rake_stdout: false) repo_path = File.dirname metadata_json_path unless ENV['UPDATE_NON_SIMP_MODULES'] == 'yes' - if pupmod_metadata['name'] !~ %r{\Asimp[-/]} + if !%r{\Asimp[-/]}.match?(pupmod_metadata['name']) warn("\n\n\n== WARNING: SKIPPING update of non-simp module (#{content['name']}) (force with `UPDATE_NON_SIMP_MODULES=yes`)\n\n\n") else - task_output_files = tmp_bundle_rake_execs(repo_path, ['strings:generate:reference']) + tmp_bundle_rake_execs(repo_path, ['strings:generate:reference']) - Dir.chdir(repo_path) do |dir| - fail "ERROR: no file at REFERENCE.md" unless File.exist?('REFERENCE.md') - sh "git add REFERENCE.md" + Dir.chdir(repo_path) do |_dir| + raise 'ERROR: no file at REFERENCE.md' unless File.exist?('REFERENCE.md') + sh 'git add REFERENCE.md' sh ">&2 git commit -m 'Update REFERENCE.md' || :" end exit 0 diff --git a/dist/puppetsync/tasks/git_commit.rb b/dist/puppetsync/tasks/git_commit.rb old mode 100644 new mode 100755 index cf90363..ab4c8b8 --- a/dist/puppetsync/tasks/git_commit.rb +++ b/dist/puppetsync/tasks/git_commit.rb @@ -19,12 +19,11 @@ def git_commit(repo_path, commit_message) if current_commit == commit_message warn "NOTICE: Running 'git commit -F #{commit_msg_file.path} --amend' in #{repo_path}" pid = spawn 'git', 'commit', '-F', commit_msg_file.path, '--amend' - Process.wait pid else warn "NOTICE: Running 'git commit -F #{commit_msg_file.path}' in #{repo_path}" pid = spawn 'git', 'commit', '-F', commit_msg_file.path - Process.wait pid end + Process.wait pid if $CHILD_STATUS.success? puts "== #{File.basename(repo_path)} : committed changes in #{repo_path}" end diff --git a/dist/puppetsync/tasks/lint_gitlab_ci.rb b/dist/puppetsync/tasks/lint_gitlab_ci.rb old mode 100644 new mode 100755 index 32a6a46..598968b --- a/dist/puppetsync/tasks/lint_gitlab_ci.rb +++ b/dist/puppetsync/tasks/lint_gitlab_ci.rb @@ -7,30 +7,29 @@ require 'yaml' require 'faraday' - def lint_request(gitlab_ci_url, gitlab_token, body) response = Faraday.post(gitlab_ci_url) do |req| req.params['limit'] = 100 req.headers['Content-Type'] = 'application/json' req.headers['PRIVATE-TOKEN'] = gitlab_token - #req.headers['Authorization'] = "Bearer #{gitlab_token}" + # req.headers['Authorization'] = "Bearer #{gitlab_token}" req.body = body end + response end def err_msg_about_response(response, gitlab_ci_url, gitlab_ci_yml_path) unless response.success? return "ERROR: Could not use CI linter at #{gitlab_ci_url} (#{response.status} #{response.reason_phrase}):\n#{JSON.parse(response.body).to_yaml}\n\n" end - #if JSON.parse(response.body).fetch('status', '') != 'valid' - if JSON.parse(response.body).fetch('valid', false) != true - msg = "ERROR: #{File.basename(gitlab_ci_yml_path)} is not valid!\n\n" - data = JSON.parse response.body - data['errors'].each { |error| msg += " * #{error}" } - msg += "\n\n" - msg += "Path: '#{gitlab_ci_yml_path}'\n" - return(msg) - end + # if JSON.parse(response.body).fetch('status', '') != 'valid' + return unless JSON.parse(response.body).fetch('valid', false) != true + msg = "ERROR: #{File.basename(gitlab_ci_yml_path)} is not valid!\n\n" + data = JSON.parse response.body + data['errors'].each { |error| msg += " * #{error}" } + msg += "\n\n" + msg += "Path: '#{gitlab_ci_yml_path}'\n" + msg end def gitlab_ci_lint(gitlab_ci_url, gitlab_ci_yml_path, gitlab_token) @@ -44,12 +43,11 @@ def gitlab_ci_lint(gitlab_ci_url, gitlab_ci_yml_path, gitlab_token) body = JSON.dump('content' => content.to_json) response = lint_request(gitlab_ci_url, gitlab_token, body) msg = err_msg_about_response(response, gitlab_ci_url, gitlab_ci_yml_path) - msg ? abort(msg) : puts( "#{File.basename(gitlab_ci_yml_path)} is valid\n\n") + msg ? abort(msg) : puts("#{File.basename(gitlab_ci_yml_path)} is valid\n\n") end # ARGF hack to allow use run the task directly as a ruby script while testing if ARGF.filename == '-' - stdin = '' warn "ARGF.file.lineno: '#{ARGF.file.lineno}'" stdin = ARGF.file.read require 'json' @@ -63,7 +61,7 @@ def gitlab_ci_lint(gitlab_ci_url, gitlab_ci_yml_path, gitlab_token) gitlab_token = params['gitlab_private_api_token'] || ENV['GITLAB_API_TOKEN'] files = (params['repo_paths'] || []).map { |x| File.join(x, '.gitlab-ci.yml') } || ARGV -warn "files", files +warn 'files', files raise('No repo_paths given') if params.to_h['repo_paths'].to_a.empty? files.each do |path| diff --git a/dist/puppetsync/tasks/merge_github_pr.rb b/dist/puppetsync/tasks/merge_github_pr.rb old mode 100644 new mode 100755 index 01100ee..683f1cf --- a/dist/puppetsync/tasks/merge_github_pr.rb +++ b/dist/puppetsync/tasks/merge_github_pr.rb @@ -10,8 +10,9 @@ # require_relative '../../ruby_task_helper/files/task_helper.rb' +# Bolt task class class MyTask < TaskHelper - def task(name: nil, **kwargs) + def task(name: nil, **kwargs) # rubocop:disable Lint/UnusedMethodArgument Dir["#{kwargs[:extra_gem_path]}/gems/*/lib"].each { |path| $LOAD_PATH << path } # for octokit require_relative '../../puppetsync/files/github_pr_forker.rb' diff --git a/dist/puppetsync/tasks/modernize_fixtures.rb b/dist/puppetsync/tasks/modernize_fixtures.rb index 14975e5..6f81a93 100755 --- a/dist/puppetsync/tasks/modernize_fixtures.rb +++ b/dist/puppetsync/tasks/modernize_fixtures.rb @@ -12,14 +12,14 @@ def tmp_bundle_rake_execs(repo_path, tasks) Dir.chdir repo_path gemfile_lock = false if File.exist?('Gemfile.lock') - gemfile_lock = File.expand_path('Gemfile.lock',tmp_dir) + gemfile_lock = File.expand_path('Gemfile.lock', tmp_dir) FileUtils.cp File.join(repo_path, 'Gemfile.lock'), gemfile_lock end results = [] require 'bundler' require 'rake' Bundler.with_unbundled_env do - sh "/opt/puppetlabs/bolt/bin/bundle install &> /dev/null" + sh '/opt/puppetlabs/bolt/bin/bundle install &> /dev/null' tasks.each do |task| puts cmd = "/opt/puppetlabs/bolt/bin/bundle exec /opt/puppetlabs/bolt/bin/rake #{task}" @@ -31,7 +31,7 @@ def tmp_bundle_rake_execs(repo_path, tasks) FileUtils.rm('Gemfile.lock') end end - unless results.all?{ |x| x } + unless results.all? { |x| x } warn 'bad result' end end @@ -39,7 +39,6 @@ def tmp_bundle_rake_execs(repo_path, tasks) # ARGF hack to allow use run the task directly as a ruby script while testing if ARGF.filename == '-' - stdin = '' warn "ARGF.file.lineno: '#{ARGF.file.lineno}'" stdin = ARGF.file.read warn "== stdin: '#{stdin}'" @@ -52,32 +51,32 @@ def tmp_bundle_rake_execs(repo_path, tasks) # Read content from file warn "file: '#{file}'" raise('No .fixtures path given') unless file -content = YAML.load File.read(file) +content = YAML.load_file(file) # Transform content warn "\n== Modernizing .fixtures content" original_content_str = content.to_s -#regexp_for_low_high_bounds = %r[\A(?>=?) (?\d+.*) (?<=?) (?\d+.*)\Z] +# regexp_for_low_high_bounds = %r[\A(?>=?) (?\d+.*) (?<=?) (?\d+.*)\Z] # -if content.to_s =~ /^ *#/ - fail "FATAL OMG there was a comment in '#{file}', it might be important and we don't preserve those yet; check it out" +if %r{^ *#}.match?(content.to_s) + raise "FATAL OMG there was a comment in '#{file}', it might be important and we don't preserve those yet; check it out" end -content_repos = content.dig('fixtures','repositories').map do |k,v| - unless (v.is_a?(String) || v.is_a?(Hash)) - fail "NO HANDLER: fixtures.yml 'repositories' key is not a String or Hash!:\n#{v.to_yaml}\n" - end - if v.is_a?(String) && v =~ /^http/ && v !~ /\.git$/ +content_repos = content.dig('fixtures', 'repositories').map { |k, v| + unless v.is_a?(String) || v.is_a?(Hash) + raise "NO HANDLER: fixtures.yml 'repositories' key is not a String or Hash!:\n#{v.to_yaml}\n" + end + if v.is_a?(String) && v =~ %r{^http} && v !~ %r{\.git$} v = "#{v}.git" - elsif v.is_a?(Hash) && v['repo'] && v['repo'] =~ /^http/ && v['repo'] !~ /\.git$/ + elsif v.is_a?(Hash) && v['repo'] && v['repo'] =~ %r{^http} && v['repo'] !~ %r{\.git$} v['repo'] = "#{v['repo']}.git" end - [k,v] -end.to_h + [k, v] +}.to_h -unless content_repos.nil? or content_repos.empty? +unless content_repos.nil? || content_repos.empty? content['fixtures']['repositories'] = content_repos end diff --git a/dist/puppetsync/tasks/modernize_gitlab_files.rb b/dist/puppetsync/tasks/modernize_gitlab_files.rb index 0029846..9fa0341 100755 --- a/dist/puppetsync/tasks/modernize_gitlab_files.rb +++ b/dist/puppetsync/tasks/modernize_gitlab_files.rb @@ -3,8 +3,8 @@ require 'fileutils' def modernize_gitlab_ci(content) - content.gsub!(%r[\n\n^pup5.*?(?=\n\n)]m,'') # Remove pup5 blocks (nice formatting) - content.gsub!(%r[^pup5.*?(?=\n\n)]m,'') # Remove pup5 blocks that beign with comments + content.gsub!(%r{\n\n^pup5.*?(?=\n\n)}m, '') # Remove pup5 blocks (nice formatting) + content.gsub!(%r{^pup5.*?(?=\n\n)}m, '') # Remove pup5 blocks that beign with comments content.gsub!(%r{pup6\.(?:16|17|18)\.0}, 'pup6.22.1') content.gsub!(%r{pup_6_(?:16|17|18)_0}, 'pup_6_22_1') @@ -21,13 +21,12 @@ def modernize_gitlab_ci(content) content.gsub!(%r{\bpup6\.22\.1}, 'pup6.pe') content.gsub!(%r{\bpup_6_22_1\b}, 'pup_6_pe') - content.gsub!(%r{bundle exec rake beaker:suites'},"bundle exec rake beaker:suites[default,default]'") + content.gsub!(%r{bundle exec rake beaker:suites'}, "bundle exec rake beaker:suites[default,default]'") content end # ARGF hack to allow use run the task directly as a ruby script while testing if ARGF.filename == '-' - stdin = '' warn "ARGF.file.lineno: '#{ARGF.file.lineno}'" stdin = ARGF.file.read require 'json' @@ -47,7 +46,7 @@ def modernize_gitlab_ci(content) warn "\n== Modernizing Gitlab CI content" original_content = content.dup content = modernize_gitlab_ci(original_content) -warn (content == original_content ? ' == content unchanged' : ' ++ content was changed!') +warn((content == original_content) ? ' == content unchanged' : ' ++ content was changed!') # Write content back to original file File.open(file, 'w') { |f| f.puts content.strip } diff --git a/dist/puppetsync/tasks/modernize_metadata_json.rb b/dist/puppetsync/tasks/modernize_metadata_json.rb index bd885b9..5b0f621 100755 --- a/dist/puppetsync/tasks/modernize_metadata_json.rb +++ b/dist/puppetsync/tasks/modernize_metadata_json.rb @@ -17,34 +17,36 @@ def bump_version(file) data = JSON.parse(content) # bump y version - parts = data['version'].split(/[\.-]/) + parts = data['version'].split(%r{[\.-]}) parts[1] = (parts[1].to_i + 1).to_s parts[2] = '0' new_version = parts.join('.') data['version'] = new_version - File.open(file,'w'){|f| f.puts(JSON.pretty_generate(data)) } + File.open(file, 'w') { |f| f.puts(JSON.pretty_generate(data)) } warn "\n\n++ processed '#{file}'" - if new_version - if file =~ /\.erb$/ - warn "SKIP VERSION BUMP: File is not .erb: #{file}" - return - end + return unless new_version + if %r{\.erb$}.match?(file) + warn "SKIP VERSION BUMP: File is not .erb: #{file}" + return + end - changelog_file = File.join(dir,'CHANGELOG') - unless File.exist? changelog_file - warn "SKIP VERSION BUMP: No CHANGELOG" - return - end + changelog_file = File.join(dir, 'CHANGELOG') + unless File.exist? changelog_file + warn 'SKIP VERSION BUMP: No CHANGELOG' + return + end - changelog = File.read(changelog_file) - require 'date' - new_lines = [] - new_lines << DateTime.now.strftime("* %a %b %d %Y Steven Pritchard - #{new_version}") - new_lines << '- [puppetsync] Update module dependencies to support simp-iptables 7.x' - changelog = new_lines.join("\n") + "\n\n" + changelog - File.open(changelog_file,'w'){|f| f.puts changelog; f.flush } + changelog = File.read(changelog_file) + require 'date' + new_lines = [] + new_lines << DateTime.now.strftime("* %a %b %d %Y Steven Pritchard - #{new_version}") + new_lines << '- [puppetsync] Update module dependencies to support simp-iptables 7.x' + changelog = new_lines.join("\n") + "\n\n" + changelog + File.open(changelog_file, 'w') do |f| + f.puts changelog + f.flush end end @@ -53,15 +55,15 @@ def tmp_bundle_rake_execs(repo_path, tasks) Dir.chdir repo_path gemfile_lock = false if File.exist?('Gemfile.lock') - gemfile_lock = File.expand_path('Gemfile.lock',tmp_dir) + gemfile_lock = File.expand_path('Gemfile.lock', tmp_dir) FileUtils.cp File.join(repo_path, 'Gemfile.lock'), gemfile_lock end results = [] require 'bundler' require 'rake' Bundler.with_unbundled_env do - #sh "/opt/puppetlabs/bolt/bin/bundle config path .vendor/bundle &> /dev/null" - sh "/opt/puppetlabs/bolt/bin/bundle install --path ../../.vendor/bundle &> /dev/null" + # sh "/opt/puppetlabs/bolt/bin/bundle config path .vendor/bundle &> /dev/null" + sh '/opt/puppetlabs/bolt/bin/bundle install --path ../../.vendor/bundle &> /dev/null' tasks.each do |task| puts cmd = "/opt/puppetlabs/bolt/bin/bundle exec /opt/puppetlabs/bolt/bin/rake #{task}" @@ -73,19 +75,19 @@ def tmp_bundle_rake_execs(repo_path, tasks) FileUtils.rm('Gemfile.lock') end end - unless results.all?{ |x| x } + unless results.all? { |x| x } warn 'bad result' end end end def transform_puppet_version_requirements(content) - #regexp_for_low_high_bounds = %r[\A(?>=?) (?\d+.*) (?<=?) (?\d+.*)\Z] - content['requirements'].select{|x| x['name'] == 'puppet' }.map do |x| - #x['version_requirement'].gsub!( regexp_for_low_high_bounds ) do |y| + # regexp_for_low_high_bounds = %r[\A(?>=?) (?\d+.*) (?<=?) (?\d+.*)\Z] + content['requirements'].select { |x| x['name'] == 'puppet' }.map do |x| + # x['version_requirement'].gsub!( regexp_for_low_high_bounds ) do |y| # m = Regexp.last_match # "#{m[:low_op} #{m[:low_ver]} >= 6.22.1 < 8.0.0" - #end + # end x['version_requirement'] = '>= 7.0.0 < 9.0.0' end end @@ -93,31 +95,31 @@ def transform_puppet_version_requirements(content) def transform_module_dependencies(content) dep_sections = [ content['dependencies'], - (content['simp']||{})['optional_dependencies'] - ].select{|x| x } + (content['simp'] || {})['optional_dependencies'], + ].select { |x| x } dep_sections.each do |dependencies| # puppet/systemd 4.0.2 addd Rocky Linux 8, 5.x drops puppet 6 support - dependencies.select{|x| x['name'].sub('-', '/') == 'puppet/systemd' || x['name'].sub('-', '/') == 'camptocamp/systemd' }.each do |x| + dependencies.select { |x| x['name'].sub('-', '/') == 'puppet/systemd' || x['name'].sub('-', '/') == 'camptocamp/systemd' }.each do |x| x['name'] = 'puppet/systemd' x['version_requirement'] = '>= 4.0.2 < 7.0.0' end # stdlib 8 adds Rocky 8, 8.4.0 (beware ensure_packages flip: https://github.com/puppetlabs/puppetlabs-stdlib/pull/1196) - dependencies.select{|x| x['name'] == 'puppetlabs/stdlib' }.each do |x| + dependencies.select { |x| x['name'] == 'puppetlabs/stdlib' }.each do |x| x['version_requirement'] = '>= 8.0.0 < 10.0.0' end # augeasproviders modules moved to Vox Pupuli - dependencies.select{|x| x['name'].split(%r{[-/]}).first == "herculesteam" }.each do |x| + dependencies.select { |x| x['name'].split(%r{[-/]}).first == 'herculesteam' }.each do |x| x['name'].sub!('herculesteam', 'puppet') end # nsswitch modules moved to puppet from trlinkin - dependencies.select{|x| x['name'].sub('-', '/') == 'trlinkin/nsswitch' }.each do |x| + dependencies.select { |x| x['name'].sub('-', '/') == 'trlinkin/nsswitch' }.each do |x| x['name'].sub!('trlinkin', 'puppet') end # Update dependency versions - dependencies.select{|x| x.key?('name') && x.key?('version_requirement') }.each do |x| - version_requirements = JSON.parse(File.read(File.join(__dir__, "..", "dist", "puppetsync", "data", "version_requirements.json"))) + dependencies.select { |x| x.key?('name') && x.key?('version_requirement') }.each do |x| + version_requirements = JSON.parse(File.read(File.join(__dir__, '..', 'dist', 'puppetsync', 'data', 'version_requirements.json'))) name = x['name'].sub('-', '/') next unless version_requirements.key?(name) @@ -148,14 +150,14 @@ def transform_operatingsystem_support(content) el = ['Rocky', 'AlmaLinux', 'CentOS', 'RedHat', 'OracleLinux'] # We only want to manipulate the supported OS list if it includes RHEL 8. - return unless content['operatingsystem_support'].any?{|x| x['operatingsystem'] == 'RedHat' && x['operatingsystemrelease']&.include?('8') } + return unless content['operatingsystem_support'].any? { |x| x['operatingsystem'] == 'RedHat' && x['operatingsystemrelease']&.include?('8') } el.each do |supported_os| ['8', '9'].each do |supported_version| - items = content['operatingsystem_support'].select{|x| x['operatingsystem'] == supported_os } + items = content['operatingsystem_support'].select { |x| x['operatingsystem'] == supported_os } content['operatingsystem_support'] << { 'operatingsystem' => supported_os } if items.empty? - content['operatingsystem_support'].select{|x| x['operatingsystem'] == supported_os }.map do |x| + content['operatingsystem_support'].select { |x| x['operatingsystem'] == supported_os }.map do |x| x['operatingsystemrelease'] ||= [] unless x['operatingsystemrelease'].include? supported_version x['operatingsystemrelease'] << supported_version @@ -167,7 +169,6 @@ def transform_operatingsystem_support(content) # ARGF hack to allow use run the task directly as a ruby script while testing if ARGF.filename == '-' - stdin = '' warn "ARGF.file.lineno: '#{ARGF.file.lineno}'" stdin = ARGF.file.read warn "== stdin: '#{stdin}'" @@ -183,7 +184,7 @@ def transform_operatingsystem_support(content) content = JSON.parse File.read(file) unless ENV['UPDATE_NON_SIMP_MODULES'] == 'yes' - if content['name'] !~ %r{\Asimp[-/]} + unless %r{\Asimp[-/]}.match?(content['name']) warn("\n\n\n== WARNING: SKIPPING update of non-simp module (#{content['name']}) (force with `UPDATE_NON_SIMP_MODULES=yes`)\n\n\n") exit 0 end diff --git a/dist/puppetsync/tasks/os_data.rb b/dist/puppetsync/tasks/os_data.rb old mode 100644 new mode 100755 diff --git a/dist/puppetsync/tasks/release_pupmod.rb b/dist/puppetsync/tasks/release_pupmod.rb index 090f0dc..4b22adb 100755 --- a/dist/puppetsync/tasks/release_pupmod.rb +++ b/dist/puppetsync/tasks/release_pupmod.rb @@ -6,24 +6,24 @@ require 'tempfile' require 'tmpdir' -BUNDLER_EXE=ENV['BUNDLER_EXE'] || "/opt/puppetlabs/bolt/bin/bundle" -RAKE_EXE=ENV['RAKE_EXE'] || "/opt/puppetlabs/bolt/bin/rake" -BUNDLE_PATH=ENV['BUNDLE_PATH']||'../../.vendor/bundle' +BUNDLER_EXE = ENV['BUNDLER_EXE'] || '/opt/puppetlabs/bolt/bin/bundle' +RAKE_EXE = ENV['RAKE_EXE'] || '/opt/puppetlabs/bolt/bin/rake' +BUNDLE_PATH = ENV['BUNDLE_PATH'] || '../../.vendor/bundle' def tmp_bundle_rake_execs(repo_path, tasks, save_rake_stdout: false) Dir.mktmpdir('tmp_bundle_rake_execs') do |tmp_dir| Dir.chdir repo_path gemfile_lock = false if File.exist?('Gemfile.lock') - gemfile_lock = File.expand_path('Gemfile.lock',tmp_dir) + gemfile_lock = File.expand_path('Gemfile.lock', tmp_dir) FileUtils.cp File.join(repo_path, 'Gemfile.lock'), gemfile_lock end results = [] - rake_stdout_files={} + rake_stdout_files = {} require 'bundler' require 'rake' Bundler.with_unbundled_env do - #sh "#{BUNDLER_EXE} config path .vendor/bundle &> /dev/null" + # sh "#{BUNDLER_EXE} config path .vendor/bundle &> /dev/null" sh "#{BUNDLER_EXE} install --path '#{BUNDLE_PATH}' &> /dev/null" tasks.each do |task| puts @@ -41,20 +41,18 @@ def tmp_bundle_rake_execs(repo_path, tasks, save_rake_stdout: false) FileUtils.rm('Gemfile.lock') end end - unless results.all?{ |x| x } + unless results.all? { |x| x } warn 'bad result' end return rake_stdout_files if save_rake_stdout end end - # ARGF hack to allow use run the task directly as a ruby script while testing metadata_json_path = false overwrite_existing_tags = false upstream_remote = 'origin' if ARGF.filename == '-' - stdin = '' warn "ARGF.file.lineno: '#{ARGF.file.lineno}'" stdin = ARGF.file.read warn "== stdin: '#{stdin}'" @@ -66,36 +64,31 @@ def tmp_bundle_rake_execs(repo_path, tasks, save_rake_stdout: false) metadata_json_path = ARGF.filename end - # Read content from metadata.json metadata_json_path warn "metadata_json_path: '#{metadata_json_path}'" raise('No metadata.json path given') unless metadata_json_path pupmod_metadata = JSON.parse File.read(metadata_json_path) repo_path = File.dirname metadata_json_path - - unless ENV['UPDATE_NON_SIMP_MODULES'] == 'yes' - if pupmod_metadata['name'] !~ %r{\Asimp[-/]} + if !%r{\Asimp[-/]}.match?(pupmod_metadata['name']) warn("\n\n\n== WARNING: SKIPPING update of non-simp module (#{content['name']}) (force with `UPDATE_NON_SIMP_MODULES=yes`)\n\n\n") else task_output_files = tmp_bundle_rake_execs(repo_path, ['pkg:create_tag_changelog'], save_rake_stdout: true) annotated_tag_file = task_output_files['pkg:create_tag_changelog'] - fail "ERROR: no file at #{annotated_tag_file}" unless File.exist?(annotated_tag_file) + raise "ERROR: no file at #{annotated_tag_file}" unless File.exist?(annotated_tag_file) # strip extra newlines annotated_tag = File.read(task_output_files['pkg:create_tag_changelog']).strip annotated_tag_file = '_annotated_tag.txt' # get rid of RPM date + email + version changelog line(s) - annotated_tag = annotated_tag.lines.reject{ |x| x =~ %r{^\* (\w{3}) (\w{3}) (\d{2}) (\d{4}) .*@} }.join + annotated_tag = annotated_tag.lines.reject { |x| x =~ %r{^\* (\w{3}) (\w{3}) (\d{2}) (\d{4}) .*@} }.join - File.open(annotated_tag_file,'w'){|f| f.puts annotated_tag } + File.open(annotated_tag_file, 'w') { |f| f.puts annotated_tag } - if task_output_files - task_output_files.values.each{|f| FileUtils.rm_f(f) } - end + task_output_files&.each_value { |f| FileUtils.rm_f(f) } sh ">&2 git tag -D '#{pupmod_metadata['version']}'" if overwrite_existing_tags sh ">&2 git tag -a '#{pupmod_metadata['version']}' -F '#{annotated_tag_file}'" diff --git a/dist/puppetsync/tasks/remove_el6.rb b/dist/puppetsync/tasks/remove_el6.rb old mode 100644 new mode 100755 index 52c4a3b..71ccf1e --- a/dist/puppetsync/tasks/remove_el6.rb +++ b/dist/puppetsync/tasks/remove_el6.rb @@ -4,7 +4,6 @@ # ARGF hack to allow use run the task directly as a ruby script while testing if ARGF.filename == '-' - stdin = '' warn "ARGF.file.lineno: '#{ARGF.file.lineno}'" stdin = ARGF.file.read require 'json' @@ -22,109 +21,106 @@ content = File.read(file) data = JSON.parse(content) el_oses = ['CentOS', 'RedHat', 'OracleLinux', 'Amazon', 'Scientific'] -oses = (data['operatingsystem_support'] || [] ).select{ |os| el_oses.include?(os['operatingsystem']) } -changes=[] -oses.each{|os| changes << os['operatingsystemrelease'].delete('6') } +oses = (data['operatingsystem_support'] || []).select { |os| el_oses.include?(os['operatingsystem']) } +changes = oses.map { |os| os['operatingsystemrelease'].delete('6') } changes.compact! new_version = nil # bump Z version if changed unless changes.empty? - parts = data['version'].split(/[\.-]/) + parts = data['version'].split(%r{[\.-]}) parts[2] = (parts[2].to_i + 1).to_s new_version = parts.join('.') data['version'] = new_version end -File.open(file,'w'){|f| f.puts(JSON.pretty_generate(data)) } +File.open(file, 'w') { |f| f.puts(JSON.pretty_generate(data)) } warn "\n\n++ processed '#{file}'" if new_version - changelog_file = File.join(dir,'CHANGELOG') + changelog_file = File.join(dir, 'CHANGELOG') changelog = File.read(changelog_file) require 'date' new_lines = [] new_lines << DateTime.now.strftime("* %a %b %d %Y Chris Tessmer - #{new_version}") new_lines << '- Removed EL6 from supported OSes' changelog = new_lines.join("\n") + "\n\n" + changelog - File.open(changelog_file,'w'){|f| f.puts changelog } + File.open(changelog_file, 'w') { |f| f.puts changelog } end - - # Remove el6 nodesets -warn( %x[find $(find #{dir}/spec/acceptance -name nodesets -type d) -name centos-6.yml -print -exec rm -f {} \\; &> /dev/null] ) +warn(`find $(find #{dir}/spec/acceptance -name nodesets -type d) -name centos-6.yml -print -exec rm -f {} \\; &> /dev/null`) # Remove el6 YAML files -warn( %x[find #{dir}/data/os -name \*6.yaml -print -exec rm -f {} \\; &>/dev/null] ) +warn(`find #{dir}/data/os -name \*6.yaml -print -exec rm -f {} \\; &>/dev/null`) # Remove el6 hosts from Beaker nodesets -nodeset_files = %x[find $(find #{dir}/spec/acceptance -name nodesets -type d) -name \\*.yml].split("\n") -warn %x[grep -E 'el.?6' #{nodeset_files.join(" ")}] +nodeset_files = `find $(find #{dir}/spec/acceptance -name nodesets -type d) -name \\*.yml`.split("\n") +warn `grep -E 'el.?6' #{nodeset_files.join(' ')}` nodeset_files.each do |nodeset_file| - next if %x[grep -c '^ *platform: *el-6-x86_64' #{nodeset_file}].strip == '0' + next if `grep -c '^ *platform: *el-6-x86_64' #{nodeset_file}`.strip == '0' d = File.read(nodeset_file) - section_start_line=nil - delete_block=false + section_start_line = nil + delete_block = false ranges_to_delete = [] - d.lines.each_with_index do |line,idx| - if section_start_line && (line =~ /^ {0,2}[a-zA-Z<]/ || idx == (d.lines.size-1)) && delete_block - i = idx-1 - i = idx if idx == (d.lines.size-1) + d.lines.each_with_index do |line, idx| + if section_start_line && (line =~ %r{^ {0,2}[a-zA-Z<]} || idx == (d.lines.size - 1)) && delete_block + i = idx - 1 + i = idx if idx == (d.lines.size - 1) ranges_to_delete << (section_start_line..i) warn "DELETE BLOCK (starts at #{section_start_line}, ends at #{idx})" - delete_block=false - section_start_line=nil + delete_block = false + section_start_line = nil end - if line =~ /^ [a-z].*:$/ + if %r{^ [a-z].*:$}.match?(line) warn "NEW BLOCK: '#{line.strip}'" - section_start_line=idx - delete_block=false + section_start_line = idx + delete_block = false end - if line =~ /^ platform: *el-6-x86_64/ + if %r{^ platform: *el-6-x86_64}.match?(line) delete_block = true warn "FOUND BAD BLOCK (starts at #{section_start_line})" end end - lines = d.lines - ranges_to_delete.reverse.each { |r| lines.slice!(r) } + ranges_to_delete.reverse_each { |r| lines.slice!(r) } lines_str = lines.join # HACK: Migrate any now-missing roles from deleted nodes to the first node with roles - roles_regex = /^ *(?[a-z0-9_-]+):\n *roles:(?(?:\n *- [a-z0-9-]+)*)/ - orig_roles = d.scan(roles_regex).map{|x| [x[0],x[1].split(/\n *- /).reject{|y| y.empty?}] }.to_h - new_roles = lines_str.scan(roles_regex).map{|x| [x[0],x[1].split(/\n *- /).reject{|y| y.empty?}] }.to_h + roles_regex = %r{^ *(?[a-z0-9_-]+):\n *roles:(?(?:\n *- [a-z0-9-]+)*)} + orig_roles = d.scan(roles_regex).map { |x| [x[0], x[1].split(%r{\n *- }).reject { |y| y.empty? }] }.to_h + new_roles = lines_str.scan(roles_regex).map { |x| [x[0], x[1].split(%r{\n *- }).reject { |y| y.empty? }] }.to_h deleted_nodes = (orig_roles.keys - new_roles.keys) - deleted_node_roles = deleted_nodes.map{|x| orig_roles[x] }.flatten.uniq - new_node_roles = new_roles.map{|k,x| x }.flatten.uniq + deleted_node_roles = deleted_nodes.map { |x| orig_roles[x] }.flatten.uniq + new_node_roles = new_roles.map { |_k, x| x }.flatten.uniq missing_roles = deleted_node_roles - new_node_roles - missing_roles.reject!{|x| x.match(/[-_]?(el|rhel|oel|centos)[-_]?6$/) } + missing_roles.reject! { |x| x.match(%r{[-_]?(el|rhel|oel|centos)[-_]?6$}) } unless missing_roles.empty? role_subs = 0 - lines_str.sub!(/^ *roles:\n(? *- )(?[a-z0-9-]+)/) do |s| + lines_str.sub!(%r{^ *roles:\n(? *- )(?[a-z0-9-]+)}) do |s| role_subs += 1 - space = s.match(/^ *roles:\n(? *- )(?[a-z0-9-]+)/)[:space] - s + "\n" + space.sub('- ','# roles migrated from now-removed el6 node(s):') + missing_roles.map{|x| "\n#{space}#{x}" }.join + space = s.match(%r{^ *roles:\n(? *- )(?[a-z0-9-]+)})[:space] + s + "\n" + space.sub('- ', '# roles migrated from now-removed el6 node(s):') + missing_roles.map { |x| "\n#{space}#{x}" }.join end if role_subs == 0 # if no other nodeset contained roles - space = lines_str.sub!(/^(? *)platform:.*$/) do |s| - space = s.match(/^(? *)platform:/)[:space] - "#{space}roles: # migrated from now-removed el6 node(s)" + missing_roles.map{|x| "\n#{space}- #{x}" }.join + "\n#{s}" + space = lines_str.sub!(%r{^(? *)platform:.*$}) do |s| + space = s.match(%r{^(? *)platform:})[:space] + "#{space}roles: # migrated from now-removed el6 node(s)" + missing_roles.map { |x| "\n#{space}- #{x}" }.join + "\n#{s}" end end end - File.open(nodeset_file,'w'){|f| f.puts lines_str } + File.open(nodeset_file, 'w') { |f| f.puts lines_str } end -warn %Q@grep -i -r -e "\\['6', \\?'7'\\|facts\\(\\['os'\\]\\['release'\\]\\['major'\\]\\|\\[:operatingsystemmajrelease\\]\\|\\[:os\\]\\[:release\\]\\[:major\\]\\)\\(\\.to_\\(i\\|\\s\\)\\)\\? \\(\\(<=\\|==\\) '\\?6'\\?\\|< '\\?7'\\?\\)\\|\\['\\?6'\\?, ?'\\?7'\\?\\]\\|\\(oel\\|rhel\\|centos\\|el\\).6\\|versioncmp($facts\\['os'\\]\\['release'\\]\\['major'\\], '6')" --exclude-dir=.{plan.gems,gems,git} --exclude=\\* --include=\\*.{rb,pp,erb,epp} '#{dir}'@ -grep_results = %x@grep -i -r -e "\\['6', \\?'7'\\|facts\\(\\['os'\\]\\['release'\\]\\['major'\\]\\|\\[:operatingsystemmajrelease\\]\\|\\[:os\\]\\[:release\\]\\[:major\\]\\)\\(\\.to_\\(i\\|\\s\\)\\)\\? \\(\\(<=\\|==\\) '\\?6'\\?\\|< '\\?7'\\?\\)\\|\\['\\?6'\\?, ?'\\?7'\\?\\]\\|\\(oel\\|rhel\\|centos\\|el\\).6\\|versioncmp($facts\\['os'\\]\\['release'\\]\\['major'\\], '6')" --exclude-dir=.{plan.gems,gems,git} --exclude=\\* --include=\\*.{rb,pp,erb,epp} '#{dir}'@ +# rubocop:disable Layout/LineLength +warn %@grep -i -r -e "\\['6', \\?'7'\\|facts\\(\\['os'\\]\\['release'\\]\\['major'\\]\\|\\[:operatingsystemmajrelease\\]\\|\\[:os\\]\\[:release\\]\\[:major\\]\\)\\(\\.to_\\(i\\|\\s\\)\\)\\? \\(\\(<=\\|==\\) '\\?6'\\?\\|< '\\?7'\\?\\)\\|\\['\\?6'\\?, ?'\\?7'\\?\\]\\|\\(oel\\|rhel\\|centos\\|el\\).6\\|versioncmp($facts\\['os'\\]\\['release'\\]\\['major'\\], '6')" --exclude-dir=.{plan.gems,gems,git} --exclude=\\* --include=\\*.{rb,pp,erb,epp} '#{dir}'@ +grep_results = `grep -i -r -e "\\['6', \\?'7'\\|facts\\(\\['os'\\]\\['release'\\]\\['major'\\]\\|\\[:operatingsystemmajrelease\\]\\|\\[:os\\]\\[:release\\]\\[:major\\]\\)\\(\\.to_\\(i\\|\\s\\)\\)\\? \\(\\(<=\\|==\\) '\\?6'\\?\\|< '\\?7'\\?\\)\\|\\['\\?6'\\?, ?'\\?7'\\?\\]\\|\\(oel\\|rhel\\|centos\\|el\\).6\\|versioncmp($facts\\['os'\\]\\['release'\\]\\['major'\\], '6')" --exclude-dir=.{plan.gems,gems,git} --exclude=\\* --include=\\*.{rb,pp,erb,epp} '#{dir}'` +# rubocop:enable Layout/LineLength unless grep_results.empty? - fail "ERROR: EL6 detritus detected under #{dir}:\n\n #{grep_results}\n\n" + raise "ERROR: EL6 detritus detected under #{dir}:\n\n #{grep_results}\n\n" end - warn "\n\nFINIS: #{__FILE__}" diff --git a/dist/puppetsync/tasks/remove_puppet6.rb b/dist/puppetsync/tasks/remove_puppet6.rb index aa225bb..8cd8bfc 100755 --- a/dist/puppetsync/tasks/remove_puppet6.rb +++ b/dist/puppetsync/tasks/remove_puppet6.rb @@ -4,7 +4,6 @@ # ARGF hack to allow use run the task directly as a ruby script while testing if ARGF.filename == '-' - stdin = '' warn "ARGF.file.lineno: '#{ARGF.file.lineno}'" stdin = ARGF.file.read warn "== stdin: '#{stdin}'" @@ -14,32 +13,31 @@ file = ARGF.filename end -#Returns the spot in the file that is no longer managed by puppet +# Returns the spot in the file that is no longer managed by puppet def get_index(input_file, str) content = File.read(input_file) start_idx = nil - content.lines.each_with_index do | line,idx | - if line =~ /#{str}/ + content.lines.each_with_index do |line, idx| + if %r{#{str}}.match?(line) start_idx = idx return start_idx end end - warn("No index match") + warn('No index match') start_idx = 0 end -#Roll puppet6 -> 7, 7 -> 8 +# Roll puppet6 -> 7, 7 -> 8 warn "file: '#{file}'" -start_index = get_index(file, "^# Repo-specific content") -ci_file = File.readlines("#{file}") -ci_file.each_with_index do | line,idx | - if idx >= start_index - puts "searching line:#{idx} #{line}" - line.sub!("pup7", "pup8") - line.sub!("pup_7", "pup_8") - line.sub!('pup6', 'pup7') - line.sub!('pup_6', 'pup_7') - end +start_index = get_index(file, '^# Repo-specific content') +ci_file = File.readlines(file.to_s) +ci_file.each_with_index do |line, idx| + next unless idx >= start_index + puts "searching line:#{idx} #{line}" + line.sub!('pup7', 'pup8') + line.sub!('pup_7', 'pup_8') + line.sub!('pup6', 'pup7') + line.sub!('pup_6', 'pup_7') end -File.open(file, "w") { |out| out.puts ci_file } +File.open(file, 'w') { |out| out.puts ci_file } diff --git a/dist/puppetsync/tasks/run_gha_tests.json b/dist/puppetsync/tasks/run_gha_tests.json new file mode 100644 index 0000000..73e4115 --- /dev/null +++ b/dist/puppetsync/tasks/run_gha_tests.json @@ -0,0 +1,11 @@ +{ + "description": "Run GitHub Actions tests", + "input_method": "environment", + "parameters": { + "path": { + "description": "Path to project folder (ex: '/path/to/gems')", + "type": "String[1]" + } + } +} + diff --git a/dist/puppetsync/tasks/run_gha_tests.sh b/dist/puppetsync/tasks/run_gha_tests.sh new file mode 100644 index 0000000..88e0968 --- /dev/null +++ b/dist/puppetsync/tasks/run_gha_tests.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -euo pipefail + +if [ -n "${PT_path}" ] && [ -d "${PT_path}" ] ; then + cd "${PT_path}" +else + echo "'path' parameter not set or not a valid directory!" >&2 + exit 1 +fi + +act=$(type -p act || :) +if [ -z "$act" ] ; then + echo "act not found. Can't run GitHub Actions locally." >&2 + exit 1 +fi + +# Unfortunately, we need the jumbo image for `rpm` +act --rm -P ubuntu-latest=catthehacker/ubuntu:full-latest pull_request diff --git a/examples/puppetsync_planconfig.SIMP-7035.yaml b/examples/puppetsync_planconfig.SIMP-7035.yaml index 3bcf2f5..2c014d8 100644 --- a/examples/puppetsync_planconfig.SIMP-7035.yaml +++ b/examples/puppetsync_planconfig.SIMP-7035.yaml @@ -6,7 +6,7 @@ puppetsync: - pupmod plans: sync: - #clone_git_repos: false + # clone_git_repos: false skip_pipeline_stages: # - install_gems # - checkout_git_feature_branch_in_each_repo diff --git a/files/gitlab-ci.common.yml b/files/gitlab-ci.common.yml deleted file mode 100644 index 97f8670..0000000 --- a/files/gitlab-ci.common.yml +++ /dev/null @@ -1,142 +0,0 @@ -# The testing matrix considers ruby/puppet versions supported by SIMP and PE: -# -# https://puppet.com/docs/pe/2018.1/component_versions_in_recent_pe_releases.html -# https://puppet.com/misc/puppet-enterprise-lifecycle -# https://puppet.com/docs/pe/2018.1/overview/getting_support_for_pe.html -# ------------------------------------------------------------------------------ -# Release Puppet Ruby EOL -# SIMP 6.1 4.10.6 2.1.9 TBD -# SIMP 6.2 4.10.12 2.1.9 TBD -# PE 2016.4.15 4.10.12 2.1.9 2018-12 (LTS) -# PE 2017.3.10 5.3.8 2.4.4 2018-12 (STS) -# SIMP 6.3 5.5.7 2.4.4 TBD*** -# PE 2018.1 5.5.6 2.4.4 2020-05 (LTS)*** -# PE 2019.0 6.0 2.5.1 2019-08-31^^^ -# -# *** = Modules created for SIMP 6.3+ are not required to support Puppet < 5.5 -# ^^^ = SIMP doesn't support 6 yet; tests are info-only and allowed to fail ---- -stages: - - 'sanity' - - 'validation' - - 'acceptance' - - 'compliance' - - 'deployment' - -image: 'ruby:2.7' - -variables: - PUPPET_VERSION: 'UNDEFINED' # <- Matrixed jobs MUST override this (or fail) - BUNDLER_VERSION: '1.17.1' - - # Force dependencies into a path the gitlab-runner user can write to. - # (This avoids some failures on Runners with misconfigured ruby environments.) - GEM_HOME: .vendor/gem_install - BUNDLE_CACHE_PATH: .vendor/bundle - BUNDLE_PATH: .vendor/bundle - BUNDLE_BIN: .vendor/gem_install/bin - BUNDLE_NO_PRUNE: 'true' - - -# bundler dependencies and caching -# -# - Cache bundler gems between pipelines foreach Ruby version -# - Try to use cached and local resources before downloading dependencies -# -------------------------------------- -.setup_bundler_env: &setup_bundler_env - cache: - untracked: true - key: "${CI_PROJECT_NAMESPACE}_ruby-${MATRIX_RUBY_VERSION}_bundler" - paths: - - '.vendor' - before_script: - - 'ruby -e "puts %(\n\n), %q(=)*80, %(\nSIMP-relevant Environment Variables:\n\n#{e=ENV.keys.grep(/^PUPPET|^SIMP|^BEAKER|MATRIX/); pad=e.map{|x| x.size}.max+1; e.map{|v| %( * #{%(#{v}:).ljust(pad)} #{39.chr + ENV[v] + 39.chr}\n)}.join}\n), %q(=)*80, %(\n\n)"' - - 'declare GEM_BUNDLER_VER=(-v "~> ${BUNDLER_VERSION:-1.17.1}")' - - 'declare GEM_INSTALL_CMD=(gem install --no-document)' - - 'declare BUNDLER_INSTALL_CMD=(bundle install --no-binstubs --jobs $(nproc) "${FLAGS[@]}")' - - 'mkdir -p ${GEM_HOME} ${BUNDLER_BIN}' - - 'gem list -ie "${GEM_BUNDLER_VER[@]}" --silent bundler || "${GEM_INSTALL_CMD[@]}" --local "${GEM_BUNDLER_VER[@]}" bundler || "${GEM_INSTALL_CMD[@]}" "${GEM_BUNDLER_VER[@]}" bundler' - - 'rm -rf pkg/ || :' - - 'bundle check || rm -f Gemfile.lock && ("${BUNDLER_INSTALL_CMD[@]}" --local || "${BUNDLER_INSTALL_CMD[@]}" || bundle pristine || "${BUNDLER_INSTALL_CMD[@]}") || { echo "PIPELINE: Bundler could not install everything (see log output above)" && exit 99 ; }' - -# To avoid running a prohibitive number of tests every commit, -# don't set this env var in your gitlab instance -.only_with_SIMP_FULL_MATRIX: &only_with_SIMP_FULL_MATRIX - only: - variables: - - $SIMP_FULL_MATRIX == "yes" - -# Puppet Versions -#----------------------------------------------------------------------- - -.pup_7: &pup_7 - allow_failure: true - image: 'ruby:2.7' - variables: - PUPPET_VERSION: '~> 7.0' - BEAKER_PUPPET_COLLECTION: 'puppet7' - MATRIX_RUBY_VERSION: '2.7' - - -# Testing Environments -#----------------------------------------------------------------------- - -.lint_tests: &lint_tests - stage: 'validation' - tags: ['docker'] - <<: *setup_bundler_env - script: - - 'bundle exec rake syntax' - - 'bundle exec rake lint' - - 'bundle exec rake metadata_lint' - -.unit_tests: &unit_tests - stage: 'validation' - tags: ['docker'] - <<: *setup_bundler_env - script: - - 'bundle exec rake spec' - -.acceptance_base: &acceptance_base - stage: 'acceptance' - tags: ['beaker'] - <<: *setup_bundler_env - -.compliance_base: &compliance_base - stage: 'compliance' - tags: ['beaker'] - <<: *setup_bundler_env - - -# Pipeline / testing matrix -#======================================================================= - -sanity_checks: - <<: *pup_7 - <<: *setup_bundler_env - stage: 'sanity' - tags: ['docker'] - script: - - 'if `hash apt-get`; then apt-get update; fi' - - 'if `hash apt-get`; then apt-get install -y rpm; fi' - - 'bundle exec rake check:dot_underscore' - - 'bundle exec rake check:test_file' - - 'bundle exec rake pkg:check_version' - - 'bundle exec rake pkg:compare_latest_tag' - - 'bundle exec rake pkg:create_tag_changelog' - - 'bundle exec puppet module build' - -# Linting -#----------------------------------------------------------------------- - -pup7-lint: - <<: *pup_7 - <<: *lint_tests - -# Unit Tests -#----------------------------------------------------------------------- - -pup7-unit: - <<: *pup_7 - <<: *unit_tests - diff --git a/gem.deps.rb b/gem.deps.rb index 061cd66..16df12c 100644 --- a/gem.deps.rb +++ b/gem.deps.rb @@ -5,18 +5,35 @@ # - http://docs.ruby-lang.org/en/2.5.0/Gem.html#method-c-use_gemdeps source 'https://rubygems.org' +def ruby3? + @ruby3 ||= Gem::Requirement.create(['>= 3']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) +end + gem 'octokit', '~> 4.18' gem 'jira-ruby', '~> 2.0' -#gem 'puppet-debugger', '~> 0.17' +# gem 'puppet-debugger', '~> 0.17' gem 'puppet-debugger', '~> 0.2' -gem 'bundler', '~> 2.0' +gem 'bundler', ['~> 2.0'] + (ruby3? ? [] : ['<= 2.4.22']) gem 'pry', '~> 0.13' gem 'pry-remote' gem 'terminal-table', '~> 1.8' gem 'facter', '~> 4.0' -#gem 'puppet-lint' -#gem 'yamllint' gem 'gitlab' -gem 'rubocop' gem 'jsonlint' -gem 'puppet', "~> #{ENV.fetch('PUPPET_VERSION', '7')}" +gem 'puppet', ENV.fetch('PUPPET_VERSION', ruby3? ? '~> 8' : '~> 7') + +group :syntax do + gem 'puppet-syntax', '~> 4.1', require: false + gem 'puppet-lint', '~> 4.2', require: false + gem 'voxpupuli-puppet-lint-plugins', '~> 5.0', require: false + gem 'metadata-json-lint', '~> 4.0', require: false + # gem 'yamllint', require: false + gem 'rubocop', '~> 1.42', require: false + gem 'rubocop-rspec', '~> 3.0', require: false + gem 'rubocop-performance', '~> 1.19', require: false + gem 'rubocop-rake', '~> 0.6', require: false +end + +group :development do + gem 'puppet-strings', '~> 4.0', require: false +end diff --git a/hiera.yaml b/hiera.yaml index e960945..6813688 100644 --- a/hiera.yaml +++ b/hiera.yaml @@ -5,21 +5,20 @@ hierarchy: - name: 'Basic hierarchy' paths: - - "repos/%{::mod_data.repo_name}.yaml" - - "module_names/%{facts.module_metadata.name}.yaml" - - "forge_orgs/%{facts.module_metadata.forge_org}.yaml" - - "project_types/%{facts.project_type}.yaml" - - "common.yaml" + - "repos/%{::mod_data.repo_name}.yaml" + - "module_names/%{facts.module_metadata.name}.yaml" + - "forge_orgs/%{facts.module_metadata.forge_org}.yaml" + - "project_types/%{facts.project_type}.yaml" + - "common.yaml" plan_hierarchy: - name: 'Basic plan hierarchy' paths: - - "sync/batches/%{batchlist}.yaml" - - "sync/configs/%{config}.yaml" - - "sync/repolists/%{repolist}.yaml" - - "sync/common.yaml" + - "sync/batches/%{batchlist}.yaml" + - "sync/configs/%{config}.yaml" + - "sync/repolists/%{repolist}.yaml" + - "sync/common.yaml" defaults: datadir: data data_hash: yaml_data - diff --git a/inventory.yaml b/inventory.yaml index 56a9835..d6ab8a3 100644 --- a/inventory.yaml +++ b/inventory.yaml @@ -5,8 +5,8 @@ config: interpreters: .rb: /opt/puppetlabs/bolt/bin/ruby tmpdir: - _plugin: env_var - var: PWD + _plugin: env_var + var: PWD groups: - name: repo_targets diff --git a/manifests/site.pp b/manifests/site.pp index b6c08c9..893bdb7 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -1,12 +1,17 @@ +# lint:ignore:top_scope_facts warning( "\$::repo_path = '${::repo_path}'" ) warning( "\$::module_metadata = '${::module_metadata}'" ) warning( "\$::module_metadata = '${::module_metadata['forge_org']}'" ) +# lint:endignore if !$facts.dig('repo_path') { fail ( 'The fact $::repo_path must be defined! Hint: use `rake apply`' ) } -lookup('classes', {'value_type' => Array[String], - 'merge' => 'unique', - 'default_value' => [], - }).include +lookup('classes', + { + 'value_type' => Array[String], + 'merge' => 'unique', + 'default_value' => [], + } +).include diff --git a/modules/profile/files/_github/workflows/add_new_issue_to_triage_project.yml b/modules/profile/files/_github/workflows/add_new_issue_to_triage_project.yml index 775d16e..f3c5b84 100644 --- a/modules/profile/files/_github/workflows/add_new_issue_to_triage_project.yml +++ b/modules/profile/files/_github/workflows/add_new_issue_to_triage_project.yml @@ -1,7 +1,26 @@ +# Add new issues to triage project board (https://github.com/orgs/simp/projects/11) +# ------------------------------------------------------------------------------ +# +# NOTICE: **This file is maintained with puppetsync** +# +# This file is updated automatically as part of a puppet module baseline. +# +# The next baseline sync will overwrite any local changes to this file! +# +# ============================================================================== +# This pipeline uses the following GitHub Action Secrets: +# +# GitHub Secret variable Notes +# ------------------------------- --------------------------------------- +# AUTO_TRIAGE_TOKEN Token with appropriate permissions +# +# ------------------------------------------------------------------------------ +# +# --- name: Add new issues to triage project -on: +'on': issues: types: - opened diff --git a/modules/profile/files/_github/workflows/release_rpms.yml b/modules/profile/files/_github/workflows/release_rpms.yml index 450ff7c..04f1ef5 100644 --- a/modules/profile/files/_github/workflows/release_rpms.yml +++ b/modules/profile/files/_github/workflows/release_rpms.yml @@ -31,7 +31,7 @@ --- name: 'RELENG: Build + attach RPMs to GitHub Release' -on: +'on': workflow_dispatch: inputs: release_tag: @@ -71,10 +71,10 @@ on: description: "Dry run (Test-build RPMs)" required: false default: 'no' - #verbose: - # description: 'Verbose RPM builds when "yes"' - # required: false - # default: 'no' + # verbose: + # description: 'Verbose RPM builds when "yes"' + # required: false + # default: 'no' rebuild_number: description: 'If this is an RPM rebuild, put the number of the rebuild here' required: false @@ -255,13 +255,13 @@ jobs: simp_core_ref_for_building_rpms: ${{ secrets.SIMP_CORE_REF_FOR_BUILDING_RPMS }} simp_builder_docker_image: 'docker.io/simpproject/simp_build_${{ github.event.inputs.build_container_os }}:latest' path_to_build: "${{ (github.event.inputs.path_to_build != null && format('{0}/{1}', github.workspace, github.event.inputs.path_to_build)) || github.workspace }}" - verbose: 'no' #${{ github.event.inputs.verbose }} + verbose: 'no' # ${{ github.event.inputs.verbose }} - name: "Wipe all previous assets from GitHub Release (when clean == 'yes')" if: ${{ github.event.inputs.clean == 'yes' && github.event.inputs.dry_run != 'yes' }} uses: actions/github-script@v6 env: - release_id: ${{ steps.release-api.outputs.id }} + release_id: ${{ steps.release-api.outputs.id }} with: github-token: ${{ github.event.inputs.target_repo_token || secrets.GITHUB_TOKEN }} script: | @@ -282,7 +282,7 @@ jobs: env: rpm_file_paths: ${{ steps.build-and-sign-rpm.outputs.rpm_file_paths }} rpm_gpg_file: ${{ steps.build-and-sign-rpm.outputs.rpm_gpg_file }} - release_id: ${{ steps.release-api.outputs.id }} + release_id: ${{ steps.release-api.outputs.id }} clobber: ${{ github.event.inputs.clobber }} clean: ${{ github.event.inputs.clean }} dry_run: ${{ github.event.inputs.dry_run }} diff --git a/modules/profile/files/_github/workflows/tag_deploy_github-only.yml b/modules/profile/files/_github/workflows/tag_deploy_github-only.yml index 77c7a20..2b77a9f 100644 --- a/modules/profile/files/_github/workflows/tag_deploy_github-only.yml +++ b/modules/profile/files/_github/workflows/tag_deploy_github-only.yml @@ -17,7 +17,7 @@ --- name: 'Tag: Release to GitHub' -on: +'on': push: tags: - '[0-9]+\.[0-9]+\.[0-9]+' @@ -77,6 +77,6 @@ jobs: run: | echo "${RELEASE_MESSAGE}" > /tmp/.commit-msg.txt args=(-F /tmp/.commit-msg.txt) - [[ ${{ steps.tag-check.outputs.prerelease }} == yes ]] && args+=(--prerelease) + [[ "${{ steps.tag-check.outputs.prerelease }}" == yes ]] && args+=(--prerelease) gh release create ${args[@]} "$TARGET_TAG" diff --git a/modules/profile/files/_github/workflows/tag_deploy_github-rpms-el7-el8.yml b/modules/profile/files/_github/workflows/tag_deploy_github-rpms-el7-el8.yml index 4425919..83868b8 100644 --- a/modules/profile/files/_github/workflows/tag_deploy_github-rpms-el7-el8.yml +++ b/modules/profile/files/_github/workflows/tag_deploy_github-rpms-el7-el8.yml @@ -29,7 +29,7 @@ --- name: 'Tag: Release to GitHub' -on: +'on': push: tags: # NOTE: These filter patterns aren't actually regexes: @@ -92,13 +92,14 @@ jobs: run: | echo "${RELEASE_MESSAGE}" > /tmp/.commit-msg.txt args=(-F /tmp/.commit-msg.txt) - [[ ${{ steps.tag-check.outputs.prerelease }} == yes ]] && args+=(--prerelease) + [[ "${{ steps.tag-check.outputs.prerelease }}" == yes ]] && args+=(--prerelease) gh release create ${args[@]} "$TARGET_TAG" build-and-attach-rpms: name: Trigger RPM release - needs: [ create-github-release ] + needs: + - create-github-release if: github.repository_owner == 'simp' runs-on: ubuntu-latest env: diff --git a/modules/profile/files/_github/workflows/tag_deploy_github-rpms.yml b/modules/profile/files/_github/workflows/tag_deploy_github-rpms.yml index 6848d7c..8c1f7ce 100644 --- a/modules/profile/files/_github/workflows/tag_deploy_github-rpms.yml +++ b/modules/profile/files/_github/workflows/tag_deploy_github-rpms.yml @@ -29,7 +29,7 @@ --- name: 'Tag: Release to GitHub w/RPMs' -on: +'on': push: tags: # NOTE: These filter patterns aren't actually regexes: @@ -38,7 +38,7 @@ on: - '[0-9]+\.[0-9]+\.[0-9]+\-[a-z]+[0-9]+' env: - PUPPET_VERSION: '~> 7' + PUPPET_VERSION: '~> 8' jobs: create-github-release: @@ -95,13 +95,14 @@ jobs: run: | echo "${RELEASE_MESSAGE}" > /tmp/.commit-msg.txt args=(-F /tmp/.commit-msg.txt) - [[ ${{ steps.tag-check.outputs.prerelease }} == yes ]] && args+=(--prerelease) + [[ "${{ steps.tag-check.outputs.prerelease }}" == yes ]] && args+=(--prerelease) gh release create ${args[@]} "$TARGET_TAG" build-and-attach-rpms: name: Trigger RPM release - needs: [ create-github-release ] + needs: + - create-github-release if: github.repository_owner == 'simp' runs-on: ubuntu-latest env: diff --git a/modules/profile/files/_github/workflows/tag_deploy_rubygem.yml b/modules/profile/files/_github/workflows/tag_deploy_rubygem.yml index bef8064..9bdd919 100644 --- a/modules/profile/files/_github/workflows/tag_deploy_rubygem.yml +++ b/modules/profile/files/_github/workflows/tag_deploy_rubygem.yml @@ -39,7 +39,7 @@ --- name: 'Tag: Release to GitHub + rubygems.org (no RPMS)' -on: +'on': push: tags: # NOTE: These filter patterns aren't actually regexes: @@ -48,7 +48,7 @@ on: - '[0-9]+\.[0-9]+\.[0-9]+\-[a-z]+[0-9]+' env: - PUPPET_VERSION: '~> 7' + PUPPET_VERSION: '~> 8' LOCAL_WORKFLOW_CONFIG_FILE: .github/workflows.local.json jobs: @@ -108,7 +108,8 @@ jobs: create-github-release: name: Deploy GitHub Release - needs: [ releng-checks ] + needs: + - releng-checks if: github.repository_owner == 'simp' runs-on: ubuntu-latest outputs: @@ -162,13 +163,15 @@ jobs: run: | echo "${RELEASE_MESSAGE}" > /tmp/.commit-msg.txt args=(-F /tmp/.commit-msg.txt) - [[ $IS_PRERELEASE == yes ]] && args+=(--prerelease) + [[ "$IS_PRERELEASE" == yes ]] && args+=(--prerelease) gh release create ${args[@]} "$TARGET_TAG" deploy-rubygem: name: Deploy RubyGem Release - needs: [ releng-checks, create-github-release ] + needs: + - releng-checks + - create-github-release if: (github.repository_owner == 'simp') && (needs.create-github-release.outputs.prerelease != 'yes') runs-on: ubuntu-latest env: diff --git a/modules/profile/files/_github/workflows/tag_deploy_rubygem__github-only.yml b/modules/profile/files/_github/workflows/tag_deploy_rubygem__github-only.yml index 11486ea..70b7676 100644 --- a/modules/profile/files/_github/workflows/tag_deploy_rubygem__github-only.yml +++ b/modules/profile/files/_github/workflows/tag_deploy_rubygem__github-only.yml @@ -26,7 +26,7 @@ --- name: 'Tag: Release to GitHub' -on: +'on': push: tags: # NOTE: These filter patterns aren't actually regexes: @@ -35,7 +35,7 @@ on: - '[0-9]+\.[0-9]+\.[0-9]+\-[a-z]+[0-9]+' env: - PUPPET_VERSION: '~> 7' + PUPPET_VERSION: '~> 8' LOCAL_WORKFLOW_CONFIG_FILE: .github/workflows.local.json jobs: @@ -96,7 +96,8 @@ jobs: create-github-release: name: Deploy GitHub Release - needs: [ releng-checks ] + needs: + - releng-checks if: github.repository_owner == 'simp' runs-on: ubuntu-latest outputs: @@ -149,6 +150,6 @@ jobs: run: | echo "${RELEASE_MESSAGE}" > /tmp/.commit-msg.txt args=(-F /tmp/.commit-msg.txt) - [[ ${{ steps.tag-check.outputs.prerelease }} == yes ]] && args+=(--prerelease) + [[ "${{ steps.tag-check.outputs.prerelease }}" == yes ]] && args+=(--prerelease) gh release create ${args[@]} "$TARGET_TAG" diff --git a/modules/profile/files/_github/workflows/tag_deploy_rubygem__github-rpms.yml b/modules/profile/files/_github/workflows/tag_deploy_rubygem__github-rpms.yml index 924c54a..68cb813 100644 --- a/modules/profile/files/_github/workflows/tag_deploy_rubygem__github-rpms.yml +++ b/modules/profile/files/_github/workflows/tag_deploy_rubygem__github-rpms.yml @@ -40,7 +40,7 @@ --- name: 'Tag: Release to GitHub w/RPMs' -on: +'on': push: tags: # NOTE: These filter patterns aren't actually regexes: @@ -49,7 +49,7 @@ on: - '[0-9]+\.[0-9]+\.[0-9]+\-[a-z]+[0-9]+' env: - PUPPET_VERSION: '~> 7' + PUPPET_VERSION: '~> 8' LOCAL_WORKFLOW_CONFIG_FILE: .github/workflows.local.json jobs: @@ -109,7 +109,8 @@ jobs: create-github-release: name: Deploy GitHub Release - needs: [ releng-checks ] + needs: + - releng-checks if: github.repository_owner == 'simp' runs-on: ubuntu-latest outputs: @@ -162,13 +163,14 @@ jobs: run: | echo "${RELEASE_MESSAGE}" > /tmp/.commit-msg.txt args=(-F /tmp/.commit-msg.txt) - [[ ${{ steps.tag-check.outputs.prerelease }} == yes ]] && args+=(--prerelease) + [[ "${{ steps.tag-check.outputs.prerelease }}" == yes ]] && args+=(--prerelease) gh release create ${args[@]} "$TARGET_TAG" build-and-attach-rpms: name: Trigger RPM release - needs: [ create-github-release ] + needs: + - create-github-release if: github.repository_owner == 'simp' runs-on: ubuntu-latest env: diff --git a/modules/profile/files/_github/workflows/validate_tokens_asset.yml b/modules/profile/files/_github/workflows/validate_tokens_asset.yml index 14cb05a..9271994 100644 --- a/modules/profile/files/_github/workflows/validate_tokens_asset.yml +++ b/modules/profile/files/_github/workflows/validate_tokens_asset.yml @@ -20,7 +20,7 @@ --- name: 'Manual: Validate API tokens' -on: +'on': - workflow_dispatch jobs: @@ -52,4 +52,3 @@ jobs: echo "::debug ::${scopes}" exit 1 fi - diff --git a/modules/profile/files/pupmod/Gemfile.simp-simp_core b/modules/profile/files/pupmod/Gemfile.simp-simp_core new file mode 100644 index 0000000..79cbfa9 --- /dev/null +++ b/modules/profile/files/pupmod/Gemfile.simp-simp_core @@ -0,0 +1,56 @@ +# ------------------------------------------------------------------------------ +# NOTICE: **This file is maintained with puppetsync** +# +# This file is automatically updated as part of a puppet module baseline. +# The next baseline sync will overwrite any local changes made to this file. +# ------------------------------------------------------------------------------ +gem_sources = ENV.fetch('GEM_SERVERS', 'https://rubygems.org').split(%r{[, ]+}) + +ENV['PDK_DISABLE_ANALYTICS'] ||= 'true' + +gem_sources.each { |gem_source| source gem_source } + +group :test do + puppet_version = ENV.fetch('PUPPET_VERSION', ['>= 7', '< 9']) + major_puppet_version = Array(puppet_version).first.scan(%r{(\d+)(?:\.|\Z)}).flatten.first.to_i + gem 'hiera-puppet-helper' + gem 'metadata-json-lint' + gem 'naturally' + gem 'pathspec', '~> 0.2' if Gem::Requirement.create('< 2.6').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem('pdk', ENV.fetch('PDK_VERSION', ['>= 2.0', '< 4.0']), require: false) if major_puppet_version > 5 + gem 'puppet', puppet_version + gem 'puppetlabs_spec_helper' + gem 'puppet-lint-trailing_comma-check', require: false + gem 'puppet-strings' + gem 'rake' + gem 'rspec' + gem 'rspec-puppet' + gem 'simp-rake-helpers', ENV.fetch('SIMP_RAKE_HELPERS_VERSION', ['>= 5.21.0', '< 6']) + gem 'simp-rspec-puppet-facts', ENV.fetch('SIMP_RSPEC_PUPPET_FACTS_VERSION', '~> 3.7') +end + +group :development do + gem 'pry' + gem 'pry-byebug' + gem 'pry-doc' +end + +group :system_tests do + gem 'bcrypt_pbkdf' + gem 'beaker' + gem 'beaker-rspec' + gem 'simp-beaker-helpers', ENV.fetch('SIMP_BEAKER_HELPERS_VERSION', ['>= 1.32.1', '< 2']) +end + +# Evaluate extra gemfiles if they exist +extra_gemfiles = [ + ENV.fetch('EXTRA_GEMFILE', ''), + "#{__FILE__}.project", + "#{__FILE__}.local", + File.join(Dir.home, '.gemfile'), +] +extra_gemfiles.each do |gemfile| + if File.file?(gemfile) && File.readable?(gemfile) + eval(File.read(gemfile), binding) # rubocop:disable Security/Eval + end +end diff --git a/modules/profile/files/pupmod/_github/workflows/pr_tests.simp-simp.yml b/modules/profile/files/pupmod/_github/workflows/pr_tests.simp-simp.yml index ca47bd9..3af5a89 100644 --- a/modules/profile/files/pupmod/_github/workflows/pr_tests.simp-simp.yml +++ b/modules/profile/files/pupmod/_github/workflows/pr_tests.simp-simp.yml @@ -11,8 +11,8 @@ # The testing matrix considers ruby/puppet versions supported by SIMP and PE: # ------------------------------------------------------------------------------ # Release Puppet Ruby EOL -# PE 2019.8 6.22 2.5 2022-12 (LTS) -# PE 2021.Y 7.x 2.7 Quarterly updates +# PE 2021.Y 7.x 2.7 2025-02 (LTS) +# PE 2023.Y 8.x 3.2 Biannual updates # # https://puppet.com/docs/pe/latest/component_versions_in_recent_pe_releases.html # https://puppet.com/misc/puppet-enterprise-lifecycle @@ -20,14 +20,14 @@ # # https://docs.github.com/en/actions/reference/events-that-trigger-workflows # - +--- name: PR Tests -on: +'on': pull_request: types: [opened, reopened, synchronize] env: - PUPPET_VERSION: '~> 7' + PUPPET_VERSION: '~> 8' jobs: puppet-syntax: @@ -38,7 +38,7 @@ jobs: - name: "Install Ruby ${{matrix.puppet.ruby_version}}" uses: ruby/setup-ruby@v1 # ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0 with: - ruby-version: 2.7 + ruby-version: 3.2 bundler-cache: true - run: "bundle exec rake syntax" @@ -50,13 +50,13 @@ jobs: - name: "Install Ruby ${{matrix.puppet.ruby_version}}" uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7 + ruby-version: 3.2 bundler-cache: true - run: "bundle exec rake lint" - run: "bundle exec rake metadata_lint" ruby-style: - if: false # TODO Modules will need: rubocop in Gemfile, .rubocop.yml + if: false # TODO Modules will need: rubocop in Gemfile, .rubocop.yml name: 'Ruby Style (experimental)' runs-on: ubuntu-latest continue-on-error: true @@ -65,7 +65,7 @@ jobs: - name: "Install Ruby ${{matrix.puppet.ruby_version}}" uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7 + ruby-version: 3.2 bundler-cache: true - run: | bundle show @@ -76,10 +76,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: 'Install Ruby 2.7' + - name: 'Install Ruby 3.2' uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7 + ruby-version: 3.2 bundler-cache: true - run: bundle exec rake check:dot_underscore - run: bundle exec rake check:test_file @@ -92,7 +92,7 @@ jobs: - name: 'Install Ruby ${{matrix.puppet.ruby_version}}' uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7 + ruby-version: 3.2 bundler-cache: true - name: 'Tags and changelogs' run: | diff --git a/modules/profile/files/pupmod/_github/workflows/pr_tests.yml b/modules/profile/files/pupmod/_github/workflows/pr_tests.yml index 21ca28c..9c0e683 100644 --- a/modules/profile/files/pupmod/_github/workflows/pr_tests.yml +++ b/modules/profile/files/pupmod/_github/workflows/pr_tests.yml @@ -11,8 +11,8 @@ # The testing matrix considers ruby/puppet versions supported by SIMP and PE: # ------------------------------------------------------------------------------ # Release Puppet Ruby EOL -# PE 2019.8 6.22 2.5 2022-12 (LTS) -# PE 2021.Y 7.x 2.7 Quarterly updates +# PE 2021.Y 7.x 2.7 2025-02 (LTS) +# PE 2023.Y 8.x 3.2 Biannual updates # # https://puppet.com/docs/pe/latest/component_versions_in_recent_pe_releases.html # https://puppet.com/misc/puppet-enterprise-lifecycle @@ -20,14 +20,14 @@ # # https://docs.github.com/en/actions/reference/events-that-trigger-workflows # - +--- name: PR Tests -on: +'on': pull_request: types: [opened, reopened, synchronize] env: - PUPPET_VERSION: '~> 7' + PUPPET_VERSION: '~> 8' jobs: puppet-syntax: @@ -38,7 +38,7 @@ jobs: - name: "Install Ruby ${{matrix.puppet.ruby_version}}" uses: ruby/setup-ruby@v1 # ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0 with: - ruby-version: 2.7 + ruby-version: 3.2 bundler-cache: true - run: "bundle exec rake syntax" @@ -50,13 +50,13 @@ jobs: - name: "Install Ruby ${{matrix.puppet.ruby_version}}" uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7 + ruby-version: 3.2 bundler-cache: true - run: "bundle exec rake lint" - run: "bundle exec rake metadata_lint" ruby-style: - if: false # TODO Modules will need: rubocop in Gemfile, .rubocop.yml + if: false # TODO Modules will need: rubocop in Gemfile, .rubocop.yml name: 'Ruby Style (experimental)' runs-on: ubuntu-latest continue-on-error: true @@ -65,7 +65,7 @@ jobs: - name: "Install Ruby ${{matrix.puppet.ruby_version}}" uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7 + ruby-version: 3.2 bundler-cache: true - run: | bundle show @@ -76,10 +76,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: 'Install Ruby 2.7' + - name: 'Install Ruby 3.2' uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7 + ruby-version: 3.2 bundler-cache: true - run: bundle exec rake check:dot_underscore - run: bundle exec rake check:test_file @@ -92,7 +92,7 @@ jobs: - name: 'Install Ruby ${{matrix.puppet.ruby_version}}' uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7 + ruby-version: 3.2 bundler-cache: true - name: 'Tags and changelogs' run: | diff --git a/modules/profile/files/pupmod/_github/workflows/tag_deploy.yml b/modules/profile/files/pupmod/_github/workflows/tag_deploy.yml index 2191ab1..10a5d1c 100644 --- a/modules/profile/files/pupmod/_github/workflows/tag_deploy.yml +++ b/modules/profile/files/pupmod/_github/workflows/tag_deploy.yml @@ -30,7 +30,7 @@ --- name: 'Tag: Release to GitHub w/RPMs + Puppet Forge' -on: +'on': push: tags: # NOTE: These filter patterns aren't actually regexes: @@ -39,7 +39,7 @@ on: - '[0-9]+\.[0-9]+\.[0-9]+\-[a-z]+[0-9]+' env: - PUPPET_VERSION: '~> 7' + PUPPET_VERSION: '~> 8' jobs: releng-checks: @@ -55,7 +55,7 @@ jobs: clean: true - uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7 + ruby-version: 3.2 bundler-cache: true - run: bundle exec rake pkg:check_version - run: bundle exec rake pkg:compare_latest_tag @@ -67,7 +67,8 @@ jobs: create-github-release: name: Deploy GitHub Release - needs: [ releng-checks ] + needs: + - releng-checks if: github.repository_owner == 'simp' runs-on: ubuntu-latest outputs: @@ -117,17 +118,18 @@ jobs: id: create_release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - IS_PRERELASE: ${{ steps.tag-check.outputs.prerelease }} + IS_PRERELEASE: ${{ steps.tag-check.outputs.prerelease }} run: | echo "${RELEASE_MESSAGE}" > /tmp/.commit-msg.txt args=(-F /tmp/.commit-msg.txt) - [[ $IS_PRERELASE == yes ]] && args+=(--prerelease) + [[ "$IS_PRERELEASE" == yes ]] && args+=(--prerelease) gh release create ${args[@]} "$TARGET_TAG" build-and-attach-rpms: name: Trigger RPM release - needs: [ create-github-release ] + needs: + - create-github-release if: github.repository_owner == 'simp' runs-on: ubuntu-latest env: @@ -165,7 +167,8 @@ jobs: deploy-to-puppet-forge: name: 'Deploy PuppetForge Release' - needs: [ create-github-release ] + needs: + - create-github-release if: (github.repository_owner == 'simp') && (needs.create-github-release.outputs.prerelease != 'yes') runs-on: ubuntu-latest env: @@ -180,7 +183,7 @@ jobs: clean: true - uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7 + ruby-version: 3.2 bundler-cache: true - name: Build Puppet module (PDK) run: bundle exec pdk build --force diff --git a/modules/profile/files/pupmod/_github/workflows/validate_tokens.yml b/modules/profile/files/pupmod/_github/workflows/validate_tokens.yml index 11dd5f3..cfbba7b 100644 --- a/modules/profile/files/pupmod/_github/workflows/validate_tokens.yml +++ b/modules/profile/files/pupmod/_github/workflows/validate_tokens.yml @@ -21,7 +21,7 @@ --- name: 'Manual: Validate API tokens' -on: +'on': - workflow_dispatch jobs: @@ -66,4 +66,3 @@ jobs: echo "::debug ::${scopes}" exit 1 fi - diff --git a/modules/profile/files/pupmod/_gitlab-ci.blank_repo_section.yml b/modules/profile/files/pupmod/_gitlab-ci.blank_repo_section.yml index 69a6b25..f597b99 100644 --- a/modules/profile/files/pupmod/_gitlab-ci.blank_repo_section.yml +++ b/modules/profile/files/pupmod/_gitlab-ci.blank_repo_section.yml @@ -1,4 +1,3 @@ - # # Comments regarding repo-specific pipeline content: # diff --git a/modules/profile/files/pupmod/_gitlab-ci.default.repocontent.yml b/modules/profile/files/pupmod/_gitlab-ci.default.repocontent.yml index c2b0f0a..5433fbd 100644 --- a/modules/profile/files/pupmod/_gitlab-ci.default.repocontent.yml +++ b/modules/profile/files/pupmod/_gitlab-ci.default.repocontent.yml @@ -4,4 +4,3 @@ # .repo_metadata/.gitlab-ci-acceptance.repo.yml # # ----------------------------------------------------------------------------- - diff --git a/modules/profile/manifests/github_actions.pp b/modules/profile/manifests/github_actions.pp index ac4acd0..8088f96 100644 --- a/modules/profile/manifests/github_actions.pp +++ b/modules/profile/manifests/github_actions.pp @@ -1,4 +1,9 @@ -# GitHub actions +# @summary GitHub actions +# +# @param target_github_actions_dir +# @param target_repo_name +# @param present_action_files +# @param absent_action_files # # Specific repos can provide their own customized file using the filename # convention:: @@ -7,29 +12,29 @@ # # files/pupmod/_github/workflows/{workflow_name}.{repo_name}.yml # -class profile::github_actions( - Stdlib::Absolutepath $target_github_actions_dir = "${::repo_path}/.github/workflows", +class profile::github_actions ( + Stdlib::Absolutepath $target_github_actions_dir = "${::repo_path}/.github/workflows", # lint:ignore:top_scope_facts Optional[String[1]] $target_repo_name = $facts.dig('module_metadata','name'), Array[String] $present_action_files = [], Array[String] $absent_action_files = [ 'pr_glci.yml', 'pr_glci_cleanup.yml', 'pr_glci_manual.yml', ], -){ - $project_type = $facts.dig('project_type').lest || {'unknown'} +) { + $project_type = $facts.dig('project_type').lest || { 'unknown' } $project_type2 = $project_type == 'pupmod_skeleton' ? { true => 'pupmod', default => "NO_PROJECT_TYPE_FOR_${project_type}", } - file{ [$target_github_actions_dir, dirname($target_github_actions_dir)]: ensure => directory } + file { [$target_github_actions_dir, dirname($target_github_actions_dir)]: ensure => directory } $absent_action_files.each |$action_file| { - file{ "${target_github_actions_dir}/${action_file}": ensure => absent } + file { "${target_github_actions_dir}/${action_file}": ensure => absent } } $present_action_files.each |$action_file| { $action = basename( $action_file, '.yml' ) - file{ "${target_github_actions_dir}/${action_file}": + file { "${target_github_actions_dir}/${action_file}": content => file( "${module_name}/${project_type}/_github/workflows/${action}.${target_repo_name}.yml", "${module_name}/${project_type}/_github/workflows/${action}.yml", diff --git a/modules/profile/manifests/obsoletes.pp b/modules/profile/manifests/obsoletes.pp index 033b1b8..b9af8b8 100644 --- a/modules/profile/manifests/obsoletes.pp +++ b/modules/profile/manifests/obsoletes.pp @@ -1,11 +1,14 @@ -# Ensure that obsolete files are removed +# @summary Ensure that obsolete files are removed +# +# @param files +# @param repo_path # # Use Hiera to build up a $files array -class profile::obsoletes( +class profile::obsoletes ( Array[String[1]] $files = [], - Stdlib::Absolutepath $repo_path = $::repo_path, -){ - file{ $files.map |$file| { "${repo_path}/${file}" }: + Stdlib::Absolutepath $repo_path = $::repo_path, # lint:ignore:top_scope_facts +) { + file { $files.map |$file| { "${repo_path}/${file}" }: ensure => absent, force => true, } diff --git a/modules/profile/manifests/pupmod/base.pp b/modules/profile/manifests/pupmod/base.pp index 25bafc3..9255b89 100644 --- a/modules/profile/manifests/pupmod/base.pp +++ b/modules/profile/manifests/pupmod/base.pp @@ -1,6 +1,6 @@ # Common code for all pupmod:: roles class profile::pupmod::base { - $project_type = $facts.dig('project_type').lest || {'unknown'} + $project_type = $facts.dig('project_type').lest || { 'unknown' } unless $project_type == 'pupmod' or $project_type == 'pupmod_skeleton' { fail("ERROR: reached class '${title}', but project_type is not a 'pupmod' (${project_type})") } @@ -8,7 +8,7 @@ if $org { warn("======== Forge org: ${org}") } # Clean up obsolete puppetsync folder - file{ "${::repo_path}/.repo_metadata": + file { "${::repo_path}/.repo_metadata": # lint:ignore:top_scope_facts ensure => absent, force => true, } diff --git a/modules/profile/manifests/pupmod/gemfile.pp b/modules/profile/manifests/pupmod/gemfile.pp index 10a4b32..bd821f7 100644 --- a/modules/profile/manifests/pupmod/gemfile.pp +++ b/modules/profile/manifests/pupmod/gemfile.pp @@ -1,16 +1,18 @@ -# Static Gemfile for Puppet modules -class profile::pupmod::gemfile( - Stdlib::Absolutepath $gemfile_path = "${::repo_path}/Gemfile", +# @summary Static Gemfile for Puppet modules +# @param gemfile_path +# @param target_module_name +class profile::pupmod::gemfile ( + Stdlib::Absolutepath $gemfile_path = "${::repo_path}/Gemfile", # lint:ignore:top_scope_facts Optional[String[1]] $target_module_name = $facts.dig('module_metadata','name'), -){ - file{ $gemfile_path: +) { + file { $gemfile_path: content => file( "${module_name}/pupmod/Gemfile.${target_module_name}", "${module_name}/pupmod/Gemfile", - ) + ), } - file{ "${gemfile_path}.lock": + file { "${gemfile_path}.lock": ensure => absent, } } diff --git a/modules/profile/manifests/pupmod/git_files.pp b/modules/profile/manifests/pupmod/git_files.pp index 03f85ea..e8dea31 100644 --- a/modules/profile/manifests/pupmod/git_files.pp +++ b/modules/profile/manifests/pupmod/git_files.pp @@ -1,10 +1,13 @@ -# Manages .gitignore and .gitattributes -class profile::pupmod::git_files( - Stdlib::Absolutepath $gitignore_path = "${::repo_path}/.gitignore", - Stdlib::Absolutepath $gitattributes_path = "${::repo_path}/.gitattributes", +# @summary Manages .gitignore and .gitattributes +# @param gitignore_path +# @param gitattributes_path +# @param target_module_name +class profile::pupmod::git_files ( + Stdlib::Absolutepath $gitignore_path = "${::repo_path}/.gitignore", # lint:ignore:top_scope_facts + Stdlib::Absolutepath $gitattributes_path = "${::repo_path}/.gitattributes", # lint:ignore:top_scope_facts Optional[String[1]] $target_module_name = $facts.dig('module_metadata','name'), -){ - file{ $gitignore_path: +) { + file { $gitignore_path: content => file( "${module_name}/pupmod/_gitignore.${target_module_name}", "${module_name}/pupmod/_gitignore", @@ -12,7 +15,7 @@ ), } - file{ $gitattributes_path: + file { $gitattributes_path: content => file( "${module_name}/pupmod/_gitattributes.${target_module_name}", "${module_name}/pupmod/_gitattributes", diff --git a/modules/profile/manifests/pupmod/gitlab_ci.pp b/modules/profile/manifests/pupmod/gitlab_ci.pp index f664f86..0a461a1 100644 --- a/modules/profile/manifests/pupmod/gitlab_ci.pp +++ b/modules/profile/manifests/pupmod/gitlab_ci.pp @@ -1,45 +1,11 @@ -# Static .gitlab-ci.yml file for Puppet modules. +# @summary Static .gitlab-ci.yml file for Puppet modules. # -# There are two components of SIMP .gitlab-ci.yml pipelines: -# -# 1. The standardized CI pipeline for SIMP Puppet modules -# - e.g., Cache, stages, YAML anchors, most jobs EXCEPT acceptance tests -# - This section should be static across all module repositories -# -# 2. Repo-specific CI content -# - Jobs that provide acceptance and compliance tests -# - These jobs vary from repo to repo, and are managed directly in -# repository -# -# This profile enforces the standardized content in `.gitlab-ci.yml`, but also -# persists existing repo-specific content. The repo-specific content must be -# defined below the following two lines: -# -# ``` -# # Repo-specific content -# # ======================================================================== -# ``` -# -# @param existing_pipeline_content -# The content of the module's existing `.gitlab-ci.yml` file, used to detect -# and perist local changes. -# -# * By default, this content read directly from the target's `$::repo_path` on -# the local filesystem. -# * If the target doesn't have a `.gitlab-ci.yml` file, default starter -# content will be sourced from this module. -# -# Target-specific content will be detected by searching for a specific lines -# (see the profile's documentation for an example) -# -# Anything below those lines will be saved, and added to Puppet-managed -# template. -# -class profile::pupmod::gitlab_ci( - Stdlib::Absolutepath $target_gitlabci_yml_path = "${::repo_path}/.gitlab-ci.yml", +# @param target_gitlabci_yml_path +# @param target_module_name +class profile::pupmod::gitlab_ci ( + Stdlib::Absolutepath $target_gitlabci_yml_path = "${::repo_path}/.gitlab-ci.yml", # lint:ignore:top_scope_facts Optional[String[1]] $target_module_name = $facts.dig('module_metadata','name'), -){ - +) { # NOTE: as noted above, the default value first attempts to read in the # target's existing `.gitlab-ci.yml`. This allows us to persist # locally-managed, repo-specific pipeline content while keeping the resource @@ -77,7 +43,7 @@ "${module_name}/pupmod/_gitlab-ci.yml.epp" ) - file{ $target_gitlabci_yml_path: + file { $target_gitlabci_yml_path: content => epp( $gitlab_ci_template_path, { 'repo_specific_content' => $repo_specific_content, diff --git a/modules/profile/manifests/pupmod/pdkignore.pp b/modules/profile/manifests/pupmod/pdkignore.pp index 95cddc0..decafdf 100644 --- a/modules/profile/manifests/pupmod/pdkignore.pp +++ b/modules/profile/manifests/pupmod/pdkignore.pp @@ -1,4 +1,7 @@ -# Static .pdkignore file for Puppet modules. +# @summary Static .pdkignore file for Puppet modules. +# +# @param target_pdkignore_path +# @param target_module_name # # Specific modules can provide their own .pdkignore file using the filename # convention:: @@ -7,11 +10,11 @@ # # files/pupmod/_pdkignore.pupmod-simp-name # -class profile::pupmod::pdkignore( - Stdlib::Absolutepath $target_pdkignore_path = "${::repo_path}/.pdkignore", +class profile::pupmod::pdkignore ( + Stdlib::Absolutepath $target_pdkignore_path = "${::repo_path}/.pdkignore", # lint:ignore:top_scope_facts Optional[String[1]] $target_module_name = $facts.dig('module_metadata','name'), -){ - file{ $target_pdkignore_path: +) { + file { $target_pdkignore_path: content => file( "${module_name}/pupmod/_pdkignore.${target_module_name}", "${module_name}/pupmod/_pdkignore" diff --git a/modules/profile/manifests/pupmod/puppet_lint.pp b/modules/profile/manifests/pupmod/puppet_lint.pp index 045849e..cc22b63 100644 --- a/modules/profile/manifests/pupmod/puppet_lint.pp +++ b/modules/profile/manifests/pupmod/puppet_lint.pp @@ -1,9 +1,11 @@ -# Manages .puppet-lint.rc -class profile::pupmod::puppet_lint( - Stdlib::Absolutepath $puppet_lint_rc_path = "${::repo_path}/.puppet-lint.rc", +# @summary Manages .puppet-lint.rc +# @param puppet_lint_rc_path +# @param target_module_name +class profile::pupmod::puppet_lint ( + Stdlib::Absolutepath $puppet_lint_rc_path = "${::repo_path}/.puppet-lint.rc", # lint:ignore:top_scope_facts Optional[String[1]] $target_module_name = $facts.dig('module_metadata','name'), -){ - file{ $puppet_lint_rc_path: +) { + file { $puppet_lint_rc_path: content => file( "${module_name}/pupmod/_puppet-lint.rc.${target_module_name}", "${module_name}/pupmod/_puppet-lint.rc", diff --git a/modules/profile/manifests/pupmod/rspec.pp b/modules/profile/manifests/pupmod/rspec.pp index 4567ac1..5789107 100644 --- a/modules/profile/manifests/pupmod/rspec.pp +++ b/modules/profile/manifests/pupmod/rspec.pp @@ -10,13 +10,18 @@ Optional[String[1]] $target_module_name = $facts.dig('module_metadata','name'), ) { file { $rspec_path: + ensure => file, content => file( "${module_name}/pupmod/_rspec.${target_module_name}", "${module_name}/pupmod/_rspec", ), } - file { $spec_helper_path: + file { dirname($spec_helper_path): + ensure => directory, + } + -> file { $spec_helper_path: + ensure => file, content => epp( "${module_name}/pupmod/spec/spec_helper.rb.epp", ), diff --git a/modules/profile/templates/pupmod/_gitlab-ci.yml.epp b/modules/profile/templates/pupmod/_gitlab-ci.yml.epp index ec71160..6fa7387 100644 --- a/modules/profile/templates/pupmod/_gitlab-ci.yml.epp +++ b/modules/profile/templates/pupmod/_gitlab-ci.yml.epp @@ -11,13 +11,12 @@ # ------------------------------------------------------------------------------ # The testing matrix considers ruby/puppet versions supported by SIMP and PE: # -# https://puppet.com/docs/pe/2019.8/component_versions_in_recent_pe_releases.html +# https://puppet.com/docs/pe/latest/component_versions_in_recent_pe_releases.html # https://puppet.com/misc/puppet-enterprise-lifecycle -# https://puppet.com/docs/pe/2018.1/overview/getting_support_for_pe.html # ------------------------------------------------------------------------------ # Release Puppet Ruby EOL -# PE 2019.8 6.28 2.5.7 2023-07 (LTS) -# PE 2021.7 7.20 2.7.6 TBD (LTS) +# PE 2021.7 7.30 2.7.8 2025-02 (LTS) +# PE 2023.8 8.6 3.2.3 TBD --- stages: @@ -33,29 +32,29 @@ variables: # fail. The intended value for PUPPET_VERSION is provided by the `pup_#` YAML # anchors. If it is still `UNDEFINED`, all the other setting from the job's # anchor are also missing. - PUPPET_VERSION: 'UNDEFINED' # <- Matrixed jobs MUST override this (or fail) - BUNDLER_VERSION: '2.2.19' + PUPPET_VERSION: 'UNDEFINED' # <- Matrixed jobs MUST override this (or fail) + BUNDLER_VERSION: '2.4.22' SIMP_MATRIX_LEVEL: '1' SIMP_FORCE_RUN_MATRIX: 'no' # Force dependencies into a path the gitlab-runner user can write to. # (This avoids some failures on Runners with misconfigured ruby environments.) - GEM_HOME: .vendor/gem_install + GEM_HOME: .vendor/gem_install BUNDLE_CACHE_PATH: .vendor/bundle - BUNDLE_PATH: .vendor/bundle - BUNDLE_BIN: .vendor/gem_install/bin - BUNDLE_NO_PRUNE: 'true' + BUNDLE_PATH: .vendor/bundle + BUNDLE_BIN: .vendor/gem_install/bin + BUNDLE_NO_PRUNE: 'true' .snippets: before_beaker_google: # Logic for beaker-google environments - echo -e "\e[0Ksection_start:`date +%s`:before_script05[collapsed=true]\r\e[0KGCP environment checks" - - "if [ \"$BEAKER_HYPERVISOR\" == google ]; then mkdir -p ~/.ssh; chmod 700 ~/.ssh; test -f ~/.ssh/google_compute_engine || ssh-keygen -f ~/.ssh/google_compute_engine < /dev/null; echo 'gem \"beaker-google\"' >> Gemfile.local ; fi" + - "if [ \"$BEAKER_HYPERVISOR\" == google ]; then mkdir -p ~/.ssh; chmod 700 ~/.ssh; test -f ~/.ssh/google_compute_engine || ssh-keygen -f ~/.ssh/google_compute_engine < /dev/null; echo 'gem \"beaker-google\"' >> Gemfile.local ; fi" # yamllint disable rule:line-length - echo -e "\e[0Ksection_end:`date +%s`:before_script05\r\e[0K" before: # Print important environment variables that may affect this job - - 'ruby -e "puts %(\n\n), %q(=)*80, %(\nSIMP-relevant Environment Variables:\n\n#{e=ENV.keys.grep(/^PUPPET|^SIMP|^BEAKER|MATRIX|GOOGLE/); pad=((e.map{|x| x.size}.max||0)+1); e.map{|v| %( * #{%(#{v}:).ljust(pad)} #{39.chr + ENV[v] + 39.chr}\n)}.join}\n), %q(=)*80, %(\n\n)" || :' + - 'ruby -e "puts %(\n\n), %q(=)*80, %(\nSIMP-relevant Environment Variables:\n\n#{e=ENV.keys.grep(/^PUPPET|^SIMP|^BEAKER|MATRIX|GOOGLE/); pad=((e.map{|x| x.size}.max||0)+1); e.map{|v| %( * #{%(#{v}:).ljust(pad)} #{39.chr + ENV[v] + 39.chr}\n)}.join}\n), %q(=)*80, %(\n\n)" || :' # yamllint disable rule:line-length - echo -e "\e[0Ksection_start:`date +%s`:before_script10[collapsed=true]\r\e[0KDiagnostic ruby & gem information" # Diagnostic ruby & gem information @@ -70,7 +69,10 @@ variables: # * Use $MATRIX_RUBY_VERSION ruby, install if not present - echo -e "\e[0Ksection_start:`date +%s`:before_script20[collapsed=true]\r\e[0KEnsure RVM & ruby is installed" - "if command -v rvm; then if declare -p rvm_path &> /dev/null; then source \"${rvm_path}/scripts/rvm\"; else source \"$HOME/.rvm/scripts/rvm\" || source /etc/profile.d/rvm.sh; fi; fi" - - "if command -v rvm && ! grep rvm_install_on_use_flag=1 ~/.rvmrc; then echo rvm_install_on_use_flag=1 >> ~/.rvmrc || echo '== WARNING: ~/.rvmrc is missing rvm_install_on_use_flag=1 and I failed to add it'; fi" + - >- + if command -v rvm && ! grep rvm_install_on_use_flag=1 ~/.rvmrc; then + echo rvm_install_on_use_flag=1 >> ~/.rvmrc + || echo '== WARNING: ~/.rvmrc is missing rvm_install_on_use_flag=1 and I failed to add it'; fi - "if command -v rvm; then rvm use \"$MATRIX_RUBY_VERSION\"; else echo \"rvm not detected; skipping 'rvm use'\"; fi" - 'ruby --version || :' - 'gem list sync || :' @@ -79,13 +81,20 @@ variables: # Bundle gems (preferring cached > local > downloaded resources) # * Try to use cached and local resources before downloading dependencies - echo -e "\e[0Ksection_start:`date +%s`:before_script30[collapsed=true]\r\e[0KBundle gems (preferring cached > local > downloaded resources)" - - 'declare GEM_BUNDLER_VER=(-v "~> ${BUNDLER_VERSION:-2.2.6}")' + - 'declare GEM_BUNDLER_VER=(-v "~> ${BUNDLER_VERSION:-2.4.22}")' - 'declare GEM_INSTALL_CMD=(gem install --no-document)' - 'declare BUNDLER_INSTALL_CMD=(bundle install --no-binstubs --jobs $(nproc) "${FLAGS[@]}")' - 'mkdir -p ${GEM_HOME} ${BUNDLER_BIN}' - 'gem list -ie "${GEM_BUNDLER_VER[@]}" --silent bundler || "${GEM_INSTALL_CMD[@]}" --local "${GEM_BUNDLER_VER[@]}" bundler || "${GEM_INSTALL_CMD[@]}" "${GEM_BUNDLER_VER[@]}" bundler' - 'rm -rf pkg/ || :' - - 'bundle check || rm -f Gemfile.lock && ("${BUNDLER_INSTALL_CMD[@]}" --local || "${BUNDLER_INSTALL_CMD[@]}" || bundle pristine || "${BUNDLER_INSTALL_CMD[@]}") || { echo "PIPELINE: Bundler could not install everything (see log output above)" && exit 99 ; }' + - >- + bundle check + || rm -f Gemfile.lock + && ("${BUNDLER_INSTALL_CMD[@]}" --local + || "${BUNDLER_INSTALL_CMD[@]}" + || bundle pristine + || "${BUNDLER_INSTALL_CMD[@]}") + || { echo "PIPELINE: Bundler could not install everything (see log output above)" && exit 99 ; } - echo -e "\e[0Ksection_end:`date +%s`:before_script30\r\e[0K" # Diagnostic bundler, ruby, and gem checks: @@ -182,7 +191,6 @@ variables: when: on_success - # SIMP_MATRIX_LEVEL=1: Intended to run every commit .with_SIMP_ACCEPTANCE_MATRIX_LEVEL_1: &with_SIMP_ACCEPTANCE_MATRIX_LEVEL_1 rules: @@ -233,7 +241,7 @@ variables: # Puppet Versions -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- .pup_7_x: &pup_7_x image: 'ruby:2.7' @@ -257,9 +265,8 @@ variables: MATRIX_RUBY_VERSION: '3.2' - # Testing Environments -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- .lint_tests: &lint_tests stage: 'validation' @@ -287,7 +294,6 @@ variables: - !reference [.snippets, before] - .acceptance_base: &acceptance_base stage: 'acceptance' <<: *setup_bundler_env @@ -302,7 +308,7 @@ variables: # Pipeline / testing matrix -#======================================================================= +# ======================================================================= releng_checks: <<: *pup_7_x @@ -320,7 +326,7 @@ releng_checks: # Linting -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- # NOTE: Don't add more lint checks here. # puppet-lint is a validator, not a parser; it includes its own lexer and @@ -332,7 +338,7 @@ pup-lint: <<: *lint_tests # Unit Tests -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- pup7.x-unit: <<: *pup_7_x @@ -343,10 +349,9 @@ pup7.pe-unit: <<: *pup_7_pe <<: *unit_tests -# Commenting until Puppet 8 is released -#pup8.x-unit: -# <<: *pup_8_x -# <<: *unit_tests +pup8.x-unit: + <<: *pup_8_x + <<: *unit_tests # ------------------------------------------------------------------------------ # NOTICE: **This file is maintained with puppetsync** diff --git a/modules/profile/templates/pupmod/_gitlab-ci.yml.simp-simp.epp b/modules/profile/templates/pupmod/_gitlab-ci.yml.simp-simp.epp index e8b0620..adefe97 100644 --- a/modules/profile/templates/pupmod/_gitlab-ci.yml.simp-simp.epp +++ b/modules/profile/templates/pupmod/_gitlab-ci.yml.simp-simp.epp @@ -11,13 +11,12 @@ # ------------------------------------------------------------------------------ # The testing matrix considers ruby/puppet versions supported by SIMP and PE: # -# https://puppet.com/docs/pe/2019.8/component_versions_in_recent_pe_releases.html +# https://puppet.com/docs/pe/latest/component_versions_in_recent_pe_releases.html # https://puppet.com/misc/puppet-enterprise-lifecycle -# https://puppet.com/docs/pe/2018.1/overview/getting_support_for_pe.html # ------------------------------------------------------------------------------ # Release Puppet Ruby EOL -# PE 2019.8 6.28 2.5.7 2023-07 (LTS) -# PE 2021.7 7.20 2.7.6 TBD (LTS) +# PE 2021.7 7.30 2.7.8 2025-02 (LTS) +# PE 2023.8 8.6 3.2.3 TBD --- stages: @@ -34,7 +33,7 @@ variables: # anchors. If it is still `UNDEFINED`, all the other setting from the job's # anchor are also missing. PUPPET_VERSION: 'UNDEFINED' # <- Matrixed jobs MUST override this (or fail) - BUNDLER_VERSION: '1.17.1' + BUNDLER_VERSION: '2.4.22' SIMP_MATRIX_LEVEL: '1' SIMP_FORCE_RUN_MATRIX: 'no' @@ -79,7 +78,7 @@ variables: # Bundle gems (preferring cached > local > downloaded resources) # * Try to use cached and local resources before downloading dependencies - echo -e "\e[0Ksection_start:`date +%s`:before_script30[collapsed=true]\r\e[0KBundle gems (preferring cached > local > downloaded resources)" - - 'declare GEM_BUNDLER_VER=(-v "~> ${BUNDLER_VERSION:-2.2.6}")' + - 'declare GEM_BUNDLER_VER=(-v "~> ${BUNDLER_VERSION:-2.4.22}")' - 'declare GEM_INSTALL_CMD=(gem install --no-document)' - 'declare BUNDLER_INSTALL_CMD=(bundle install --no-binstubs --jobs $(nproc) "${FLAGS[@]}")' - 'mkdir -p ${GEM_HOME} ${BUNDLER_BIN}' @@ -371,13 +370,13 @@ pup7.pe-unit_slow: <<: *slow_unit_tests # Commented until we are ready for puppet 8 -#pup8.x-unit: -# <<: *pup_8_x -# <<: *unit_tests -# -#pup8.x-unit_slow: -# <<: *pup_8_x -# <<: *slow_unit_tests +pup8.x-unit: + <<: *pup_8_x + <<: *unit_tests + +pup8.x-unit_slow: + <<: *pup_8_x + <<: *slow_unit_tests # ------------------------------------------------------------------------------ # NOTICE: **This file is maintained with puppetsync** diff --git a/modules/profile/templates/pupmod/spec/spec_helper.rb.epp b/modules/profile/templates/pupmod/spec/spec_helper.rb.epp index 8e2bb0d..3583132 100644 --- a/modules/profile/templates/pupmod/spec/spec_helper.rb.epp +++ b/modules/profile/templates/pupmod/spec/spec_helper.rb.epp @@ -1,4 +1,5 @@ # frozen_string_literal: true + # # ------------------------------------------------------------------------------ # NOTICE: **This file is maintained with puppetsync** @@ -97,7 +98,7 @@ RSpec.configure do |c| # If nothing else... c.default_facts = { production: { - #:fqdn => 'production.rspec.test.localdomain', + # :fqdn => 'production.rspec.test.localdomain', path: '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin', concat_basedir: '/tmp' } @@ -157,9 +158,9 @@ RSpec.configure do |c| # sanitize hieradata if defined?(hieradata) - set_hieradata(hieradata.gsub(':', '_')) + set_hieradata(hieradata.tr(':', '_')) elsif defined?(class_name) - set_hieradata(class_name.gsub(':', '_')) + set_hieradata(class_name.tr(':', '_')) end end diff --git a/modules/role/manifests/pupmod_github_actions_only.pp b/modules/role/manifests/pupmod_github_actions_only.pp index 51a35d2..d13ca2a 100644 --- a/modules/role/manifests/pupmod_github_actions_only.pp +++ b/modules/role/manifests/pupmod_github_actions_only.pp @@ -3,4 +3,3 @@ include 'profile::pupmod::base' include 'profile::pupmod::github_actions' } - diff --git a/modules/role/manifests/pupmod_gitlabci_only.pp b/modules/role/manifests/pupmod_gitlabci_only.pp index 5d06b64..8114028 100644 --- a/modules/role/manifests/pupmod_gitlabci_only.pp +++ b/modules/role/manifests/pupmod_gitlabci_only.pp @@ -3,4 +3,3 @@ include 'profile::pupmod::base' include 'profile::pupmod::gitlab_ci' } - diff --git a/modules/role/manifests/pupmod_skeleton.pp b/modules/role/manifests/pupmod_skeleton.pp index 054381f..68b4043 100644 --- a/modules/role/manifests/pupmod_skeleton.pp +++ b/modules/role/manifests/pupmod_skeleton.pp @@ -10,4 +10,3 @@ class role::pupmod_skeleton { include 'role::pupmod' } - diff --git a/scripts/test-rocky8-steps.sh b/scripts/test-rocky8-steps.sh index aa6d332..0140e67 100644 --- a/scripts/test-rocky8-steps.sh +++ b/scripts/test-rocky8-steps.sh @@ -15,5 +15,5 @@ rm -rf spec/fixtures/modules/pupmod-* || : test -f "$i/metadata.json" && SKIP_RAKE_TASKS=yes "$RUBY_EXE" ../../dist/puppetsync/tasks/modernize_metadata_json.rb "$i/metadata.json" || : done -[[ ${SKIP_TESTS:-no} == yes ]] && exit 0 || : +[[ "${SKIP_TESTS:-no}" == yes ]] && exit 0 || : SPEC_OPTS="${SPEC_OPTS:---no-fail-fast}" "$BUNDLE_EXE" exec rake spec_standalone 2>&1 | tee ../"$( jq -r .name metadata.json ).rspec.log" && rm -f Gemfile.lock