I'm trying to set up a gitlab ci pipeline for a python project and I'm having some issues with sonarqube client which is not able to pars the coverage.xml file
The error I'm getting is the following:
INFO: Python test coverage
INFO: Parsing report '/builds/core-tech/tools/nlu/mix-nlu-middleware/server/tests/cov.xml'
WARN: Invalid directory path in 'source' element: /bolt-webserver/bolt
WARN: Invalid directory path in 'source' element: /bolt-webserver/tests
ERROR: Cannot resolve the file path 'base.py' of the coverage report, the file does not exist in all <source>.
ERROR: Cannot resolve 404 file paths, ignoring coverage measures for those files
INFO: Sensor Cobertura Sensor for Python coverage [python] (done) | time=74ms
INFO: Sensor PythonXUnitSensor [python]
INFO: Sensor PythonXUnitSensor [python] (done) | time=20ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
The coverage file (cov.xml) starts with this:
<?xml version="1.0" ?>
<coverage branch-rate="0" branches-covered="0" branches-valid="0" complexity="0" line-rate="0.3476" lines-covered="10369" lines-valid="29833" timestamp="1564079534753" version="4.4.2">
<!-- Generated by coverage.py: https://coverage.readthedocs.io -->
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
<sources>
<source>/bolt-webserver/bolt</source>
<source>/bolt-webserver/tests</source>
</sources>
<packages>
<package branch-rate="0" complexity="0" line-rate="0.55" name=".">
<classes>
<class branch-rate="0" complexity="0" filename="base.py" line-rate="0.5955" name="base.py">
<methods/>
<lines>
<line hits="1" number="1"/>
<line hits="1" number="2"/>
<line hits="1" number="3"/>
<line hits="1" number="4"/>
<line hits="1" number="5"/>
<line hits="1" number="7"/>
<line hits="1" number="9"/>
<line hits="1" number="10"/>
.......................
Sonar is called like this:
- sonar-scanner -Dsonar.projectKey=mix-nlu-middleware -Dsonar.sources=./server -Dsonar.host.url=$SONAR_SERVER_HOST -Dsonar.login=$SONAR_LOGIN -Dsonar.python.coverage.reportPaths=server/tests/cov.xml -Dsonar.junit.reportPaths=server/tests/junit-report.xml
The project tree looks like this:
.
+-- CONTRIBUTING.md
+-- gen_version.sh
+-- package-lock.json
+-- README.md
+-- scripts
│ +-- .....
+-- server
│ +-- alembic.ini
│ +-- bolt
│ │ +-- .....
│ +-- Bolt.egg-info
│ │ +-- .....
│ +-- conf
│ │ +-- .....
│ +-- dev-requirements.txt
│ +-- Dockerfile
│ +-- Dockerfile-dev
│ +-- http.log
│ +-- MANIFEST.in
│ +-- pytest.ini
│ +-- requirements.txt
│ +-- scripts
│ │ +-- .....
│ +-- sdks
│ │ +-- ....
│ +-- server.log
│ +-- setup.py
│ +-- templates
│ │ +-- .....
│ +-- tests
│ │ +-- .....
│ \-- version.properties
\-- test.txt
Any idea what I'm doing wrong here?
I've also tried to create the path /bolt-webserver/bolt in the root folder of the project and file system but still no luck.
The 'base.py' file and the others mentioned in the conv.xml are located under '/builds/core-tech/tools/nlu/mix-nlu-middleware/server/tests'