diff --git a/.github/workflows/pr-checks.yaml b/.github/workflows/pr-checks.yaml index 61e6c2e..23025b1 100644 --- a/.github/workflows/pr-checks.yaml +++ b/.github/workflows/pr-checks.yaml @@ -91,3 +91,11 @@ jobs: run: sudo -E /opt/puppetlabs/pdk/bin/pdk bundle install - name: Run acceptance tests run: sudo -E /opt/puppetlabs/pdk/bin/pdk bundle exec rake litmus:acceptance:localhost + + typos: + name: typos + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v5 + - uses: crate-ci/typos@v1.38.1 diff --git a/.rubocop.yml b/.rubocop.yml index e9510cd..a5ba752 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,11 +1,14 @@ --- -require: +plugins: - rubocop-performance - rubocop-rspec +- rubocop-rspec_rails +- rubocop-factory_bot +- rubocop-capybara AllCops: NewCops: enable DisplayCopNames: true - TargetRubyVersion: 3.1 + TargetRubyVersion: 2.7 Include: - "**/*.rb" Exclude: @@ -130,6 +133,12 @@ Capybara/CurrentPathExpectation: Enabled: false Capybara/VisibilityMatcher: Enabled: false +FactoryBot/AttributeDefinedStatically: + Enabled: false +FactoryBot/CreateList: + Enabled: false +FactoryBot/FactoryClassName: + Enabled: false Gemspec/DuplicatedAssignment: Enabled: false Gemspec/OrderedDependencies: @@ -304,8 +313,6 @@ Performance/UriDefaultParser: Enabled: false RSpec/Be: Enabled: false -RSpec/Capybara/FeatureMethods: - Enabled: false RSpec/ContainExactly: Enabled: false RSpec/ContextMethod: @@ -314,6 +321,8 @@ RSpec/ContextWording: Enabled: false RSpec/DescribeClass: Enabled: false +RSpec/Dialect: + Enabled: false RSpec/EmptyHook: Enabled: false RSpec/EmptyLineAfterExample: @@ -330,12 +339,6 @@ RSpec/ExpectChange: Enabled: false RSpec/ExpectInHook: Enabled: false -RSpec/FactoryBot/AttributeDefinedStatically: - Enabled: false -RSpec/FactoryBot/CreateList: - Enabled: false -RSpec/FactoryBot/FactoryClassName: - Enabled: false RSpec/HooksBeforeExamples: Enabled: false RSpec/ImplicitBlockExpectation: @@ -510,6 +513,12 @@ Capybara/SpecificFinders: Enabled: false Capybara/SpecificMatcher: Enabled: false +FactoryBot/ConsistentParenthesesStyle: + Enabled: false +FactoryBot/FactoryNameStyle: + Enabled: false +FactoryBot/SyntaxMethods: + Enabled: false Gemspec/DeprecatedAttributeAssignment: Enabled: false Gemspec/DevelopmentDependencies: @@ -610,28 +619,12 @@ RSpec/DuplicatedMetadata: Enabled: false RSpec/ExcessiveDocstringSpacing: Enabled: false -RSpec/FactoryBot/ConsistentParenthesesStyle: - Enabled: false -RSpec/FactoryBot/FactoryNameStyle: - Enabled: false -RSpec/FactoryBot/SyntaxMethods: - Enabled: false RSpec/IdenticalEqualityAssertion: Enabled: false RSpec/NoExpectationExample: Enabled: false RSpec/PendingWithoutReason: Enabled: false -RSpec/Rails/AvoidSetupHook: - Enabled: false -RSpec/Rails/HaveHttpStatus: - Enabled: false -RSpec/Rails/InferredSpecType: - Enabled: false -RSpec/Rails/MinitestAssertions: - Enabled: false -RSpec/Rails/TravelAround: - Enabled: false RSpec/RedundantAround: Enabled: false RSpec/SkipBlockInsideExample: @@ -642,6 +635,16 @@ RSpec/SubjectDeclaration: Enabled: false RSpec/VerifiedDoubleReference: Enabled: false +RSpecRails/AvoidSetupHook: + Enabled: false +RSpecRails/HaveHttpStatus: + Enabled: false +RSpecRails/InferredSpecType: + Enabled: false +RSpecRails/MinitestAssertions: + Enabled: false +RSpecRails/TravelAround: + Enabled: false Security/CompoundHash: Enabled: false Security/IoMethods: diff --git a/.typos.toml b/.typos.toml new file mode 100644 index 0000000..5c12561 --- /dev/null +++ b/.typos.toml @@ -0,0 +1,10 @@ +# Configure https://github.com/crate-ci/typos +[default.extend-words] +"facter" = "facter" + +[default] +extend-ignore-re = [ + "(?Rm)^.*(#|//)\\s*typos:ignore-line$", + "(?s)(#|//)\\s*typos:ignore-start.*?\\n\\s*(#|//)\\s*typos:ignore-end", + "(#|//)\\s*typos:ignore-next-line\\n.*" +] diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d36b8a..3f8ad60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. * Synced with [PDK][] and disabled Puppet 6 testing, since the package signing key is no longer valid. * Switched to Ruby 3.1 for automated testing since PDK no longer supports 2.7. +* Fixed a few spelling mistakes. [PDK]: https://www.puppet.com/docs/pdk/latest/pdk.html @@ -53,7 +54,7 @@ GitHub security advisory: [GHSA-8h8m-h98f-vv84] ### Changes As part of the security fix mentioned above, it became necessary to be more -agressive about ensuring that the owner and group of files in the installation +aggressive about ensuring that the owner and group of files in the installation are correct. dp-golang now deletes and recreates any Go installation it finds that has a file or directory with the wrong owner or group. diff --git a/Gemfile b/Gemfile index 4e7de03..441fe81 100644 --- a/Gemfile +++ b/Gemfile @@ -52,9 +52,12 @@ group :development do gem "pry", '~> 0.10', require: false gem "simplecov-console", '~> 0.9', require: false gem "puppet-debugger", '~> 1.6', require: false - gem "rubocop", '~> 1.50.0', require: false - gem "rubocop-performance", '= 1.16.0', require: false - gem "rubocop-rspec", '= 2.19.0', require: false + gem "rubocop", '~> 1.73.0', require: false + gem "rubocop-performance", '~> 1.24.0', require: false + gem "rubocop-rspec", '~> 3.5.0', require: false + gem "rubocop-rspec_rails", '~> 2.31.0', require: false + gem "rubocop-factory_bot", '~> 2.27.0', require: false + gem "rubocop-capybara", '~> 2.22.0', require: false gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] gem "bigdecimal", '< 3.2.2', require: false, platforms: [:mswin, :mingw, :x64_mingw] end @@ -71,10 +74,12 @@ group :system_tests do end gems = {} +bolt_version = ENV.fetch('BOLT_GEM_VERSION', nil) puppet_version = ENV.fetch('PUPPET_GEM_VERSION', nil) facter_version = ENV.fetch('FACTER_GEM_VERSION', nil) hiera_version = ENV.fetch('HIERA_GEM_VERSION', nil) +gems['bolt'] = location_for(bolt_version, nil, { source: gemsource_puppetcore }) gems['puppet'] = location_for(puppet_version, nil, { source: gemsource_puppetcore }) gems['facter'] = location_for(facter_version, nil, { source: gemsource_puppetcore }) gems['hiera'] = location_for(hiera_version, nil, {}) if hiera_version diff --git a/README.md b/README.md index 25475bc..5a2d85c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This [Puppet][] module has sane defaults to keep a standard installation simple, but is flexible enough to support automatic updates, multiple installations of -diferent versions, and running [Puppet as a non-root user][non-root]. +different versions, and running [Puppet as a non-root user][non-root]. [Puppet]: https://github.com/puppetlabs/puppet [non-root]: #running-puppet-as-a-non-root-user diff --git a/REFERENCE.md b/REFERENCE.md index 8d0fb49..dd675ba 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -16,7 +16,7 @@ ### Functions -* [`golang::latest_version`](#golang--latest_version): Get the lastest stable version number for Go +* [`golang::latest_version`](#golang--latest_version): Get the latest stable version number for Go * [`golang::state_file`](#golang--state_file): Figure out the default state file path for a given `$go_dir` ### Data types diff --git a/lib/puppet/functions/golang/latest_version.rb b/lib/puppet/functions/golang/latest_version.rb index 82ddf2e..48d30e9 100644 --- a/lib/puppet/functions/golang/latest_version.rb +++ b/lib/puppet/functions/golang/latest_version.rb @@ -4,7 +4,7 @@ require 'net/http' require 'uri' -# @summary Get the lastest stable version number for Go +# @summary Get the latest stable version number for Go # # Makes a request to the passed URL to find the latest stable version of Go. The # request will be cached for 10 minutes, so repeated calls to this function will @@ -31,7 +31,7 @@ def latest_version(url) if !@@golang_latest_version_cache[url] \ || time - @@golang_latest_version_cache[url][:time] >= 600 @@golang_latest_version_cache[url] = { - time:, + time: time, version: load_latest_version(url), } end diff --git a/metadata.json b/metadata.json index 6daba8c..358b1fd 100644 --- a/metadata.json +++ b/metadata.json @@ -85,5 +85,5 @@ ], "pdk-version": "3.4.0", "template-url": "https://github.com/danielparks/pdk-templates#main", - "template-ref": "heads/main-0-g1e26f60" + "template-ref": "heads/main-0-g8b32367" } diff --git a/release.rb b/release.rb index fb6b17e..a761558 100755 --- a/release.rb +++ b/release.rb @@ -155,7 +155,7 @@ def fix_links(root, path) IO.write(path, lines.join('')) end -# Huge kludge. Only works on unorderd lists at the moment. +# Huge kludge. Only works on unordered lists at the moment. def unwrap_markdown!(md) while md.gsub!(%r{^( *)([*+-])( +\S.+?)\n\1 +([^ *+-])}, '\1\2\3 \4') end @@ -273,8 +273,8 @@ def confirm_no_changes end run('git', 'commit', '-m', "Release #{version}: #{summary.chomp('.')}.", - dry_run:) -run('git', 'tag', "v#{version}", '-sm', <<~MSG.chomp, dry_run:) + dry_run: dry_run) +run('git', 'tag', "v#{version}", '-sm', <<~MSG.chomp, dry_run: dry_run) #{version}: #{summary} #{release_notes} @@ -283,10 +283,10 @@ def confirm_no_changes update_for_forge(metadata) run('pdk', 'build', '--force') -run('pdk', 'release', 'publish', dry_run:) +run('pdk', 'release', 'publish', dry_run: dry_run) # Reset Forge-specific changes -run('git', 'restore', '.', dry_run:) +run('git', 'restore', '.', dry_run: dry_run) # Add "## main branch" header to CHANGELOG.md insert_main_branch_header!(changelog) @@ -295,10 +295,10 @@ def confirm_no_changes run('git', 'add', 'CHANGELOG.md') run('git', 'commit', '-m', 'Add “## main branch” header back to CHANGELOG.md.', - dry_run:) + dry_run: dry_run) # Push release to GitHub -run('git', 'push', '--tags', 'origin', 'main', dry_run:) +run('git', 'push', '--tags', 'origin', 'main', dry_run: dry_run) unwrap_markdown!(release_notes) @@ -307,4 +307,4 @@ def confirm_no_changes '--notes', release_notes, "v#{version}", Dir["pkg/*-#{version}.tar.gz"].first, - dry_run:) + dry_run: dry_run) diff --git a/spec/classes/golang_spec.rb b/spec/classes/golang_spec.rb index e2e4755..42bad0b 100644 --- a/spec/classes/golang_spec.rb +++ b/spec/classes/golang_spec.rb @@ -4,7 +4,7 @@ describe 'golang' do let(:pre_condition) { <<~'PUPPET' } - # Overide golang::latest_version to avoid dependence on https://go.dev. + # Override golang::latest_version to avoid dependence on https://go.dev. function golang::latest_version($_url) { '1.0.0' } # Make deprecations testable with rspec-puppet. diff --git a/spec/defines/installation_spec.rb b/spec/defines/installation_spec.rb index 468bf26..1a412ef 100644 --- a/spec/defines/installation_spec.rb +++ b/spec/defines/installation_spec.rb @@ -4,7 +4,7 @@ describe 'golang::installation' do let(:pre_condition) { <<~'PUPPET' } - # Overide golang::latest_version to avoid dependence on https://go.dev. + # Override golang::latest_version to avoid dependence on https://go.dev. function golang::latest_version($_url) { '1.0.0' } PUPPET diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ae7c1f6..2f7fdae 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -26,7 +26,7 @@ begin require 'deep_merge' - default_facts.deep_merge!(YAML.safe_load(File.read(f), permitted_classes: [], permitted_symbols: [], aliases: true)) + default_facts.deep_merge!(YAML.safe_load_file(f, permitted_classes: [], permitted_symbols: [], aliases: true)) rescue StandardError => e RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" end