Automatic flags in monorepo

Description

The recommended Flag setup according to the documentation is Automatic Flag Management
Flags.
However, there’s no real usage example included and I couldn’t find examples in other places.

We have many packages in our monorepo, each running their own tests and coverage upload.
I’ve pre-defined them in a long list inside codecov.yml, each with its respective path, but it’s not sustainable and doesn’t look particularly good.
It’s my understanding that Automatic Flags should solve this, but I don’t understand how CodeCov will know will understand the scope of each run.

Does anyone have an example of a monorepo using automatic flags?

@NivStav-RecoLabs I don’t have one immediately on hand, but I think that should help your case. Can I help with the yaml while I search one down/create one from scratch?

Thanks for the reply @tom !
The yaml is very basic:

...
flag_management:
  default_rules:
    carryforward: true

flags: 
  packageA:
    paths:
    - src/packageA/
  packageB:
    paths:
    - src/packageB/
  packageC:
    paths:
    - src/packageC/
# this pattern repeats

Hi @NivStav-RecoLabs, I’m investigating how we handle paths. I think you should be able to get this to work by removing the entire flags section. As long as you are uploading your coverage reports with the applicable flag name, it should work.

Hi @tom , I removed the explicit flags from the config file and flags are properly displayed and carried forward.
Diffs are also showing properly.

Thanks for the help!

1 Like