From b39639358fe692969db56dce9dd095cd159cb748 Mon Sep 17 00:00:00 2001 From: Nikita Shilnikov Date: Wed, 6 Nov 2019 18:34:48 +0300 Subject: [PATCH 1/2] Setup GH Actions --- .github/workflows/ci.yml | 70 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 29 ----------------- spec/spec_helper.rb | 20 ++++++------ 3 files changed, 80 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..16d98d78 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,70 @@ +name: ci + +on: + push: + paths: + - .github/workflows/ci.yml + - lib/** + - spec/** + +jobs: + tests-mri: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ruby: ["2.6.x", "2.5.x", "2.4.x"] + include: + - ruby: "2.6.x" + coverage: "true" + steps: + - uses: actions/checkout@v1 + - name: Set up Ruby + uses: actions/setup-ruby@v1 + with: + ruby-version: ${{matrix.ruby}} + - name: Download test reporter + if: "matrix.coverage == 'true'" + run: | + mkdir -p tmp/ + curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter + chmod +x ./tmp/cc-test-reporter + ./tmp/cc-test-reporter before-build + - name: Run all tests + env: + COVERAGE: ${{matrix.coverage}} + run: | + gem install bundler + bundle install --jobs 4 --retry 3 --without tools docs + bundle exec rake + - name: Send coverage results + if: "matrix.coverage == 'true'" + env: + CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}} + GIT_COMMIT_SHA: ${{github.sha}} + GIT_BRANCH: ${{github.ref}} + GIT_COMMITTED_AT: ${{github.event.head_commit.timestamp}} + run: | + GIT_BRANCH=`ruby -e "puts ENV['GITHUB_REF'].split('/', 3).last"` \ + GIT_COMMITTED_AT=`ruby -r time -e "puts Time.iso8601(ENV['GIT_COMMITTED_AT']).to_i"` \ + ./tmp/cc-test-reporter after-build + + tests-others: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + image: ["jruby:9.2.8", "ruby:rc"] + container: + image: ${{matrix.image}} + steps: + - uses: actions/checkout@v1 + - name: Install git + run: | + apt-get update + apt-get install -y --no-install-recommends git + - name: Run all tests + run: | + gem install bundler + bundle install --jobs 4 --retry 3 --without tools docs + bundle exec rspec diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6e8a691e..00000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: ruby -dist: trusty -sudo: required -cache: bundler -bundler_args: --without console -after_success: - - "[ -d coverage ] && bundle exec codeclimate-test-reporter" -rvm: - - 2.4.6 - - 2.5.5 - - 2.6.3 - - jruby-9.2.7.0 - - truffleruby -matrix: - allow_failures: - - rvm: truffleruby - - rvm: jruby-9.2.7.0 -env: - global: - - JRUBY_OPTS='--dev -J-Xmx1024M' - - COVERAGE='true' -notifications: - email: false - webhooks: - urls: - - https://webhooks.gitter.im/e/19098b4253a72c9796db - on_success: change # options: [always|never|change] default: always - on_failure: always # options: [always|never|change] default: always - on_start: false # default: false diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index fc32fc30..cf58f464 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,13 +1,13 @@ -if RUBY_ENGINE == 'ruby' && ENV['COVERAGE'] == 'true' - require 'yaml' - rubies = YAML.load(File.read(File.join(__dir__, '..', '.travis.yml')))['rvm'] - latest_mri = rubies.select { |v| v =~ /\A\d+\.\d+.\d+\z/ }.max - - if RUBY_VERSION == latest_mri - require 'simplecov' - SimpleCov.start do - add_filter '/spec/' - end +$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) + +require 'pathname' + +SPEC_ROOT = Pathname(__FILE__).dirname + +if ENV['COVERAGE'] == 'true' + require 'simplecov' + SimpleCov.start do + add_filter '/spec/' end end From 34065719fe869ca87407da4f3f1654ade1e3fe66 Mon Sep 17 00:00:00 2001 From: Nikita Shilnikov Date: Wed, 6 Nov 2019 18:37:17 +0300 Subject: [PATCH 2/2] Ignore rspec warnings --- spec/spec_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cf58f464..ccd895c9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -18,6 +18,7 @@ require 'warning' +Warning.ignore(/rspec\/mocks/) Warning.process { |w| raise RuntimeError, w } # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration