diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..d7f227672 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,29 @@ +name: "ci" + +on: + pull_request: + branches: + - "main" + workflow_dispatch: + +jobs: + spec: + strategy: + fail-fast: false + matrix: + ruby_version: + - "2.5" + - "2.7" + puppet_gem_version: + - '~> 6.0' + - '~> 7.0' + runs_on: + - "ubuntu-latest" + - "windows-latest" + name: "spec (${{ matrix.runs_on }} ruby ${{ matrix.ruby_version }} | puppet ${{matrix.puppet_gem_version}})" + uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main" + secrets: "inherit" + with: + ruby_version: ${{ matrix.ruby_version }} + puppet_gem_version: ${{ matrix.puppet_gem_version }} + runs_on: ${{ matrix.runs_on }} diff --git a/.github/workflows/labeller.yml b/.github/workflows/labeller.yml new file mode 100644 index 000000000..047bbf823 --- /dev/null +++ b/.github/workflows/labeller.yml @@ -0,0 +1,22 @@ +name: community-labeller + +on: + issues: + types: + - "opened" + pull_request_target: + types: + - "opened" + +jobs: + label: + runs-on: "ubuntu-latest" + steps: + + - uses: "puppetlabs/community-labeller@v0" + name: "Label issues or pull requests" + with: + label_name: "community" + label_color: '5319e7' + org_membership: "puppetlabs" + token: ${{ secrets.IAC_COMMUNITY_LABELER }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 937dd8eed..000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,37 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: CI - -# Controls when the workflow will run -on: - # Triggers the workflow on push or pull request events but only for the master branch - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - spec: - strategy: - fail-fast: false - matrix: - os: ["ubuntu-latest", "windows-latest"] - ruby: - - "2.5" - - "2.7" - puppet: - - '~> 6.0' - - '~> 7.0' - name: RSpec - ${{ matrix.os }} - Ruby ${{ matrix.ruby }} - Puppet ${{ matrix.puppet }} - runs-on: ${{ matrix.os }} - env: - COVERAGE: yes - PUPPET_GEM_VERSION: ${{ matrix.puppet }} - steps: - - uses: actions/checkout@v2 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby }} - bundler-cache: true - - run: bundle exec rake test - diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 000000000..ed5439a80 --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,28 @@ +name: "nightly" + +on: + schedule: + - cron: "0 0 * * *" + workflow_dispatch: + +jobs: + spec: + strategy: + fail-fast: false + matrix: + ruby_version: + - "2.5" + - "2.7" + puppet_gem_version: + - '~> 6.0' + - '~> 7.0' + runs_on: + - "ubuntu-latest" + - "windows-latest" + name: "spec (${{ matrix.runs_on }} ruby ${{ matrix.ruby_version }} | puppet ${{matrix.puppet_gem_version}})" + uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main" + secrets: "inherit" + with: + ruby_version: ${{ matrix.ruby_version }} + puppet_gem_version: ${{ matrix.puppet_gem_version }} + runs_on: ${{ matrix.runs_on }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..92338dc29 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,16 @@ +name: "release" + +on: + workflow_dispatch: + inputs: + target: + description: "The target for the release. This can be a commit sha or a branch." + required: false + default: "main" + +jobs: + release: + uses: "puppetlabs/cat-github-actions/.github/workflows/gem_release.yml@main" + with: + target: "${{ github.event.inputs.target }}" + secrets: "inherit" diff --git a/.github/workflows/release_prep.yml b/.github/workflows/release_prep.yml new file mode 100644 index 000000000..be3080f78 --- /dev/null +++ b/.github/workflows/release_prep.yml @@ -0,0 +1,20 @@ +name: "release prep" + +on: + workflow_dispatch: + inputs: + target: + description: "The target for the release. This can be a commit sha or a branch." + required: false + default: "main" + version: + description: "Version of gem to be released." + required: true + +jobs: + release_prep: + uses: "puppetlabs/cat-github-actions/.github/workflows/gem_release_prep.yml@main" + with: + target: "${{ github.event.inputs.target }}" + version: "${{ github.events.inputs.version }}" + secrets: "inherit" diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 000000000..73b76390e --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,4 @@ +# Silencing rubocop warnings until https://tickets.puppetlabs.com/browse/CONT-725 +# is completed +AllCops: + DisabledByDefault: true diff --git a/Gemfile b/Gemfile index 7e44bfa4e..4d66e7a54 100644 --- a/Gemfile +++ b/Gemfile @@ -17,9 +17,9 @@ if RUBY_VERSION =~ /^1\.?9/ gem 'ffi', '<= 1.9.14' end -gem 'rspec', *location_for(ENV['RSPEC_GEM_VERSION'] || '~> 3.0') -gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION'] || '~> 7.0') -gem 'facter', *location_for(ENV['FACTER_GEM_VERSION'] || '~> 4.0') +gem 'rspec', *location_for(!ENV['RSPEC_GEM_VERSION']&.empty? ? ENV['RSPEC_GEM_VERSION'] : '~> 3.0') +gem 'puppet', *location_for(!ENV['PUPPET_GEM_VERSION']&.empty? ? ENV['PUPPET_GEM_VERSION'] : '~> 7.0') +gem 'facter', *location_for(!ENV['FACTER_GEM_VERSION']&.empty? ? ENV['FACTER_GEM_VERSION'] : '~> 4.0') gem 'pry', :group => :development if RUBY_VERSION =~ /^1\.?/ @@ -38,8 +38,9 @@ if RUBY_VERSION =~ /^1\.?9/ elsif RUBY_VERSION =~ /^1\.?8/ gem 'json_pure', '< 2.0.0' else - gem 'rubocop' - gem 'rubocop-rspec', '~> 1.6' if (RUBY_VERSION >= '2.3.0' || RUBY_VERSION >= '23') + gem "rubocop", '= 1.6.1', require: false + gem "rubocop-performance", '= 1.9.1', require: false + gem "rubocop-rspec", '= 2.0.1', require: false gem 'sync' if (RUBY_VERSION >= '2.7.0') end diff --git a/Rakefile b/Rakefile index 6edf9c16c..cebb94086 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,6 @@ require 'rake' require 'rspec/core/rake_task' +require 'rubocop/rake_task' require 'bundler/gem_tasks' require 'fileutils' require 'puppet' @@ -89,3 +90,7 @@ task :test do Rake::Task['test:teardown'].invoke end end + +RuboCop::RakeTask.new(:rubocop) do |task| + task.options = %w[-D -S -E] +end diff --git a/lib/rspec-puppet/version.rb b/lib/rspec-puppet/version.rb new file mode 100644 index 000000000..f0e7fbb09 --- /dev/null +++ b/lib/rspec-puppet/version.rb @@ -0,0 +1,5 @@ +#frozen_string_literal: true + +module RSpecPuppet + VERSION ||= '2.12.0' +end diff --git a/rspec-puppet.gemspec b/rspec-puppet.gemspec index 4c90d8dbe..c460a32c7 100644 --- a/rspec-puppet.gemspec +++ b/rspec-puppet.gemspec @@ -1,6 +1,10 @@ +lib = File.expand_path('lib', __dir__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require 'rspec-puppet/version' + Gem::Specification.new do |s| s.name = 'rspec-puppet' - s.version = '2.12.0' + s.version = RSpecPuppet::VERSION s.homepage = 'https://github.com/puppetlabs/rspec-puppet/' s.summary = 'RSpec tests for your Puppet manifests' s.description = 'RSpec tests for your Puppet manifests' diff --git a/spec/classes/test_registry_spec.rb b/spec/classes/test_registry_spec.rb index 35cb981a3..5e1f3c67a 100644 --- a/spec/classes/test_registry_spec.rb +++ b/spec/classes/test_registry_spec.rb @@ -1,11 +1,7 @@ require 'spec_helper' describe 'test::registry', :if => Puppet.version.to_f >= 4.0 do - let(:facts) do - { - :operatingsystem => 'windows', - } - end - + let(:facts) { {:os => { :name => 'windows' } } } + it { should compile.with_all_deps } end