GithubAction, SonarScanner on is not detecting lcov report

On GitHub Actions, the scanner is not detecting the lcov report.

I’m using SonarCloud and your official Github Action SonarSource/sonarcloud-github-action@master on the last version.

I’m generating the lcov report for test coverage, and the scanner is indicating the report doesn’t exist, even though I check if the file is on the right spot and its content is right.

Run ls -l coverage/packages/ngx-deploy-npm
total 8
drwxr-xr-x 5 runner docker 4096 Jan 29 23:56 lcov-report
-rw-r--r-- 1 runner docker 3538 Jan 29 23:56 lcov.info
Run cat coverage/packages/ngx-deploy-npm/lcov.info
TN:
SF:src/core/index.ts
FNF:0
FNH:0
DA:1,3
LF:1
LH:1
BRF:0
BRH:0
end_of_record
TN:
.
.
.

Scanner Error:

INFO: Sensor JavaScript/TypeScript Coverage [javascript]
INFO: No LCOV files were found using coverage/packages/ngx-deploy-npm/lcov.info
WARN: No coverage information will be saved because all LCOV files cannot be found.

Here is the full output

steps to reproduce
On GitHub actions, using SonarSource/sonarcloud-github-action@master

  • Inidcate on sonar-project.properties to find the lcov report on coverage/packages/ngx-deploy-npm/lcov.info
  • Generate the lcov report
  • Verify if the file coverage/packages/ngx-deploy-npm/lcov.info exits
  • Launch the sonnar scanner using
    • - 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.SONARQUBE_SCANNER }}
        with:
          args: >
            -Dsonar.pullrequest.key=${{ github.env.PR_NUMBER }}
      
  • See the error indicating the lcov report doesn’t exist

I tested my configuration locally with dockerized server and scanner, and everything is running as expected.

I see no potential workaround.

Hey there.

Thanks for reaching out and linking to your project.

I have the feeling that you have really over-complicated your sonar-project.properties file by adding the concept of modules (which are, in most cases, an internal implementation detail that almost never need to be configured manually).

As a result, the coverage file cannot be found relative to the base of the module you’ve configured the coverage file for.

My suggestion is to cut back significantly in your configuration

  • remove sonar.modules and all module specific configuration
  • remove sonar.test.inclusions and instead…
    • set sonar.sources to the packages directory
    • set sonar.tests to the e2e directory that contains all your tests).
  • configure your coverage report once, not tied to any module

Besides your basic project identifiers (key, organization, name), this is really all you really need:

sonar.sources=packages
sonar.tests=e2e
sonar.javascript.lcov.reportPaths=coverage/packages/ngx-deploy-npm/lcov.info