SonarCloud not reporting coverage with GitHub Action

We have a JS repo in GitHub, and want to integrate the GitHub Action for reporting, as per this doc entry.

Following the example on the docs, our action installs the repository’s dependencies, runs the jest --coverage command (that’s aliased as the test:cicov in our package.json), and then runs the scan:

 name: SonarCloud Report

on: 
  pull_request:
    branches: 
      - main
      - develop
jobs:
  Run_SonarCloud_Analysis:
    name: SonarCloud Analysis
    runs-on: ubuntu-latest
    environment: 'develop'
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0 
      - name: Install dependencies
        run: npm i
      - name: Test and coverage
        run: npm run test:cicov
      - name: SonarCloud Scan
        if: always()
        uses: SonarSource/sonarcloud-github-action@master
        env:
          SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}

Our sonar-project.properties file looks like this:

sonar.organization=MY_REAL_ORG
sonar.projectKey=MY_REAL_PROJECT
sonar.javascript.lcov.reportPaths=./coverage/lcov.info
sonar.verbose=true

When Sonar Scan runs, it shows the following logs related to the JS Code Coverage:

18:31:45.212 DEBUG: Property sonar.javascript.lcov.reportPaths is used.
18:31:45.212 DEBUG: Using './coverage/lcov.info' to resolve LCOV files
18:31:45.213 INFO: Analysing [/github/workspace/./coverage/lcov.info]
18:31:45.270 INFO: Sensor JavaScript/TypeScript Coverage [javascript] (done) | time=59ms

But, the end result is Code Coverage not being reported

Anything I’m missing on my setup? Thanks!

Hi,

Can we have the full analysis log?

Also, are we looking at a PR here? And if so, can you verify that the changes in the PR include changes to code (versus configuration or comments)?

 
Thx,
Ann

I added some code to the PR and it seems to be reporting code coverage on new code.

My expectation was to report full code coverage, not just for new code on the PR. Is that even possible? Thanks!

Hi,

PR analysis only reports on what was changed in the PR.

 
Ann

Gotcha, appreciate the prompt response.

Does SonarCloud Analysis support FULL coverage report at all? Thanks!

Hi,

Of course. Do a branch analysis.

Specifically, you want to make sure analysis is included in the pipeline for the build of your branches.

 
HTH,
Ann