diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d6f5e78..1139098 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -135,4 +135,9 @@ jobs: if: github.ref == 'refs/heads/main' run: ./cc-test-reporter upload-coverage env: - CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} \ No newline at end of file + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + + - name: Check code changes coverage + run: | + git fetch --update-head-ok origin main:main + ./bin/undercover -c main diff --git a/.simplecov b/.simplecov new file mode 100644 index 0000000..e971a9c --- /dev/null +++ b/.simplecov @@ -0,0 +1,20 @@ +require "simplecov-lcov" +require "undercover" +require "simplecov_json_formatter" + +SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true + +SimpleCov.start do + add_filter "/spec/" + add_filter "/features/" + + formatter( + SimpleCov::Formatter::MultiFormatter.new( + [ + SimpleCov::Formatter::HTMLFormatter, + SimpleCov::Formatter::JSONFormatter, + SimpleCov::Formatter::LcovFormatter + ] + ) + ) +end diff --git a/Gemfile b/Gemfile index 6154a28..e4eb91f 100644 --- a/Gemfile +++ b/Gemfile @@ -78,5 +78,7 @@ group :test do gem "selenium-webdriver" gem "simplecov", "~> 0.21", require: false gem "simplecov-json", require: false + gem "simplecov-lcov", "~> 0.8", require: false gem "shoulda-matchers", "~> 6.2" + gem "undercover", "~> 0.5" end diff --git a/Gemfile.lock b/Gemfile.lock index e2b153b..f6ba599 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -152,6 +152,8 @@ GEM image_processing (1.12.2) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) + imagen (0.1.8) + parser (>= 2.5, != 2.5.1.1) importmap-rails (2.0.1) actionpack (>= 6.0.0) activesupport (>= 6.0.0) @@ -313,6 +315,7 @@ GEM ruby-vips (2.1.4) ffi (~> 1.12) rubyzip (2.3.2) + rugged (1.7.2) selenium-webdriver (4.21.1) base64 (~> 0.2) rexml (~> 3.2, >= 3.2.5) @@ -328,6 +331,7 @@ GEM simplecov-json (0.2.3) json simplecov + simplecov-lcov (0.8.0) simplecov_json_formatter (0.1.4) sprockets (4.2.1) concurrent-ruby (~> 1.0) @@ -350,6 +354,11 @@ GEM railties (>= 6.0.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) + undercover (0.5.0) + bigdecimal + imagen (>= 0.1.8) + rainbow (>= 2.1, < 4.0) + rugged (>= 0.27, < 1.8) unicode-display_width (2.5.0) web-console (4.2.1) actionview (>= 6.0.0) @@ -394,10 +403,12 @@ DEPENDENCIES shoulda-matchers (~> 6.2) simplecov (~> 0.21) simplecov-json + simplecov-lcov (~> 0.8) sprockets-rails stimulus-rails turbo-rails tzinfo-data + undercover (~> 0.5) web-console RUBY VERSION diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index db96063..a2cc22a 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -1,6 +1,13 @@ class StoriesController < ApplicationController before_action :set_story, only: %i[ show edit update destroy ] + def new_test_endpoint + random_number = rand(100) + sleep(2) + + Array.new(20) { random_number + rand(3) } + end + # GET /stories or /stories.json def index @stories = Story.all diff --git a/bin/undercover b/bin/undercover new file mode 100755 index 0000000..1d08481 --- /dev/null +++ b/bin/undercover @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("undercover", "undercover") diff --git a/features/support/env.rb b/features/support/env.rb index 2bd02fd..3c8e937 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -5,8 +5,6 @@ # files. require 'simplecov' -SimpleCov.start - require 'cucumber/rails' # By default, any exception happening in your Rails application will bubble up diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8b551b7..829f410 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,15 +1,5 @@ require 'pathname' require 'simplecov' -require "simplecov_json_formatter" - -SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([ - SimpleCov::Formatter::HTMLFormatter, - SimpleCov::Formatter::JSONFormatter - ]) - -SimpleCov.start do - add_filter '/spec/' -end class RootPath def pathname