Code cov not uploading coverage reports! But whyyyyyyy?!

Hey y’all - has anyone had trouble with codcov not uploading coverage reports to codecov.io? it tries but can’t seem to find the file. when i run pytest locally it creates a coverage.xml file in the main repo.

i’m tried adding a ./coverage.xml element to the files element here but it can’t seem to find that coverage file. how do i figure out where the coverage file is being saved when it’s run in CI?

it’s easy to see locally.

BTW this build used to work but it stopped working sometime in the past months. could it be because i’m now running tests using nox? could nox be creating that file in it’s own environment in CI? I am now wondering if that is the issue.

here is the build file - stravalib/.github/workflows/build-test.yml at main · stravalib/stravalib · GitHub i do think it might be related to nox.

i figured it out. something that used to work stopped working.

this was my fix to explicitly generate the xml file on the specific package.

    session.run(
        "pytest",
        "--cov=src/stravalib",
        "--cov-report=xml:coverage.xml",
        "src/stravalib/tests/unit/",
        "src/stravalib/tests/integration/",
    )

Yes, I also had a very similar issue with locating the .xml file. It felt like my CI was already a little bit fragile before the coverage uploads broke. I messed around with settings involving where the coverage action looks for the coverage data and where my coverage test writes the file. In the process I migrated from pytest to unittest + coverage.

I’d have to dig to figure out exactly what change I made to recover the coverage reports, but it sounds like we both solved our problems.

1 Like

@jagerber48 so weird! what i still don’t understand (but it’s not worth figuring out) is why it worked previously when i was using a makefile and the same approach. i suspect like you mention it was fragile and somehow worked by mistake. :woman_shrugging:

i did briefly look at coverage but i guess i’ve been using pytest / pytest-cov for so long i just stuck with it!