DiamondLightSource / python3-pip-skeleton

Archived in favour of https://github.com/DiamondLightSource/python-copier-template
Apache License 2.0
4 stars 4 forks source link

Change where we add coverage so debugging works intuitively even if .vscode dir is deleted #135

Closed coretl closed 1 year ago

coretl commented 1 year ago

At the moment coverage is always active in pytest. It is disabled in vscode debugging with a launch config. Some projects don't want to store .vscode in repo, so delete it, but then when they point vscode to it without any settings they have something where debugging doesn't work. It would seem better to have debugging work but coverage not active.

To change this we should delete: https://github.com/DiamondLightSource/python3-pip-skeleton/blob/64d2a03ba80d52b6d22ca541bb32eb6b455d83f9/pyproject.toml#L78

And then add --cov=python3_pip_skeleton --cov-report term --cov-report xml:cov.xml here: https://github.com/DiamondLightSource/python3-pip-skeleton/blob/64d2a03ba80d52b6d22ca541bb32eb6b455d83f9/pyproject.toml#L110 This means that tox -e pytest will do terminal and xml reported coverage

Also set

"python.testing.pytestArgs": [
  "--cov=python3_pip_skeleton",
  "--cov-report xml:cov.xml"
]

here: https://github.com/DiamondLightSource/python3-pip-skeleton/blob/64d2a03ba80d52b6d22ca541bb32eb6b455d83f9/.vscode/settings.json#L6 This means that vscode testing will write the coverage to an xml file that coverage gutters can use.

Finally we need to tell CI to also do this by doing tox -e pytest instead of: https://github.com/DiamondLightSource/python3-pip-skeleton/blob/64d2a03ba80d52b6d22ca541bb32eb6b455d83f9/.github/workflows/code.yml#L66

Then we need to test that coverage work in vscode and the commandline, that debugging works in vscode out of the box and when the .vscode directory is deleted, and that CI still sends coverage to codecov