codecov / codecov-action

GitHub Action that uploads coverage to Codecov :open_umbrella:
https://www.codecov.io
MIT License
1.45k stars 202 forks source link

Unable to specify coverage reports flags per file #1522

Open ssbarnea opened 1 month ago

ssbarnea commented 1 month ago

Current way to define flags forces them to apply to all files part of a single upload step. Ideally the flags should be per file and not per upload action.

This makes Github Actions definition much harder to manage as we are forced to add extra calls to the upload action, especially as GHA does not have any support for looping.

It would be far more flexible if we could so something like:

    - name: Upload coverage to Codecov
      uses: codecov/codecov-action@v4
      with:
        directory: ./coverage/reports/
        files: ./coverage1.xml:unit,./coverage2.xml:e2e,!./cache # <- note the `:flag` after file pattern.
        # flags: unit,e2e

Or maybe someone else has another idea?

belgattitude commented 1 month ago

Not totally sure about the intent... But I'm facing a similar issue. My issue is that with the current codecov action, I'm not able to upload coverage for each packages (flagged): ie: flag-lib1: coverage 90%, flag-lib2: coverage: 81%

I have a nodejs monorepo setup: https://github.com/belgattitude/httpx

.
└── packages
    │── assert
        └── coverage/clover.xml 
    │── dsn-parser
        └── coverage/clover.xml
    │── exception
        └── coverage/clover.xml
    └── plain-object
        └── coverage/clover.xml
- codecov.yml

In my codecov.yml, I've set up the flags for each packages

See here ````yml coverage: range: 60..100 round: down precision: 2 flag_management: default_rules: carryforward: false individual_flags: - name: httpx-exception-unit paths: - packages/exception statuses: - type: project target: 90% threshold: 1% - name: httpx-dsn-parser-unit paths: - packages/dsn-parser statuses: - type: project target: 90% threshold: 1% - name: httpx-memo-intl-unit paths: - packages/memo-intl statuses: - type: project target: 90% threshold: 1% - name: httpx-plain-object-unit paths: - packages/plain-object statuses: - type: project target: 90% threshold: 1% - name: httpx-assert-unit paths: - packages/assert statuses: - type: project target: 90% threshold: 1% - name: httpx-json-api-unit paths: - packages/json-api statuses: - type: project target: 50% threshold: 1% ignore: - '.yarn/**/*' - '.husky/**/*' - 'docs/**/*' - 'examples/**/*' - '**/dist/**/*' github_checks: true comment: layout: 'reach, diff, flags, files' behavior: default require_changes: false require_base: yes require_head: yes branches: null show_carryforward_flags: true ````

I was expecting the codecov action to read paths assicated to the flags... but it actually doesn't.

So to be able to get covergae independently, I have to upload multiple times with each flags.

It would be nice to have a better way to do

PS: I have done it with the cli, but it does not work anymore (complains about missing token..., or rate limits)