Skip to content

Commit

Permalink
Add CodeCov for Ruby coverage reports (mastodon#23868)
Browse files Browse the repository at this point in the history
  • Loading branch information
nschonni authored Nov 14, 2023
1 parent 35b9749 commit 36d7d17
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion .github/workflows/test-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
DB_HOST: localhost
DB_USER: postgres
DB_PASS: postgres
DISABLE_SIMPLECOV: true
DISABLE_SIMPLECOV: ${{ matrix.ruby-version != '.ruby-version' }}
RAILS_ENV: test
ALLOW_NOPAM: true
PAM_ENABLED: true
Expand Down Expand Up @@ -137,6 +137,12 @@ jobs:

- run: bin/rspec

- name: Upload coverage reports to Codecov
if: matrix.ruby-version == '.ruby-version'
uses: codecov/codecov-action@v3
with:
files: coverage/lcov/mastodon.lcov

test-e2e:
name: End to End testing
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ group :test do

# Coverage formatter for RSpec test if DISABLE_SIMPLECOV is false
gem 'simplecov', '~> 0.22', require: false
gem 'simplecov-lcov', '~> 0.8', require: false

# Stub web requests for specs
gem 'webmock', '~> 3.18'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@ GEM
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov-lcov (0.8.0)
simplecov_json_formatter (0.1.4)
smart_properties (1.17.0)
sprockets (3.7.2)
Expand Down Expand Up @@ -936,6 +937,7 @@ DEPENDENCIES
simple-navigation (~> 4.4)
simple_form (~> 5.2)
simplecov (~> 0.22)
simplecov-lcov (~> 0.8)
sprockets (~> 3.7.2)
sprockets-rails (~> 3.4)
stackprof
Expand Down
8 changes: 8 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@

if ENV['DISABLE_SIMPLECOV'] != 'true'
require 'simplecov'
require 'simplecov-lcov'
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter
SimpleCov.start 'rails' do
enable_coverage :branch
enable_coverage_for_eval

add_filter 'lib/linter'
add_group 'Policies', 'app/policies'
add_group 'Presenters', 'app/presenters'
add_group 'Serializers', 'app/serializers'
add_group 'Services', 'app/services'
add_group 'Validators', 'app/validators'

add_group 'Libraries', 'lib'
end
end

Expand Down

0 comments on commit 36d7d17

Please sign in to comment.