I wanted to use coveragepy combine to seperate .coverage files into one.
For that I installed python and the coverage module via pip, afterwards then running this command. python -m coverage combine .coverage-*
. That should work and does, but aparrently requires either root or for the user to own the directory. So I decided to use sudo within the github action, since I read that it's passwordless.
But when running the installed module with sudo in front of the command it says /usr/bin/python: No module named coverage
.
This is the part of my workflow responsible for the actions explained above:
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install coverage
run: |
python -m pip install --upgrade pip
pip install coverage
- name: Listing all items in data directory (Testing)
run: ls -Al ./docker/data/coverage
- name: Merge coverage reports
working-directory: ./docker/data/coverage
run: sudo python -m coverage combine .coverage-*
running the sudo python -m coverage combine .coverage-*
on my local machine works just fine.
Is there any way I can get python to recognise that, that module exists and is installed or is there maybe any other workaround I could use?
I suspect pip is installing coverage to the user directory. If you must run the command with sudo, try running the pip install with sudo as well.