Skip to content

fix codecov upload (closes #381) - #382

Merged
grst merged 3 commits into
scverse:mainfrom
ilia-kats:codecov
Apr 7, 2025
Merged

grst merged 3 commits into
scverse:mainfrom
ilia-kats:codecov

Conversation

@ilia-kats

Copy link
Copy Markdown
Collaborator

The codecov action can generate a usable report itself, but it needs the coverage package installed and accessible. This is not the case anymore, since it's now only installed in the hatch test environment. So we generate the report ourselves.

The codecov action can generate a usable report itself, but it needs the
coverage package installed and accessible. This is not the case anymore,
since it's now only installed in the hatch test environment. So we
generate the report ourselves.
@grst
grst requested a review from flying-sheep April 5, 2025 19:59
@grst

grst commented Apr 5, 2025

Copy link
Copy Markdown
Collaborator

Thanks @ilia-kats. We thought that hatch test --cover already creates the coverage report, but that doesn't seem to be the case.

Your solution will certainly work, I'm just wondering if it would be even better to somehow include this in the hatch script definition in pyproject.toml? @flying-sheep you get to decide.

@flying-sheep

flying-sheep commented Apr 7, 2025 •

Copy link
Copy Markdown
Member

OK so first of all, Ilan and I have seen some issues with letting codecov run coverage xml, so doing that ourselves is probably best: codecov/codecov-cli#648

Then generating the XML isn’t really necessary for any tool we use, so generating it locally would work, but just generate a useless file in the project root for most people. Also it’s only possible to override all of an environment’s scripts at once, so we’d have to add all of this to the config (see defaults):

[tool.hatch.envs.hatch-test.scripts]
run = "pytest{env:HATCH_TEST_ARGS:} {args}"
run-cov = "coverage run -m pytest{env:HATCH_TEST_ARGS:} {args}"
cov-combine = [ "coverage combine", "coverage xml" ] # we just want to override this …
cov-report = "coverage report"

So running it manually in CI probably best, but we need to be careful not to run into the same issue that codecov runs into: We should make sure to run coverage xml from the hatch environment, not some one-shot one that might fail to read our config or import our project properly or something.


So I say we run it using something like hatch run hatch-test.py${{ matrix.python }}:coverage xml (didn’t test that, might have gotten the syntax slightly wrong)

@flying-sheep flying-sheep linked an issue Apr 7, 2025 that may be closed by this pull request
@grst

grst commented Apr 7, 2025

Copy link
Copy Markdown
Collaborator

@ilia-kats, can you confirm

hatch run hatch-test.py${{ matrix.python }}:coverage xml

works for you?

@ilia-kats

Copy link
Copy Markdown
Collaborator Author

It needs to be uvx hatch run .... That works.

This was referenced Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

coverage upload broken with latest template version

3 participants