Empty "code", no coverage on PR views (python)

Hi all, I’m running into a problem where the PR code is showing empty

I’m uploading the results to sonarcloud using the github action

steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 0  # shallow clones disabled for sonar cloud
    - name: Set up Python
      uses: actions/setup-python@v2
      with:
        python-version: 3.8
    - name: Install dependencies & Run make
      run: |
        poetry install --no-root
        poetry run sh scripts/lint.sh
        poetry run sh scripts/coverage.sh
    - name: SonarCloud Scan
      uses: SonarSource/sonarcloud-github-action@master
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

My config is as follows:

sonar.projectKey=***
sonar.organization=***

When I run a scan like this I get the following warning:

The following error(s) occurred while trying to import coverage report:
Invalid directory path in 'source' element: /home/runner/work/***/***

so If I add the following step to the worklow:

- name: Override Coverage Source Path for Sonar
      run: |
        sed -i 's/<source>\/home\/runner\/work\/***\/***<\/source>/<source>\/github\/workspace<\/source>/g' coverage.xml

Then I don’t get the warning but the code is still empty

Any help would be appreciated.

1 Like

Hi,

Welcome to the community!

I need to start with what may be a dumb question: your PR does make changes to code files, doesn’t it?

Because it would be perfectly normal, I think, to have an empty Code tab if you only updated e.g. a README.md file…

 
Ann

Hi, this PR is actually trying to solve an earlier issue where coverage wouldn’t show up. so there’s no code change unfortunately :sweat_smile:.

However it doesn’t address the issue of there being no actual coverage metric in the PR

Seeing as how the coverage on the “develop” branch is 0, I’d expect to see the coverage on this PR at least.

Hi,

If there’s no code, then there’s nothing to cover.

PR analysis is going to report on the coverage of the changed lines. Can you try this again with some code changes?

 
Ann