In a nutshell :
- Error : SonarCloud Dashboard showing 0% Coverage
- GitHub (private repo)
- Github Actions
- Python (for a data science project)
Hi folks,
I am a totally beginner with sonar source products, and I am in charge to configure SonarCloud automatic analysis on my team’s project (sic).
I have read all available documentations, everything is working fine, except that the code coverage on my project stays to 0. I have dug the documentation and some tutorials, but I am still stuck and cannot get what I am missing …
I run my unit tests using : pytest test --doctest-modules --junitxml=junit/test-results.xml --cov=jawclenching --cov-report=xml
Is there anything wrong in my configurations? my paths? my xml report format?
Let me know if you have any questions.
Thx,
Have a nice day.
Please find my project’s configurations
project/.github/workflows/build.yml :
name: Build
on:
push:
branches:
- develop
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build, Test and Analyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Test with pytest
run: |
pip install pytest
pip install pytest-mock
pip install pytest-cov
pytest test --doctest-modules --junitxml=junit/test-results.xml --cov=jawclenching --cov-report=xml --cov-report=html
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
project/sonar-project.properties :
sonar.projectKey= --
sonar.organization= --
sonar.projectName= --
sonar.projectVersion=1.0
sonar.sources=.
sonar.sources.exlcusions=**/test_*.py
sonar.tests=.
sonar.test.inclusions=**/test_*.py
sonar.python.coverage.reportPaths=junit/*.xml
sonar.sourceEncoding=UTF-8
project structure:
- project :
- src
- test
- junit
- ...
project/junit/test-results.xml:
<?xml version="1.0" encoding="utf-8"?>
<testsuites>
<testsuite name="pytest" errors="0" failures="0" skipped="0" tests="511" time="7.164" timestamp="2021-07-30T15:55:59.722732" hostname="xxx.local">
<testcase classname="test.test_base.TestFilter" name="test_generate_filter" time="0.003"/>
<testcase classname="test.test_base.TestFilter" name="test_get_logs" time="0.001"/>
....
</testsuite>
</testsuites>