Fixing paths per flag in a monorepo

Description

I have a monorepo project with two packages for a frontend and api. We want to track coverage for the project overall, and for each of the packages using codecov flags.

The codecov.yml is set up like this:

coverage:
  status:
    project:
      default:
        threshold: 5
      api:
        flags: api
        threshold: 5
      frontend:
        threshold: 5
        flags: frontend
flags:
  api:
    paths:
      - packages/api/
  frontend:
    paths:
      - packages/frontend/

We use wsrun to run package scripts from the monorepo root. So our CI calls the yarn script report-coverage in each package, which looks like this:

"report-coverage": "cd ../../; codecov -f ./packages/frontend/coverage/lcov.info -F frontend",

As you can see, we are cding up into the root of the monorepo. This is the only way I’ve been able to figure out how to get codecov to recognize file paths correctly. If I leave off the cding part, and run codecov from inside the package root, then the packages/frontend is missing from our paths, and trying to view a single file on the webapp results in the 404, “file not found in report” error.

I think Fixing Paths should be able to help us here, but it’s not very well documented. It seems we would need to have path fixing per flag - i.e. the frontend flagged files would fix paths with something like ::packages/frontend

Is this possible? How can I better understand the path fixing that codecov already does? And does adding my own path fixes replace what codecov does?

Repository

private

Versions

latest codecov npm package