diff --git a/config_defaults.yml b/config_defaults.yml index cad772fe..7edebe30 100644 --- a/config_defaults.yml +++ b/config_defaults.yml @@ -9,40 +9,41 @@ .github/SECURITY.md: delete: true .github/workflows/ci.yml: - beaker_fact_matrix: {} excludes: [] pidfile_workaround: false - timeout_minutes: 40 + additional_packages: '' + acceptance_tests: true +# PDK creates this +.github/workflows/puppet-lint.yml: + delete: true .travis.yml: delete: true Jenkinsfile: delete: true Gemfile: - puppet_version: '>= 6.0' + puppet_version: '~> 7.24' required: ':test': - gem: voxpupuli-test - version: '~> 5.0' + version: '~> 6.0' - gem: coveralls - gem: simplecov-console - gem: puppet_metadata - version: '~> 1.0' + version: '~> 3.0' ':development': - gem: guard-rake - gem: overcommit version: '>= 0.39.1' ':system_tests': - gem: voxpupuli-acceptance - version: '~> 1.0' + version: '~> 2.0' ':release': - gem: github_changelog_generator version: '>= 1.16.1' - ruby-version: '2.5' - ruby-operator: '>=' - gem: voxpupuli-release - version: '>= 1.2.0' - - gem: puppet-strings - version: '>= 2.2' + version: '~> 3.0' + - gem: faraday-retry + version: '~> 2.1' Rakefile: config.user: ccin2p3 puppet_strings_patterns: [] @@ -61,6 +62,8 @@ spec/default_facts.yml: delete: true spec/classes/coverage_spec.rb: delete: true +spec/acceptance/nodesets/default.yml: + delete: true spec/acceptance/nodesets/archlinux-2-x64.yml: delete: true spec/acceptance/nodesets/centos-511-x64.yml: @@ -89,6 +92,16 @@ spec/acceptance/nodesets/fedora-26-x64.yml: delete: true spec/acceptance/nodesets/fedora-27-x64.yml: delete: true +spec/acceptance/nodesets/debian-7-x64.yml: + delete: true +spec/acceptance/nodesets/debian-8-x64.yml: + delete: true +spec/acceptance/nodesets/sles-11-x64.yml: + delete: true +spec/acceptance/nodesets/sles-12-x64.yml: + delete: true +spec/acceptance/nodesets/ubuntu-1604-x64.yml: + delete: true spec/acceptance/nodesets/ubuntu-server-1204-x64.yml: delete: true spec/acceptance/nodesets/ubuntu-server-1404-x64.yml: @@ -114,9 +127,12 @@ spec/acceptance/nodesets/ec2/ubuntu-1604-x64.yml: spec/acceptance/nodesets/ec2/windows-2016-base-x64.yml: delete: true spec/spec_helper.rb: + add_mocked_facts: true mock_with: false spec/spec_helper_acceptance.rb: unmanaged: true + configure_beaker: + modules: ':metadata' CONTRIBUTING.md: delete: true .yardopts: @@ -130,5 +146,19 @@ appveyor.yml: delete: true pdk.yaml: delete: true +.ruby-version: + delete: true +.tool-versions: + delete: true +CODE_OF_CONDUCT.md: + delete: true +.github/CODE_OF_CONDUCT.md: + delete: true +SECURITY.md: + delete: true +.github/SECURITY.md: + delete: true +Modulefile: + delete: true ... # vim: syntax=yaml diff --git a/moduleroot/.github/workflows/ci.yml.erb b/moduleroot/.github/workflows/ci.yml.erb index f000544e..2cfd1656 100644 --- a/moduleroot/.github/workflows/ci.yml.erb +++ b/moduleroot/.github/workflows/ci.yml.erb @@ -11,107 +11,21 @@ concurrency: cancel-in-progress: true jobs: - setup_matrix: - name: 'Setup Test Matrix' - runs-on: ubuntu-latest - timeout-minutes: <%= @configs['timeout_minutes'] %> - 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 <%= @configs['pidfile_workaround'] %> - - unit: - needs: setup_matrix - runs-on: ubuntu-latest - timeout-minutes: <%= @configs['timeout_minutes'] %> - 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 -<%- if Dir[File.join(@metadata[:workdir], 'spec', 'acceptance', '**', '*_spec.rb')].any? -%> - - 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)}} - <%- @configs['beaker_fact_matrix'].each do |option, values| -%> - <%= option %>: - <%- values.each do |value| -%> - - "<%= value %>" - <%- end -%> - <%- end -%> - <%- if @configs['excludes'].any? -%> - exclude: - <%- @configs['excludes'].each do |exclude| -%> - <%- exclude.each do |key, value| -%> - <%= key == exclude.first.first ? '-' : ' ' %> <%= key %>: "<%= value %>" - <%- end -%> - <%- end -%> - <%- end -%> - <%- - name = ['${{ matrix.puppet.name }}', '${{ matrix.setfile.name }}'] - @configs['beaker_fact_matrix'].each_key do |option| - name << "#{option.tr('_', ' ').capitalize} ${{ matrix.#{option} }}" - end - -%> - name: <%= name.join(' - ') %> - 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 }} - <%- @configs['beaker_fact_matrix'].keys.each do |fact| -%> - BEAKER_FACTER_<%= fact.upcase %>: ${{ matrix.<%= fact %> }} - <%- end -%> + puppet: + name: Puppet +<%- if @configs['acceptance_tests'] && Dir[File.join(@metadata[:workdir], 'spec', 'acceptance', '**', '*_spec.rb')].any? -%> + uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v1 + with: + pidfile_workaround: '<%= @configs['pidfile_workaround'] %>' +<%- else -%> + uses: voxpupuli/gha-puppet/.github/workflows/basic.yml@v1 +<%- if @configs.key?('rubocop') || !@configs['additional_packages'].empty? -%> + with: +<%- end -%> +<%- end -%> +<%- unless @configs['additional_packages'].empty? -%> + additional_packages: '<%= @configs['additional_packages'] %>' +<%- end -%> +<%- if @configs.key?('rubocop') -%> + rubocop: <%= @configs['rubocop'] %> <%- end -%> - - tests: - needs: - - unit - <%- if Dir[File.join(@metadata[:workdir], 'spec', 'acceptance', '**', '*_spec.rb')].any? -%> - - acceptance - <%- end -%> - runs-on: ubuntu-latest - name: Test suite - steps: - - run: echo Test suite completed diff --git a/moduleroot/.github/workflows/release.yml.erb b/moduleroot/.github/workflows/release.yml.erb index 20f6828b..464edae0 100644 --- a/moduleroot/.github/workflows/release.yml.erb +++ b/moduleroot/.github/workflows/release.yml.erb @@ -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 == '<%= @configs[:namespace] %>' - 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: '<%= @configs[:namespace] %>' + 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 }} diff --git a/moduleroot/.gitignore.erb b/moduleroot/.gitignore.erb index 6e230360..df67d1dd 100644 --- a/moduleroot/.gitignore.erb +++ b/moduleroot/.gitignore.erb @@ -1,26 +1,26 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -pkg/ -Gemfile.lock -Gemfile.local -vendor/ -.vendor/ -spec/fixtures/manifests/ -spec/fixtures/modules/ -.vagrant/ -.bundle/ -.ruby-version -coverage/ -log/ -.idea/ -.dependencies/ -.librarian/ -Puppetfile.lock +/pkg/ +/Gemfile.lock +/Gemfile.local +/vendor/ +/.vendor/ +/spec/fixtures/manifests/ +/spec/fixtures/modules/ +/.vagrant/ +/.bundle/ +/.ruby-version +/coverage/ +/log/ +/.idea/ +/.dependencies/ +/.librarian/ +/Puppetfile.lock *.iml .*.sw? -.yardoc/ -Guardfile +/.yardoc/ +/Guardfile <% if ! @configs['paths'].nil? -%> <% @configs['paths'].each do |path| -%> <%= path %> diff --git a/moduleroot/.msync.yml.erb b/moduleroot/.msync.yml.erb index a83abd9b..b929160c 100644 --- a/moduleroot/.msync.yml.erb +++ b/moduleroot/.msync.yml.erb @@ -2,4 +2,4 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -modulesync_config_version: '5.1.0' +modulesync_config_version: '6.0.0' diff --git a/moduleroot/.pmtignore.erb b/moduleroot/.pmtignore.erb index 49b2fd25..71feddc9 100644 --- a/moduleroot/.pmtignore.erb +++ b/moduleroot/.pmtignore.erb @@ -1,40 +1,40 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -docs/ -pkg/ -Gemfile -Gemfile.lock -Gemfile.local -vendor/ -.vendor/ -spec/ -Rakefile -.vagrant/ -.bundle/ -.ruby-version -coverage/ -log/ -.idea/ -.dependencies/ -.github/ -.librarian/ -Puppetfile.lock +/docs/ +/pkg/ +/Gemfile +/Gemfile.lock +/Gemfile.local +/vendor/ +/.vendor/ +/spec/ +/Rakefile +/.vagrant/ +/.bundle/ +/.ruby-version +/coverage/ +/log/ +/.idea/ +/.dependencies/ +/.github/ +/.librarian/ +/Puppetfile.lock *.iml -.editorconfig -.fixtures.yml -.gitignore -.msync.yml -.overcommit.yml -.pmtignore -.rspec -.rspec_parallel -.rubocop.yml -.sync.yml +/.editorconfig +/.fixtures.yml +/.gitignore +/.msync.yml +/.overcommit.yml +/.pmtignore +/.rspec +/.rspec_parallel +/.rubocop.yml +/.sync.yml .*.sw? -.yardoc/ -.yardopts -Dockerfile +/.yardoc/ +/.yardopts +/Dockerfile <% if ! @configs['paths'].nil? -%> <% @configs['paths'].each do |path| -%> <%= path %> diff --git a/moduleroot/.rubocop.yml.erb b/moduleroot/.rubocop.yml.erb index aebb8e56..9d599663 100644 --- a/moduleroot/.rubocop.yml.erb +++ b/moduleroot/.rubocop.yml.erb @@ -2,11 +2,11 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ +<% if File.exist?(File.join(@metadata[:workdir], '.rubocop_todo.yml')) -%> +inherit_from: .rubocop_todo.yml +<% end -%> inherit_gem: voxpupuli-test: rubocop.yml - -Style/TrailingCommaInArguments: - EnforcedStyleForMultiline: consistent_comma - -Style/WordArray: - EnforcedStyle: brackets +<% if @configs['extra'] -%> +<%= @configs['extra'].to_yaml.sub(/\A---\n/, '') -%> +<% end -%> diff --git a/moduleroot/Gemfile.erb b/moduleroot/Gemfile.erb index c12ff6f7..a67b4685 100644 --- a/moduleroot/Gemfile.erb +++ b/moduleroot/Gemfile.erb @@ -1,7 +1,7 @@ # 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' <% groups = {} -%> <% (@configs['required'].keys + ((@configs['optional'] || {}).keys)).uniq.each do |key| -%> @@ -35,7 +35,7 @@ end gem 'rake', :require => false gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test] -puppetversion = ENV['PUPPET_VERSION'] || '<%= @configs['puppet_version'] %>' +puppetversion = ENV['PUPPET_GEM_VERSION'] || '<%= @configs['puppet_version'] %>' gem 'puppet', puppetversion, :require => false, :groups => [:test] # vim: syntax=ruby diff --git a/moduleroot/Rakefile.erb b/moduleroot/Rakefile.erb index 0ffdf4e8..0f378b2c 100644 --- a/moduleroot/Rakefile.erb +++ b/moduleroot/Rakefile.erb @@ -24,6 +24,13 @@ end begin require 'voxpupuli/release/rake_tasks' rescue LoadError + # voxpupuli-release not present +else + GCGConfig.user = '<%= @configs['config.user'] || @configs[:namespace] %>' + GCGConfig.project = '<%= @configs['config.project'] || @configs[:puppet_module] %>' + <%- if @configs['config.tag_pattern'] -%> + GCGConfig.tag_pattern = '<%= @configs['config.tag_pattern'] -%>' + <%- end -%> end desc "Run main 'test' task and report merged results to coveralls" @@ -37,36 +44,4 @@ task test_with_coveralls: [:test] do end end -desc 'Generate REFERENCE.md' -task :reference, [:debug, :backtrace] do |t, args| - patterns = '<%= @configs['puppet_strings_patterns'].join(" ") %>' - Rake::Task['strings:generate:reference'].invoke(patterns, args[:debug], args[:backtrace]) -end - -begin - require 'github_changelog_generator/task' - require 'puppet_blacksmith' - GitHubChangelogGenerator::RakeTask.new :changelog do |config| - metadata = Blacksmith::Modulefile.new - config.future_release = "v#{metadata.version}" if metadata.version =~ /^\d+\.\d+.\d+$/ - config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not affect the functionality of the module." - config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog} - config.user = '<%= @configs['config.user'] -%>' - config.project = "puppet-#{metadata.metadata['name'].split('-').last}" - end - - # Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715 - require 'rbconfig' - if RbConfig::CONFIG['host_os'] =~ /linux/ - task :changelog do - puts 'Fixing line endings...' - changelog_file = File.join(__dir__, 'CHANGELOG.md') - changelog_txt = File.read(changelog_file) - new_contents = changelog_txt.gsub(%r{\r\n}, "\n") - File.open(changelog_file, "w") {|file| file.puts new_contents } - end - end - -rescue LoadError -end # vim: syntax=ruby diff --git a/moduleroot/spec/spec_helper.rb.erb b/moduleroot/spec/spec_helper.rb.erb index d2c508f4..f3178f75 100644 --- a/moduleroot/spec/spec_helper.rb.erb +++ b/moduleroot/spec/spec_helper.rb.erb @@ -20,6 +20,10 @@ RSpec.configure do |c| c.hiera_config = <%= @configs['hiera_config'] %> end <%- end -%> +<%- if @configs['add_mocked_facts'] -%> + +add_mocked_facts! +<%- end -%> if File.exist?(File.join(__dir__, 'default_module_facts.yml')) facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml'))) diff --git a/moduleroot/spec/spec_helper_acceptance.rb.erb b/moduleroot/spec/spec_helper_acceptance.rb.erb index d3a6e23c..570755a6 100644 --- a/moduleroot/spec/spec_helper_acceptance.rb.erb +++ b/moduleroot/spec/spec_helper_acceptance.rb.erb @@ -5,6 +5,8 @@ require 'voxpupuli/acceptance/spec_helper_acceptance' -configure_beaker +<%- unless @configs['configure_beaker'].nil? -%> +configure_beaker(modules: <%= @configs['configure_beaker']['modules'] || ':metadata' %>) +<%- end -%> Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f }