Since coverage 5.0b2 you can now use relative path with this configuration file .coveragerc
:
[run]
relative_files = True
Then run pytest in the CI with the --cov
option pointing to the current directory:
pytest --cov ./ --cov-report xml:coverage.xml --cov-config=.coveragerc --cov-branch -ra
Reference: