SonarCloud Python Code Coverage Result Doesn't Match

I would like to ask why is the code coverage report does not match the result in Github Action.

I ran the following

    - name: Test with django
      run: |
        source venv/bin/activate
        coverage run --source='.' manage.py test
        coverage report
        coverage html
        coverage xml -o coverage_report/coverage.xml
        deactivate
    - name: Override Coverage Source Path for Sonar
      run: sed -i "s/<source>\/home\/runner\/work\/hre-ml\/hre-ml<\/source>/<source>\/github\/workspace<\/source>/g" /home/runner/work/hre-ml/hre-ml/coverage_report/coverage.xml
    - name: archive coverage results
      uses: actions/upload-artifact@v1
      with:
        name: coverage-report
        path: coverage_report
    - name: SonarCloud Scan
      uses: SonarSource/sonarcloud-github-action@master
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
        SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

Result from Github Action:

TOTAL 2081 824 60.40%
Wrote HTML report to coverage_report/index.html
Wrote XML report to coverage_report/coverage.xml

But in SonarCloud Dashboard,
It only show 43.8% under “Overall Code”.
Just wondering why it doesn’t match the result from the coverage report.

Hey there.

To diagnose issues like these, it would be good to find a specific file where the coverage in SonarCloud doesn’t match what’s reported in your coverage report.

Also remember that SonarCloud will calculate coverage for all files, not just the ones calculated in your coverage report. If your repository has other files that can be covered by tests, they contribute to the coverage calculation as well.

Pay attention also to any logs that surround the import of code coverage:

So it doesn’t just reflect the result of the coverage result that done during the Github Workflow?
I expect that to be happen when we just uploading the coverage report.