diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab42212..ecc396e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,79 +1,79 @@ name: CI on: pull_request: schedule: - cron: '4 4 * * *' jobs: setup_matrix: if: github.event_name != 'schedule' || github.repository_owner == 'theforeman' name: 'Setup Test Matrix' runs-on: ubuntu-latest outputs: beaker_setfiles: ${{ steps.get_outputs.outputs.beaker_setfiles }} puppet_major_versions: ${{ steps.get_outputs.outputs.puppet_major_versions }} puppet_unit_test_matrix: ${{ steps.get_outputs.outputs.puppet_unit_test_matrix }} env: - BUNDLE_WITHOUT: development:release + BUNDLE_WITHOUT: development:system_tests:release steps: - uses: actions/checkout@v2 - name: Setup ruby uses: ruby/setup-ruby@v1 with: ruby-version: '2.7' bundler-cache: true - name: Run rake check run: bundle exec rake check - name: Run rake validate run: bundle exec rake validate - name: Run rake lint run: bundle exec rake lint - name: Setup Test Matrix id: get_outputs run: bundle exec metadata2gha --use-fqdn --pidfile-workaround true unit: needs: setup_matrix runs-on: ubuntu-latest 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: Unit / 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: setfile: ${{fromJson(needs.setup_matrix.outputs.beaker_setfiles)}} puppet: ${{fromJson(needs.setup_matrix.outputs.puppet_major_versions)}} name: Acceptance / ${{ matrix.puppet.name }} - ${{ matrix.setfile.name }} steps: - uses: actions/checkout@v2 - name: Setup ruby uses: ruby/setup-ruby@v1 with: ruby-version: '2.7' bundler-cache: true - name: Run tests run: bundle exec rake beaker env: BEAKER_PUPPET_COLLECTION: ${{ matrix.puppet.collection }} BEAKER_setfile: ${{ matrix.setfile.value }} diff --git a/Gemfile b/Gemfile index 964e3e3..a9386fd 100644 --- a/Gemfile +++ b/Gemfile @@ -1,23 +1,24 @@ # This file is managed centrally by modulesync # https://github.com/theforeman/foreman-installer-modulesync source 'https://rubygems.org' gem 'puppet', ENV.key?('PUPPET_VERSION') ? "~> #{ENV['PUPPET_VERSION']}" : '>= 5.5', groups: ['development', 'test'] gem 'rake' gem 'kafo_module_lint', {"groups"=>["test"]} gem 'puppet-lint-empty_string-check', {"groups"=>["test"]} gem 'puppet-lint-file_ensure-check', {"groups"=>["test"]} gem 'puppet-lint-param-docs', '>= 1.3.0', {"groups"=>["test"]} gem 'puppet-lint-spaceship_operator_without_tag-check', {"groups"=>["test"]} gem 'puppet-lint-strict_indent-check', {"groups"=>["test"]} gem 'puppet-lint-undef_in_function-check', {"groups"=>["test"]} -gem 'voxpupuli-test', '~> 1.4' +gem 'voxpupuli-test', '~> 1.4', {"groups"=>["test"]} gem 'github_changelog_generator', '>= 1.15.0', {"groups"=>["development"]} gem 'puppet_metadata', '~> 0.3' gem 'puppet-blacksmith', '>= 6.0.0', {"groups"=>["development"]} gem 'voxpupuli-acceptance', '~> 1.0', {"groups"=>["system_tests"]} +gem 'puppetlabs_spec_helper', {"groups"=>["system_tests"]} gem 'hocon' # vim:ft=ruby diff --git a/Rakefile b/Rakefile index 69a143c..c182b84 100644 --- a/Rakefile +++ b/Rakefile @@ -1,43 +1,59 @@ # This file is managed centrally by modulesync # https://github.com/theforeman/foreman-installer-modulesync -require 'voxpupuli/test/rake' +# Attempt to load voxupuli-test (which pulls in puppetlabs_spec_helper), +# otherwise attempt to load it directly. +begin + require 'voxpupuli/test/rake' +rescue LoadError + begin + require 'puppetlabs_spec_helper/rake_tasks' + rescue LoadError + end +end -# We use fixtures in our modules, which is not the default -task :beaker => 'spec_prep' +# load optional tasks for acceptance +# only available if gem group releases is installed +begin + require 'voxpupuli/acceptance/rake' +rescue LoadError +else + # We use fixtures in our modules, which is not the default + task :beaker => 'spec_prep' +end # blacksmith isn't always present, e.g. on Travis with --without development begin require 'puppet_blacksmith/rake_tasks' Blacksmith::RakeTask.new do |t| t.tag_pattern = "%s" t.tag_message_pattern = "Version %s" t.tag_sign = true end rescue LoadError end begin require 'github_changelog_generator/task' # https://github.com/github-changelog-generator/github-changelog-generator/issues/313 module GitHubChangelogGeneratorExtensions def compound_changelog super.gsub(/(fixes|fixing|refs) \\#(\d+)/i, '\1 [\\#\2](https://projects.theforeman.org/issues/\2)') end end class GitHubChangelogGenerator::Generator prepend GitHubChangelogGeneratorExtensions end GitHubChangelogGenerator::RakeTask.new :changelog do |config| raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil? metadata = JSON.load(File.read('metadata.json')) config.user = 'theforeman' config.project = "puppet-#{metadata['name'].split('-').last}" config.future_release = metadata['version'] config.exclude_labels = ['duplicate', 'question', 'invalid', 'wontfix', 'Modulesync', 'skip-changelog'] end rescue LoadError end