Wrong coverage number in badge with flags

Before submitting a topic, please confirm the following

I have searched for similar issues before creating this topic.
I have verified that my repository is using the Codecov GitHub app, if using GitHub
I have validated my codecov.yaml configuration file.
I have filled out the below sections to the best of my ability.


In our project:

we use codecov already since quite some time but have recently added the coverage result of mypy (static type checking coverage) using flags.
Now, we have two flags currently active: unittests and mypy

In the browser overview under flags (Codecov) I can see the correct coverage results of ~90% and ~40%, respectively. In the main overview (Codecov) I get ~68%, so far so good.

The problem now is that the badges don’t seem to work.


This is a CI run of a PR that tried to fix this issue:

But also happens on the main branch…

Codecov Output

     _____          _
    / ____|        | |
   | |     ___   __| | ___  ___ _____   __
   | |    / _ \ / _` |/ _ \/ __/ _ \ \ / /
   | |___| (_) | (_| |  __/ (_| (_) \ V /
    \_____\___/ \__,_|\___|\___\___/ \_/

  Codecov report uploader 0.3.2
[2022-11-18T16:27:41.879Z] ['info'] => Project root located at: /home/runner/work/xarray/xarray
[2022-11-18T16:27:41.885Z] ['info'] -> No token specified or token is empty
[2022-11-18T16:27:41.895Z] ['info'] Searching for coverage files...
[2022-11-18T16:27:41.961Z] ['info'] => Found 1 possible coverage files:
[2022-11-18T16:27:41.962Z] ['info'] Processing ./coverage.xml...
[2022-11-18T16:27:41.977Z] ['info'] Detected GitHub Actions as the CI provider.
[2022-11-18T16:27:41.980Z] ['info'] Pinging Codecov: https://codecov.io/upload/v4?package=github-action-3.1.1-uploader-0.3.2&token=*******&branch=codecov&build=3498487060&build_url=https%3A%2F%2Fgithub.com%2Fpydata%2Fxarray%2Factions%2Fruns%2F3498487060&commit=ad5d35b74585cd352b73d684252ebd9feeff7b46&job=CI&pr=7142&service=github-actions&slug=pydata%2Fxarray&name=codecov-umbrella&tag=&flags=unittests&parent=
[2022-11-18T16:27:42.717Z] ['info'] https://app.codecov.io/github/pydata/xarray/commit/ad5d35b74585cd352b73d684252ebd9feeff7b46
[2022-11-18T16:27:42.718Z] ['info'] Uploading...
[2022-11-18T16:27:42.909Z] ['info'] {"status":"success","resultURL":"https://app.codecov.io/github/pydata/xarray/commit/ad5d35b74585cd352b73d684252ebd9feeff7b46"}

Expected Results

I expected that the badge with the unittests flag displays ~90%.

Actual Results

If I use a badge without a flag (https://codecov.io/gh/pydata/xarray/branch/main/graph/badge.svg) it only displays 56%.
If I use the badge with the unittests flag (https://codecov.io/gh/pydata/xarray/branch/main/graph/badge.svg?flag=unittests) I get 68%, which strangely is the average percentage in the overview?.
If I use the badge with the mypy flag (https://codecov.io/gh/pydata/xarray/branch/main/graph/badge.svg?flag=mypy) I get 38%, which is weirdly correct.

Additional Information

Maybe it is an issue that the unittests are part of the package but they are type checked. Meaning the coverage of these files is only given with the mypy flag and not with the unittests flag…

@mick there seems to be a mismatch between the branch you’re showing above main and the default branch on Codecov master. I would try changing your default branch first and seeing if you are getting the right badge values.

We have changed the default branch to main, now it matches GitHub.
I’m still seeing the same results though :frowning: