diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index e1da6a36..00000000 --- a/.coveralls.yml +++ /dev/null @@ -1 +0,0 @@ -service-name: travis-pro diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..7e8da23c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,80 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + test: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + ruby: [ ruby-2.4, ruby-2.5, ruby-2.6, ruby-2.7, jruby-9.2.11 ] + os: [ ubuntu-latest, macos-latest, windows-latest ] + + steps: + - uses: actions/checkout@v2 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + + - uses: actions/cache@v1 + with: + path: vendor/bundle + key: bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby }}- + + - name: bundle install + run: | + bundle config set path "vendor/bundle" + bundle config set without "development" + bundle install --jobs 4 + + - run: bundle exec rspec --format progress --force-colour + + - name: Prepare Coveralls test coverage report + uses: coverallsapp/github-action@v1.1.2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + flag-name: "${{ matrix.ruby }} @${{ matrix.os }}" + path-to-lcov: ./coverage/lcov/lcov.info + parallel: true + + coveralls: + needs: test + runs-on: ubuntu-latest + steps: + - name: Finalize Coveralls test coverage report + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + parallel-finished: true + + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.4 + + - uses: actions/cache@v1 + with: + path: vendor/bundle + key: bundle-use-ruby-lint-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: bundle-use-ruby-lint- + + - name: bundle install + run: | + bundle config set path "vendor/bundle" + bundle config set without "development" + bundle install --jobs 4 + + - run: bundle exec rubocop --color + - run: bundle exec rake verify_measurements diff --git a/.gitignore b/.gitignore index a9caac79..d13151b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,19 +1,15 @@ *.gem -.bundle .config .rvmrc -.ruby-version .yardoc -Gemfile.lock InstalledFiles _yardoc -coverage + +.bundle +.ruby-version doc -lib/bundler/man -measurement +coverage pkg -rdoc -spec/reports -test/tmp -test/version_tmp +spec/examples.txt tmp +Gemfile.lock diff --git a/.rspec b/.rspec index d3ec40e0..c99d2e73 100644 --- a/.rspec +++ b/.rspec @@ -1,5 +1 @@ ---backtrace ---color ---format=documentation ---order random --require spec_helper diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a6624335..00000000 --- a/.travis.yml +++ /dev/null @@ -1,37 +0,0 @@ -language: ruby - -cache: bundler - -before_install: - - gem update --system - - gem --version - - gem install bundler - - bundle --version - -install: bundle install --without development doc - -script: bundle exec rake - -env: JRUBY_OPTS="$JRUBY_OPTS --debug" - -rvm: - # Include JRuby first because it takes the longest - - jruby-9.2.11.0 - - 2.4 - - 2.5 - - 2.6 - - 2.7 - -matrix: - fast_finish: true - include: - # Only run RuboCop and Yardstick metrics on the latest Ruby - - rvm: 2.7 - env: SUITE="rubocop" - - rvm: 2.7 - env: SUITE="yardstick" - -branches: - only: - - master - - 4-x-stable diff --git a/Gemfile b/Gemfile index a8e938bf..d11947e2 100644 --- a/Gemfile +++ b/Gemfile @@ -10,20 +10,21 @@ group :development do gem "nokogiri", :require => false gem "pry", :require => false - platform :ruby_20 do - gem "pry-debugger", :require => false - gem "pry-stack_explorer", :require => false + # RSpec formatter + gem "fuubar", :require => false + + platform :mri do + gem "pry-byebug" end end group :test do - gem "activemodel", :require => false # Used by certificate_authority gem "certificate_authority", :require => false gem "backports" - gem "coveralls", :require => false - gem "simplecov", ">= 0.9" + gem "simplecov", :require => false + gem "simplecov-lcov", :require => false gem "rspec", "~> 3.0" gem "rspec-its" diff --git a/Rakefile b/Rakefile index 226fd48a..ac1b2359 100644 --- a/Rakefile +++ b/Rakefile @@ -61,12 +61,4 @@ task :generate_status_codes do end end -if ENV["CI"].nil? - task :default => %i[spec rubocop verify_measurements] -else - case ENV["SUITE"] - when "rubocop" then task :default => :rubocop - when "yardstick" then task :default => :verify_measurements - else task :default => :spec - end -end +task :default => %i[spec rubocop verify_measurements] diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b2aef2d7..1bb40781 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,19 +1,7 @@ # frozen_string_literal: true -require "simplecov" -require "coveralls" - -SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new( - [ - SimpleCov::Formatter::HTMLFormatter, - Coveralls::SimpleCov::Formatter - ] -) - -SimpleCov.start do - add_filter "/spec/" - minimum_coverage 80 -end +require_relative "./support/simplecov" +require_relative "./support/fuubar" unless ENV["CI"] require "http" require "rspec/its" @@ -40,6 +28,13 @@ mocks.verify_partial_doubles = true end + # This option will default to `:apply_to_host_groups` in RSpec 4 (and will + # have no way to turn it off -- the option exists only for backwards + # compatibility in RSpec 3). It causes shared context metadata to be + # inherited by the metadata hash of host groups and examples, rather than + # triggering implicit auto-inclusion in groups with matching metadata. + config.shared_context_metadata_behavior = :apply_to_host_groups + # These two settings work together to allow you to limit a spec run # to individual examples or groups you care about by tagging them with # `:focus` metadata. When nothing is tagged with `:focus`, all examples @@ -48,17 +43,22 @@ config.filter_run_excluding :flaky if defined?(JRUBY_VERSION) && ENV["CI"] config.run_all_when_everything_filtered = true - # Limits the available syntax to the non-monkey patched syntax that is recommended. - # For more details, see: - # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax - # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ - # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching - config.disable_monkey_patching! - # This setting enables warnings. It's recommended, but in some cases may # be too noisy due to issues in dependencies. config.warnings = 0 == ENV["GUARD_RSPEC"].to_i + # Allows RSpec to persist some state between runs in order to support + # the `--only-failures` and `--next-failure` CLI options. We recommend + # you configure your source control system to ignore this file. + config.example_status_persistence_file_path = "spec/examples.txt" + + # Limits the available syntax to the non-monkey patched syntax that is + # recommended. For more details, see: + # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ + # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode + config.disable_monkey_patching! + # Many RSpec users commonly either run the entire suite or an individual # file, and it's useful to allow more verbose output when running an # individual spec file. diff --git a/spec/support/fuubar.rb b/spec/support/fuubar.rb new file mode 100644 index 00000000..f731cea9 --- /dev/null +++ b/spec/support/fuubar.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +require "fuubar" + +RSpec.configure do |config| + # Use Fuubar instafail-alike formatter, unless a formatter has already been + # configured (e.g. via a command-line flag). + config.default_formatter = "Fuubar" + + # Disable auto-refresh of the fuubar progress bar to avoid surprises during + # debugiing. And simply because there's next to absolutely no point in having + # this turned on. + # + # > By default fuubar will automatically refresh the bar (and therefore + # > the ETA) every second. Unfortunately this doesn't play well with things + # > like debuggers. When you're debugging, having a bar show up every second + # > is undesireable. + # + # See: https://github.com/thekompanee/fuubar#disabling-auto-refresh + config.fuubar_auto_refresh = false +end diff --git a/spec/support/simplecov.rb b/spec/support/simplecov.rb new file mode 100644 index 00000000..8d710d52 --- /dev/null +++ b/spec/support/simplecov.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +require "simplecov" + +if ENV["CI"] + require "simplecov-lcov" + + SimpleCov::Formatter::LcovFormatter.config do |config| + config.report_with_single_file = true + config.lcov_file_name = "lcov.info" + end + + SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter +end + +SimpleCov.start do + add_filter "/spec/" + minimum_coverage 80 +end