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)
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
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.
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