Multiple code coverage reports from one job

I have a monorepo with several packages. Unit-tests and coverage are run separately for each of packages, but within one CI job. In the end I export multiple cobertura XML files from my job:

  artifacts:
    reports:
      cobertura: 'packages/{package1,package2}/coverage/cobertura-coverage.xml'

But then in MR i see the coverage percentage from only one of the reports:

Furthermore, i can only have one badge for coverage, again referring to only one report.

Is the only possible solution to have a seperate CI job per every page?

@tsareg - Thanks for the post and welcome to the forum!

The coverage value on the MR is not taken from the cobertura.xml file directly but parsed from the jobs logs. To generate multiple coverage values and multiple badges you do need to have those in separate jobs currently yes.

I hope this helps!

-James H, GitLab Product Manager, Verify:Testing

@jheimbuck_gl it possible to get the total of the overall average rather than the last total in the job?

I ended up doing the following to get the average code coverage for anyone who has similar issue:

    - 'reportgenerator -reports:"**/coverage.cobertura.xml" -targetdir:"CoverageReports" -reporttypes:"Cobertura;HtmlSummary;SonarQube;TextSummary"'
    - 'head -n 10 CoverageReports/Summary.txt'
  coverage: /^\s*Line coverage:\s*\d+.\d+\%/

@JadeWilson - Thanks for posting the solution to your problem. That’s a great approach!

-James H, GitLab Product Manager, Verify:Testing

Where does reportgenerator come from?