diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..4c140ce --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +version: 2 +updates: +# raise PRs for gem updates +- package-ecosystem: bundler + directory: "/" + schedule: + interval: daily + time: "13:00" + open-pull-requests-limit: 10 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..39261d7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,31 @@ +name: Release + +on: + push: + tags: + - '*' + +jobs: + release: + runs-on: ubuntu-latest + if: github.repository_owner == 'voxpupuli' + steps: + - uses: actions/checkout@v3 + - name: Install Ruby 3.0 + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.0' + bundler: 'none' + - name: Build gem + run: gem build *.gemspec + - name: Publish gem to rubygems.org + run: gem push *.gem + env: + GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_AUTH_TOKEN }}' + - name: Setup GitHub packages access + run: | + mkdir -p ~/.gem + echo ":github: Bearer ${{ secrets.GITHUB_TOKEN }}" >> ~/.gem/credentials + chmod 0600 ~/.gem/credentials + - name: Publish gem to GitHub packages + run: gem push --key github --host https://rubygems.pkg.github.com/${{ github.repository_owner }} *.gem diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..84487b1 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,37 @@ +name: Test + +on: + - pull_request + - push + +env: + BUNDLE_WITHOUT: release + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - ruby: "2.4" + - ruby: "2.5" + - ruby: "2.6" + - ruby: "2.7" + - ruby: "3.0" + - ruby: "3.1" + coverage: "yes" + env: + COVERAGE: ${{ matrix.coverage }} + name: Ruby ${{ matrix.ruby }} + steps: + - uses: actions/checkout@v3 + - name: Install Ruby ${{ matrix.ruby }} + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - name: Run tests + run: bundle exec rake spec + - name: Verify gem builds + run: gem build *.gemspec diff --git a/.gitignore b/.gitignore index 427187e..1d7b280 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,5 @@ /.bundle/ /vendor/gems/ /Gemfile.lock -*.swp -.DS_Store -*~ -.\#* -coverage/ +vendor/bundle +.vendor/ diff --git a/Gemfile b/Gemfile index e18725a..20e2ce6 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,12 @@ -source 'https://rubygems.org' +source ENV['GEM_SOURCE'] || 'https://rubygems.org' gemspec -gem 'simplecov' + +group :release do + gem 'github_changelog_generator', require: false +end + +group :coverage, optional: ENV['COVERAGE']!='yes' do + gem 'simplecov-console', :require => false + gem 'codecov', :require => false +end diff --git a/Rakefile b/Rakefile index 70a846d..9092454 100644 --- a/Rakefile +++ b/Rakefile @@ -2,4 +2,18 @@ require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) -task :default => :spec +task default: :spec + +begin + require 'rubygems' + require 'github_changelog_generator/task' + + GitHubChangelogGenerator::RakeTask.new :changelog do |config| + config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file." + config.exclude_labels = %w{duplicate question invalid wontfix wont-fix skip-changelog modulesync} + config.user = 'voxpupuli' + config.project = 'puppet-lint-param-types' + config.future_release = Gem::Specification.load("#{config.project}.gemspec").version + end +rescue LoadError +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4aa9e69..2871e8d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,29 @@ +# frozen_string_literal: true + +begin + require 'simplecov' + require 'simplecov-console' + require 'codecov' +rescue LoadError +else + SimpleCov.start do + track_files 'lib/**/*.rb' + + add_filter '/spec' + + enable_coverage :branch + + # do not track vendored files + add_filter '/vendor' + add_filter '/.vendor' + end + + SimpleCov.formatters = [ + SimpleCov::Formatter::Console, + SimpleCov::Formatter::Codecov, + ] +end + require 'puppet-lint' PuppetLint::Plugins.load_spec_helper