Using codecov in monorepo with shared package

I have a monorepo with folder structure like:

  • codecov.yml (content of this file bellow)
    – packages/web (uses packages/shared as dependency)
    – packages/mobile (uses packages/shared as dependency)
    – packages/shared

I’m creating coverage by running tests for each modules separately (except of shared package, since web/mobile tests are covering all of the code) and uploading results to codecov with codecov --clear --flags=***. Uploading works fine, but since packages web and mobile import and use shared package, the coverage for shared package is generated for each of those runs, so it gets uploaded under wrong tag. Also, if I check any file from shared package in codecov WEB UI, I see that it got all 3 flags assigned.

I know I could exclude packages\shared folder from coverage reports for the tests that are generating it, but then I completely lose coverage report for this package (for now I only have 1 dummy test, didn’t write tests for it since it mostly contains constants and few functions + they are all covered by web/mobile tests).

Would there be a way to tell codecov to assign flags based on the directory? …for example, flag shared should always belong to packages/shared folder. I think this is the only way codecov could be aware of this and be able to merge reports and apply correct flags after upload.

Repository

private

Versions

Firefox 73.0.1
Windows 10

Additional Information

codecov.yml

coverage:
  status:
    project:
      target: 40%
      threshold: 5%
    web:
      target: 50%
      flags:
        - web
    mobile:
      target: 50%
      flags:
        - mobile
    shared:
      target: 50%
      flags:
        - shared
flags:
  web:
    paths:
      - packages/web
  mobile:
    paths:
      - packages/mobile
  shared:
    paths:
      - packages/shared

Hi @theanimalix

Currently, monorepos require you to upload all coverage each time or the report gets strange. We are working on a feature called CarryForward Flags that is close to release that will address this, stay tuned!

I’m aware of that and I’m doing it as mentioned above. I’ve heard about that feature but as far as I understand it, I don’t think it will solve my case, where I’m including shared local package and coverage is generated for it in each test run.

Anyway, won’t make assumptions before testing, so looking forward for it. Will update here later…