Inline code coverage should support cobertura reports with multiple source directories

Problem to solve

Right now as mentioned in #215747 (closed) the inline code coverage feature does not support files with multiple source directories. This is a problem for at least Java projects and likely other languages as well.

This may also have implications for monorepos, however monorepos are more likely to generate multiple coverage reports and upload them all. We should investigate whether we should solve the monorepo concerns as part of this issue or create a follow-up to address them.

Intended users

User experience goal

When uploading a cobertura report for a project with multiple directories/nodes we should be able to correctly attribute coverage data to files in each directory in a merge request.

Proposal

From initial issue

  1. cobertura.rb needs to differentiate between Array and String entries of source key
  2. coverage_reports.rb should match up files with sourcepaths

meledine/gitlab!1 (diffs)

Apart from the spec (just playing around there really) the code in cobertura.rb and coverage_reports.rb is the workaround we are currently using for the issue. As noted in the diff, I expect you probably want a solution using the pick method, but I'm not fluent enough in Ruby to make that workaround.

@iamricecake can you weigh in on how we might solve this?

Further details

Permissions and Security

This is an enhancement of an existing feature, N/A.

Documentation

We should remove the documentation of this limitation when we fix it.

Availability & Testing

What does success look like, and how can we measure that?

What is the type of buyer?

Is this a cross-stage feature?

Links / references