From 2f8f719fc4b5361be11504fccc4109df55adac8a Mon Sep 17 00:00:00 2001 From: Washington Botelho Date: Tue, 17 May 2022 22:48:47 -0300 Subject: [PATCH] up: adds converage --- .github/workflows/tests.yml | 18 ++++++++++++++++++ Gemfile.lock | 10 ++++++++++ rating.gemspec | 1 + spec/support/coverage.rb | 18 ++++++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 spec/support/coverage.rb diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ace75b7..e065ec6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -39,10 +39,28 @@ jobs: ruby-version: ${{ matrix.ruby }} - name: Runs tests + env: + CI: true + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + COVERAGE: true + MINIMUM_COVERAGE: 80 + run: bundle exec rake spec - name: Runs tests with config enabled + env: + CI: true + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + COVERAGE: true + MINIMUM_COVERAGE: 80 + run: bundle exec rake spec_config - name: Runs tests with config enabled for extra scopes + env: + CI: true + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + COVERAGE: true + MINIMUM_COVERAGE: 80 + run: bundle exec rake spec_config_with_extra_scopes diff --git a/Gemfile.lock b/Gemfile.lock index 004a49e..41482f4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -32,6 +32,8 @@ GEM tzinfo (~> 2.0) ast (2.4.2) builder (3.2.4) + codecov (0.6.0) + simplecov (>= 0.15, < 0.22) concurrent-ruby (1.1.10) crass (1.0.6) database_cleaner (2.0.1) @@ -41,6 +43,7 @@ GEM database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) diff-lcs (1.5.0) + docile (1.4.0) erubi (1.10.0) factory_bot (6.2.1) activesupport (>= 5.0.0) @@ -122,6 +125,12 @@ GEM ruby-progressbar (1.11.0) shoulda-matchers (5.1.0) activesupport (>= 5.2.0) + simplecov (0.21.2) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) + simplecov_json_formatter (0.1.4) thor (1.2.1) tzinfo (2.0.4) concurrent-ruby (~> 1.0) @@ -132,6 +141,7 @@ PLATFORMS ruby DEPENDENCIES + codecov database_cleaner factory_bot_rails mysql2 diff --git a/rating.gemspec b/rating.gemspec index bf30032..4f0df12 100644 --- a/rating.gemspec +++ b/rating.gemspec @@ -17,6 +17,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'activerecord' + spec.add_development_dependency 'codecov' spec.add_development_dependency 'database_cleaner' spec.add_development_dependency 'factory_bot_rails' spec.add_development_dependency 'mysql2' diff --git a/spec/support/coverage.rb b/spec/support/coverage.rb new file mode 100644 index 0000000..9b21985 --- /dev/null +++ b/spec/support/coverage.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +if ENV.fetch('COVERAGE', 'false') == 'true' + require 'simplecov' + require 'codecov' + + SimpleCov.formatter = SimpleCov::Formatter::Codecov + + SimpleCov.minimum_coverage(ENV.fetch('MINIMUM_COVERAGE', 80).to_i) + + SimpleCov.start('rails') do + add_filter [ + '/lib/generators', + '/lib/rating/version.rb', + '/vendor', + ] + end +end