Coverage paths not found in monorepo

I recently added codecov to monorepo. This is my codecov.yml:

      default: off
        target: 95%
        flags: protocol

      - packages/protocol/

  - "packages/protocol/::"

The “protocol” package is where the coverage is being done, and the output looks something like this:

The “contracts/Sablier.sol” path is valid, when inside the “packages/protocol” path. Therefore, this is what I did in my configuration file, using the instructions found on this page.

However, when I click on the file, I still get this error:

Is the path contracts/Sablier.sol a relative path in your repository?

What am I doing wrong?

Hi @PaulRBerg! Doing a quick scan of your repository, I don’t think you even need fixes. That’s typically true if the coverage report generated matches up with the repository file structure. Can you see what happens if you remove that part of the yaml?

Hey Tom so I removed fixes yet the paths still don’t show up correctly. Attached an image below.

Well, that’s the problem I think. The paths inside the coverage report are relative to each package, which is not at the root of the monorepo.

I finally solved this issue by using lcov-result-merger:

yarn run coverage
yarn lcov-result-merger "packages/**/coverage/" | yarn codecov

The first step runs coverage on all packages in the monorepo, while the second one takes all the coverage reports and merges them into one which is relative to the root of the monorepo (exactly what I needed).