codecov/codecov-ruby

Support monorepo

Opened this issue · 0 comments

Say you have a monorepo with

/ (repo root)
├── rails
└── web

This breaks the codecov report because of missing rails/ and web/ prefixes in all paths. Path fixing only works for one subfolder because it's global (not per flag/test suite), and breaks all paths of the other.

We have found a workaround with

# rails/test/support/coverage.rb, required in test_helper.rb:
SimpleCov.start 'rails' do
  # test file paths need to include `rails/...` for codecov
  root File.expand_path('../../..', __dir__)
  # .. but move the coverage reports back into `rails/test/coverage`
  coverage_dir 'rails/coverage'
end

but that's rather cumbersome.

The issue is that this is not configurable:

file.filename.gsub(/^#{SimpleCov.root}/, '.').gsub(%r{^\./}, '')

Would you be open for a PR? If so, any preferred config API? Maybe simply like this?

CODECOV_ROOT=rails/

Sorry for hammering you guys! We just love codecov so much we want to use it everywhere! :)