Template for a good new topic, formatted with Markdown:
- ALM used: GitHub
- CI system used: Github Actions
- Scanner command used: SonarSource/sonarcloud-github-action@master
Command launch from Python:
pipenv run coverage run -m pytest --disable-pytest-warnings -n 4 --cov-report=xml
- Error observed (wrap logs/code around with triple quotes ``` for proper formatting):
INFO: Parsing report '/github/workspace/./api_correcto/coverage.xml'
WARN: Invalid directory path in 'source' element: /home/runner/work/api.backend/api.backend/api_correcto/api_correcto
ERROR: Cannot resolve the file path '__init__.py' of the coverage report, the file does not exist in all 'source'.
ERROR: Cannot resolve 78 file paths, ignoring coverage measures for those files
INFO: Processing report './api_correcto/xunit.xml'
WARN: The resource for 'api_correcto.apps.checkouts.tests.test_controllers.CheckoutControllersTestCase' is not found, drilling down to the details of this test won't be possible
WARN: The resource for 'api_correcto.apps.checkouts.tests.test_services.CheckoutServicesTestCase' is not found, drilling down to the details of this test won't be possible
WARN: The resource for 'api_correcto.apps.checkouts.tests.test_controllers.CheckoutControllersTestCase' is not found, drilling down to the details of this test won't be possible
WARN: The resource for 'api_correcto.apps.checkouts.tests.test_services.CheckoutServicesTestCase' is not found, drilling down to the details of this test won't be possible
WARN: The resource for 'api_correcto.apps.checkouts.tests.test_services.CheckoutServicesTestCase' is not found, drilling down to the details of this test won't be possible
WARN: The resource for 'api_correcto.apps.auth.tests.tests.rest.v1_0.refresh_token.test_contract_refresh_token.ContractRefreshTokenAPITests' is not found, drilling down to the details of this test won't be possible
coverage.xml
<?xml version="1.0" ?>
<coverage version="7.3.2" timestamp="1698768932115" lines-valid="761" lines-covered="740" line-rate="0.9724" branches-covered="0" branches-valid="0" branch-rate="0" complexity="0">
<!-- Generated by coverage.py: https://coverage.readthedocs.io/en/7.3.2 -->
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
<sources>
<source>/home/runner/work/api.backend/api.backend/api_correcto/api_correcto</source>
</sources>
<packages>
<package name="." line-rate="1" branch-rate="0" complexity="0">
<classes>
<class name="__init__.py" filename="__init__.py" complexity="0" line-rate="1" branch-rate="0">
<methods/>
<lines/>
</class>
<class name="urls.py" filename="urls.py" complexity="0" line-rate="1" branch-rate="0">
<methods/>
<lines>
<line number="1" hits="1"/>
<line number="2" hits="1"/>
<line number="3" hits="1"/>
<line number="5" hits="1"/>
<line number="6" hits="1"/>
<line number="7" hits="1"/>
<line number="9" hits="1"/>
</lines>
</class>
</classes>
</package>
xunit.xml
<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="188" time="243.259" timestamp="2023-10-31T16:11:30.273631" hostname="fv-az589-852"><testcase classname="api_correcto.apps.auth.tests.tests.rest.v1_0.sign_in.test_sign_in.SignInAPITests" name="test_sign_in_wrong_type_password" time="137.290"><system-out>--------------------------------- Captured Out ---------------------------------
</system-out></testcase><testcase classname="api_correcto.apps.checkouts.tests.test_services.CheckoutServicesTestCase" name="test_create_new_checkout" time="137.800"><system-out>--------------------------------- Captured Out ---------------------------------
</system-out></testcase><testcase classname="api_correcto.apps.auth.tests.tests.rest.v1_0.sign_in.test_sign_in.SignInAPITests" name="test_sign_in_wrong_type_username" time="2.227"><system-out>--------------------------------- Captured Out ---------------------------------
tree directory in Github Action
api.backend
└── api.backend
├── Dockerfile
├── Pipfile
├── README.md
├── api_correcto
│ ├── api_correcto
│ │ ├── __init__.py
│ │ ├── api_core
[...]
│ │ ├── asgi.py
│ │ ├── settings
│ │ │ ├── __init__.py
│ │ │ ├── base.py
│ │ │ ├── ci.py
│ │ │ ├── local.py
│ │ │ └── prod.py
│ │ ├── test_utils
│ │ │ ├── __init__.py
│ │ │ └── mixins.py
│ │ ├── urls.py
│ │ └── wsgi.py
│ ├── coverage.xml
│ ├── manage.py
│ ├── pytest.ini
│ └── xunit.xml
├── docker-compose.yml
├── languagetool
│ └── data
│ └── dump.sql
└── sonar-project.properties
Why isn’t Sonar able to retrieve coverage information when files exist and paths are correct? Could you help me to solve this issue with Python?