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?
sudothen Python accesses a different set of packages (site-packages) doesn't it? What was more concretely the issue (error message if any) when running without sudo (it is not described in the question)? Also I would suggest to use a virtual environment to improve the ease of reproducibility.Couldn't use data file '/home/runner/work/repo/repo/docker/data/coverage/.coverage': unable to open database file. And when it comes to virtual environments, I don't know much about them nor how exactly im suppossed to use them in this kind of situation. But I might look into it if you could elaborate a little more.