huggingface_hub
huggingface_hub copied to clipboard
Enable code coverage properly in Github Actions
Following up on PR https://github.com/huggingface/huggingface_hub/pull/976 that disables the coverage in tests.
It would be good to re-enable and fix it properly. Potential fixes have been mentioned here (internal url) and here (internal url).
Originally from @osanseviero :
The coverage tool we use is currently not working since it's actually looking at the coverage of the tests (i.e. if the tests are tested). The initial solution was simple (change
--cov
to--cov=src
), but the way we setup our tests is that we don't do relative imports of the code underhuggingface_hub
, but rather we installhuggingface_hub
and then run the tests. That means that we're really interested in the coverage of the locally installedhuggingface_hub
, Making it work is somewhat possible but starts to be hacky (we need to set up.coveragerc
pointing tohuggingface_hub
), but then pytest will look at the coverage of all the files even if we're only interested in a group of files (e.g. we have independent test coverage runs for repository, hub mixin, keras, fastai), so the approach above would not work very nice. I also face the issue that it seems codecov might not share the report for source_package). Locally you can trypytest --cov=.github --cov-config=.coveragerc tests/test_utils_sha.py
and it works ok, but again it gives the coverage for all the files.
and from @adrinjalali :
In this repo: https://github.com/skops-dev/skops/blob/main/.github/workflows/build-test.yml I install the library, then test, and in tests imports are not relative, and the coverage looks quite okay, example: https://app.codecov.io/gh/skops-dev/skops/compare/18/diff I'm not sure why on
huggingface_hub
we have these issues. I've also set the codecov config to wait for all the 12 CI runs before reporting anything, we could do the same forhuggingface_hub
.
Finally, an example of misleading codecov intervention: https://github.com/huggingface/huggingface_hub/pull/904/files
Mentioning this attempt from osanseviero https://github.com/huggingface/huggingface_hub/pull/925 just in case (closed without merging).
Done in https://github.com/huggingface/huggingface_hub/pull/992.