Skip to content

Commit

Permalink
Merge pull request #1001 from traylenator/rubo
Browse files Browse the repository at this point in the history
  • Loading branch information
smortex authored Sep 2, 2022
2 parents 261641d + ead03af commit e09c7e1
Show file tree
Hide file tree
Showing 139 changed files with 952 additions and 719 deletions.
7 changes: 3 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ If you have Ruby 2.x or want a specific version of Puppet,
you must set an environment variable such as:

```sh
export PUPPET_VERSION="~> 5.5.6"
export PUPPET_GEM_VERSION="~> 6.1.0"
```

You can install all needed gems for spec tests into the modules directory by
Expand Down Expand Up @@ -232,17 +232,16 @@ simple tests against it after applying the module. You can run this
with:

```sh
BEAKER_setfile=debian10-x64 bundle exec rake beaker
BEAKER_setfile=debian11-64 bundle exec rake beaker
```

You can replace the string `debian10` with any common operating system.
The following strings are known to work:

* ubuntu1604
* ubuntu1804
* ubuntu2004
* debian9
* debian10
* debian11
* centos7
* centos8

Expand Down
84 changes: 6 additions & 78 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,84 +7,12 @@ name: CI
on: pull_request

concurrency:
group: ${{ github.head_ref }}
group: ${{ github.ref_name }}
cancel-in-progress: true

jobs:
setup_matrix:
name: 'Setup Test Matrix'
runs-on: ubuntu-latest
timeout-minutes: 75
outputs:
puppet_unit_test_matrix: ${{ steps.get-outputs.outputs.puppet_unit_test_matrix }}
github_action_test_matrix: ${{ steps.get-outputs.outputs.github_action_test_matrix }}
env:
BUNDLE_WITHOUT: development:system_tests:release
steps:
- uses: actions/checkout@v2
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
bundler-cache: true
- name: Run static validations
run: bundle exec rake validate lint check
- name: Run rake rubocop
run: bundle exec rake rubocop
- name: Setup Test Matrix
id: get-outputs
run: bundle exec metadata2gha --use-fqdn --pidfile-workaround false

unit:
needs: setup_matrix
runs-on: ubuntu-latest
timeout-minutes: 75
strategy:
fail-fast: false
matrix:
include: ${{fromJson(needs.setup_matrix.outputs.puppet_unit_test_matrix)}}
env:
BUNDLE_WITHOUT: development:system_tests:release
PUPPET_VERSION: "~> ${{ matrix.puppet }}.0"
name: Puppet ${{ matrix.puppet }} (Ruby ${{ matrix.ruby }})
steps:
- uses: actions/checkout@v2
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run tests
run: bundle exec rake parallel_spec

acceptance:
needs: setup_matrix
runs-on: ubuntu-latest
env:
BUNDLE_WITHOUT: development:test:release
strategy:
fail-fast: false
matrix:
include: ${{fromJson(needs.setup_matrix.outputs.github_action_test_matrix)}}
name: ${{ matrix.puppet.name }} - ${{ matrix.setfile.name }}
steps:
- uses: actions/checkout@v2
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
bundler-cache: true
- name: Run tests
run: bundle exec rake beaker
env:
BEAKER_PUPPET_COLLECTION: ${{ matrix.puppet.collection }}
BEAKER_setfile: ${{ matrix.setfile.value }}

tests:
needs:
- unit
- acceptance
runs-on: ubuntu-latest
name: Test suite
steps:
- run: echo Test suite completed
puppet:
name: Puppet
uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v1
with:
pidfile_workaround: 'false'
32 changes: 10 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,14 @@ on:
tags:
- '*'

env:
BUNDLE_WITHOUT: development:test:system_tests

jobs:
deploy:
name: 'deploy to forge'
runs-on: ubuntu-latest
if: github.repository_owner == 'voxpupuli'
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true
- name: Build and Deploy
env:
# Configure secrets here:
# https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets
BLACKSMITH_FORGE_USERNAME: '${{ secrets.PUPPET_FORGE_USERNAME }}'
BLACKSMITH_FORGE_API_KEY: '${{ secrets.PUPPET_FORGE_API_KEY }}'
run: bundle exec rake module:push
release:
name: Release
uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v1
with:
allowed_owner: 'voxpupuli'
secrets:
# Configure secrets here:
# https://docs.github.com/en/actions/security-guides/encrypted-secrets
username: ${{ secrets.PUPPET_FORGE_USERNAME }}
api_key: ${{ secrets.PUPPET_FORGE_API_KEY }}
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

modulesync_config_version: '4.2.0'
modulesync_config_version: '5.3.0'
3 changes: 3 additions & 0 deletions .puppet-lint.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--fail-on-warnings
--no-parameter_documentation-check
--no-parameter_types-check
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

inherit_from: .rubocop_todo.yml
inherit_gem:
voxpupuli-test: rubocop.yml
4 changes: 4 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
# Is very common in this module
RSpec/MultipleMemoizedHelpers:
Enabled: false
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ WORKDIR /opt/puppet
# https://github.com/puppetlabs/puppet/blob/06ad255754a38f22fb3a22c7c4f1e2ce453d01cb/lib/puppet/provider/service/runit.rb#L39
RUN mkdir -p /etc/sv

ARG PUPPET_VERSION="~> 6.0"
ARG PUPPET_GEM_VERSION="~> 6.0"
ARG PARALLEL_TEST_PROCESSORS=4

# Cache gems
Expand Down
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

source ENV['GEM_SOURCE'] || "https://rubygems.org"
source ENV['GEM_SOURCE'] || 'https://rubygems.org'

group :test do
gem 'voxpupuli-test', '~> 2.5', :require => false
gem 'voxpupuli-test', '~> 5.4', :require => false
gem 'coveralls', :require => false
gem 'simplecov-console', :require => false
gem 'puppet_metadata', '~> 1.0', :require => false
Expand All @@ -21,14 +21,14 @@ end

group :release do
gem 'github_changelog_generator', '>= 1.16.1', :require => false if RUBY_VERSION >= '2.5'
gem 'voxpupuli-release', '>= 1.0.2', :require => false
gem 'voxpupuli-release', '>= 1.2.0', :require => false
gem 'puppet-strings', '>= 2.2', :require => false
end

gem 'rake', :require => false
gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test]

puppetversion = ENV['PUPPET_VERSION'] || '>= 6.0'
puppetversion = ENV['PUPPET_GEM_VERSION'] || '>= 6.0'
gem 'puppet', puppetversion, :require => false, :groups => [:test]

# vim: syntax=ruby
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

# Attempt to load voxupuli-test (which pulls in puppetlabs_spec_helper),
# Attempt to load voxpupuli-test (which pulls in puppetlabs_spec_helper),
# otherwise attempt to load it directly.
begin
require 'voxpupuli/test/rake'
Expand Down
4 changes: 3 additions & 1 deletion lib/facter/collectd_version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Fact: collectd_version
#
# Purpose: Retrieve collectd version if installed
Expand All @@ -10,7 +12,7 @@
setcode do
if Facter::Util::Resolution.which('collectd')
collectd_help = Facter::Util::Resolution.exec('collectd -h')
%r{^collectd ([\w\.]+), http://collectd\.org/}.match(collectd_help)[1]
%r{^collectd ([\w.]+), http://collectd\.org/}.match(collectd_help)[1]
end
end
end
2 changes: 2 additions & 0 deletions lib/facter/python_dir.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Fact: python_dir
#
# Purpose: Retrieve python package dir used by pip install
Expand Down
19 changes: 9 additions & 10 deletions lib/puppet/parser/functions/collectd_convert_processes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

Puppet::Parser::Functions.newfunction(:collectd_convert_processes, type: :rvalue, arity: 1, doc: <<-ENDDOC
Converts the array from the old style to define process or processmatch in the
processes plugin into a create_resources compatible hash which
Expand All @@ -7,27 +9,24 @@
[ { 'name' => 'foo', 'regex' => '.*' } , { 'name' => 'bar', 'regex' => '[0-9]+' }, "alone" ]
will be converted to
{ 'foo' => { 'regex' => '.*' } , 'bar' => { 'regex' => '[0-9]+' }, 'alone' => {} }
ENDDOC
) do |args|
if args.size != 1
raise(Puppet::ParseError, 'convert_process_array(): Needs exactly one argument')
end
ENDDOC
) do |args|
raise(Puppet::ParseError, 'convert_process_array(): Needs exactly one argument') if args.size != 1

if args[0].is_a?(Hash)
return args[0] # Keep normal hiera hash as-is
end

parray = args[0]
unless parray.is_a?(Array)
raise(Puppet::ParseError, 'convert_process_array(): Needs an array as argument')
end
raise(Puppet::ParseError, 'convert_process_array(): Needs an array as argument') unless parray.is_a?(Array)

phash = {}

parray.each do |p|
if p.is_a?(String)
case p
when String
phash[p] = {}
elsif p.is_a?(Hash)
when Hash
name = p.delete('name')
phash[name] = p
else
Expand Down
7 changes: 4 additions & 3 deletions spec/acceptance/class_plugin_disk_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

describe 'collectd::plugin::disk class' do
Expand Down Expand Up @@ -38,9 +40,8 @@
# module being loaded is an exercise for the reader.
# For CentOS 7 it works on my laptop but not in travis.
# disk plugin is probably very sensitive to environment.
if fact('os.family') == 'Redhat' && fact('os.release.major') == '8'
its(:stdout) { is_expected.to match %r{disk_time} }
end

its(:stdout) { is_expected.to match %r{disk_time} } if fact('os.family') == 'Redhat' && fact('os.release.major') == '8'
end
end
end
9 changes: 7 additions & 2 deletions spec/acceptance/class_plugin_load_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

describe 'collectd::plugin::load class' do
Expand Down Expand Up @@ -38,6 +40,7 @@
its(:stdout) { is_expected.not_to match %r{load/load-relative$} }
end
end

context 'report relative false' do
# Using puppet_apply as a helper
it 'works idempotently with no errors' do
Expand Down Expand Up @@ -77,6 +80,7 @@
its(:stdout) { is_expected.not_to match %r{load/load-relative$} }
end
end

context 'report relative true' do
# Using puppet_apply as a helper
it 'works idempotently with no errors' do
Expand Down Expand Up @@ -114,8 +118,9 @@
its(:exit_status) { is_expected.to eq 0 }
# https://github.com/voxpupuli/puppet-collectd/issues/901
# following will fail once 5.9.1 is released in EPEL8
if fact('osfamily') == 'RedHat' && fact('os.release.major') == '8' ||
fact('osfamily') == 'Debian' && fact('os.release.major') == '8'

if (fact('osfamily') == 'RedHat' && fact('os.release.major') == '8') ||
(fact('osfamily') == 'Debian' && fact('os.release.major') == '8')
its(:stdout) { is_expected.not_to match %r{load/load-relative$} }
its(:stdout) { is_expected.to match %r{load/load$} }
else
Expand Down
2 changes: 2 additions & 0 deletions spec/acceptance/class_plugin_write_http_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

describe 'collectd::plugin::write_http class' do
Expand Down
2 changes: 2 additions & 0 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

describe 'collectd class' do
Expand Down
2 changes: 2 additions & 0 deletions spec/acceptance/curl_json_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

describe 'curl_json defined type' do
Expand Down
2 changes: 2 additions & 0 deletions spec/acceptance/define_plugin_processes_process_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

describe 'collectd::plugin::processes::process' do
Expand Down
2 changes: 2 additions & 0 deletions spec/acceptance/define_plugin_processes_processmatch_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

describe 'collectd::plugin::processes::processmatchs' do
Expand Down
Loading

0 comments on commit e09c7e1

Please sign in to comment.