diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8a23bc4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,69 @@ +name: CI + +on: + pull_request: + push: + branches: + - master + tags: + - v* + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + ruby: + - 2.5 + - 2.6 + - 2.7 + + steps: + - uses: actions/checkout@v2 + + - name: Setup Redis + uses: shogo82148/actions-setup-redis@v1 + with: + redis-version: '5.x' + + - name: Set up Ruby + uses: actions/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + architecture: 'x64' + + - name: Setup bundler + run: | + gem install bundler --no-doc + bundle config path vendor/bundle + + - name: Bundler cache + uses: actions/cache@v2 + with: + path: vendor/bundle + key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: | + ${{ runner.os }}-gems- + + - name: Setup gems + run: bundle install --jobs 4 + + - name: Rubocop + run: bundle exec rubocop + + - name: RSpec + run: bundle exec rspec + + publish: + if: contains(github.ref, 'refs/tags/v') + needs: build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Release Gem + uses: CvX/publish-rubygems-action@master + env: + RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}} diff --git a/.gitignore b/.gitignore index 3a9dba3..709ee91 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,3 @@ Gemfile.lock .DS_Store *.swp - -.rubocop-https---raw-githubusercontent-com-discourse-discourse-master--rubocop-yml diff --git a/.rubocop.yml b/.rubocop.yml index 0ca7eff..d46296c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1 +1,2 @@ -inherit_from: https://raw.githubusercontent.com/discourse/discourse/master/.rubocop.yml +inherit_gem: + rubocop-discourse: default.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0775c67..0000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: ruby -rvm: - - ruby-head - - 2.5 - - 2.6 - -before_install: - - gem install bundler - -cache: bundler -sudo: false - -services: - - redis-server - -matrix: - allow_failures: - - rvm: ruby-head diff --git a/Gemfile b/Gemfile index 93db27d..ace0186 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,4 @@ +# frozen_string_literal: true source 'https://rubygems.org' git_source(:github) { 'https://github.com/discourse/mini_scheduler' } diff --git a/Guardfile b/Guardfile index 75d88ab..99997eb 100644 --- a/Guardfile +++ b/Guardfile @@ -1,3 +1,4 @@ +# frozen_string_literal: true # A sample Guardfile # More info at https://github.com/guard/guard#readme diff --git a/Rakefile b/Rakefile index c92b11e..d2e1df2 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,19 @@ -require "bundler/gem_tasks" +#!/usr/bin/env rake +# frozen_string_literal: true + require "rspec/core/rake_task" +require 'bundler' + +begin + Bundler.setup :default, :development + Bundler::GemHelper.install_tasks +rescue Bundler::BundlerError => error + $stderr.puts error.message + $stderr.puts "Run `bundle install` to install missing gems" + exit error.status_code +end RSpec::Core::RakeTask.new(:spec) -task default: :spec +desc "Default: run tests" +task default: [ :spec ] diff --git a/mini_scheduler.gemspec b/mini_scheduler.gemspec index 8808ff5..4382b72 100644 --- a/mini_scheduler.gemspec +++ b/mini_scheduler.gemspec @@ -15,11 +15,7 @@ Gem::Specification.new do |spec| spec.homepage = "https://github.com/discourse/mini_scheduler" spec.license = "MIT" - # Specify which files should be added to the gem when it is released. - # The `git ls-files -z` loads the files in the RubyGem that have been added into git. - spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do - `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } - end + spec.files = `git ls-files`.split($/).reject { |s| s =~ /^(spec|\.)/ } spec.require_paths = ["lib"] spec.add_dependency "sidekiq" @@ -32,4 +28,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency "guard-rspec" spec.add_development_dependency "mock_redis" spec.add_development_dependency "rake" + spec.add_development_dependency 'rubocop-discourse' end