No unit-tests metric for JS/TS LCOV reports obtained in multiple files

  • SonarQube 9.9 LTS Developer (Server) Edition:
  • Deployed: K8S/Docker
  • Goal: get unit tests metric

Context:

  1. sonar-project.properties:
sonar.projectKey=<key>
sonar.sources=.
sonar.exclusions=**/webpack.* **/*mocks*/**/*, **/bin/**/*, **/coverage/**/*, **/generated/**/*, **/fixtures/**/*, **/docs/**/*, **/tools/**/*, **/*report.xml, **/*.config.ts, **/*.txt, **/*.abi, **/*.bin
sonar.coverage.exclusions=**/scripts/**/*, **/support/**/*, **/*.test.*
sonar.tests=.
sonar.test.inclusions=**/*.test.*
  1. GH workflow has sharded tests (workflow matrix), correspondingly producing several .lcov-reports:
name: CI
on:
  push:
    branches:
      - sonar-test-report

jobs:
  unit-tests:
      strategy:
        matrix:
          shardIndex: [1, 2, 3, 4]
          shardTotal: [4]

sonarqube:
  - name: SonarQube Scan
    needs: [unit-tests]
    runs-on: ubuntu-latest
        uses: sonarsource/sonarqube-scan-action@master
        with:
          args: >
            -Dsonar.log.level=DEBUG
            -Dsonar.javascript.lcov.reportPaths=${{ steps.sonarqube_report_paths.outputs.sonarqube_coverage_report_paths }}
  1. sonar.javascript.lcov.reportPaths gets the following values after downloading the artifacts:
    -Dsonar.log.level=DEBUG -Dsonar.javascript.lcov.reportPaths=./unit-tests-coverage/4_lcov.info,./unit-tests-coverage/1_lcov.info,./unit-tests-coverage/3_lcov.info,./unit-tests-coverage/2_lcov.info

Actual result:

Not sure if this result is dependent in any way on the fact that there are multiple files to be processed by Sonar.

  1. Partial content of .lcov:
TN:
SF:src/actionCreators.ts
FN:60,(anonymous_1)
FN:68,(anonymous_2)
FN:73,(anonymous_3)
FN:80,(anonymous_4)
FN:228,(anonymous_5)
FN:342,(anonymous_6)
FN:345,(anonymous_7)
FN:347,(anonymous_8)
FN:349,(anonymous_9)
FN:375,(anonymous_10)
FN:477,(anonymous_11)
FN:541,(anonymous_12)
FN:38,(anonymous_17)
FN:48,(anonymous_18)
FN:52,(anonymous_19)
FN:60,(anonymous_20)
FN:68,(anonymous_21)
FN:73,(anonymous_22)
FN:80,(anonymous_23)
FN:104,(anonymous_24)
FN:111,(anonymous_25)
FN:114,SignIn
FN:115,(anonymous_27)
FN:119,(anonymous_28)
FN:120,(anonymous_29)
FN:132,(anonymous_30)
FN:149,(anonymous_31)
FN:166,(anonymous_32)
FN:202,(anonymous_33)
FN:203,(anonymous_34)
FN:211,(anonymous_35)
FN:228,(anonymous_36)
FN:234,SignOut
FN:237,(anonymous_38)
FN:238,(anonymous_39)
FN:251,buffer
FN:252,(anonymous_41)
FN:256,bufferEn
  1. Sonar dashboard
  2. Logs:
INFO: Project root configuration file: /github/workspace/sonar-project.properties
20:45:14.461 INFO: SonarScanner 4.8.0.2856
20:45:14.463 INFO: Java 11.0.19 Alpine (64-bit)
20:45:14.463 INFO: Linux 5.15.0-1040-azure amd64
20:45:14.665 DEBUG: keyStore is : 
20:45:14.665 DEBUG: keyStore type is : pkcs12
20:45:14.665 DEBUG: keyStore provider is : 
20:45:14.665 DEBUG: init keystore
20:45:14.666 DEBUG: init keymanager of type SunX509
20:45:14.820 DEBUG: Create: /opt/sonar-scanner/.sonar/cache
20:45:14.821 INFO: User cache: /opt/sonar-scanner/.sonar/cache
20:45:14.821 DEBUG: Create: /opt/sonar-scanner/.sonar/cache/_tmp
20:45:14.825 DEBUG: Extract sonar-scanner-api-batch in temp...
20:45:14.828 DEBUG: Get bootstrap index...
20:45:14.828 DEBUG: Download: ***batch/index
20:45:15.459 DEBUG: Get bootstrap completed
20:45:15.465 DEBUG: Download ***batch/file?name=scanner-developer-9.9.0.65466-all.jar to /opt/sonar-scanner/.sonar/cache/_tmp/fileCache14835123108570684430.tmp
20:45:16.638 DEBUG: Create isolated classloader...
20:45:16.648 DEBUG: Start temp cleaning...
20:45:16.651 DEBUG: Temp cleaning done
20:45:16.651 DEBUG: Execution getVersion
20:45:16.672 INFO: Analyzing on SonarQube server 9.9.0.65466
20:45:16.672 INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
20:45:16.672 DEBUG: Work directory: /github/workspace/.scannerwork
20:45:16.673 DEBUG: Execution execute
20:45:17.102 DEBUG: Developer 9.9.0.65466
20:45:17.401 INFO: Load global settings
20:45:17.667 DEBUG: GET 200 ***api/settings/values.protobuf | time=264ms
20:45:17.778 INFO: Load global settings (done) | time=378ms
20:45:17.803 DEBUG: Create : /opt/sonar-scanner/.sonar/_tmp
20:45:17.803 INFO: User cache: /opt/sonar-scanner/.sonar/cache
20:45:17.807 INFO: Load/download plugins
20:45:17.807 INFO: Load plugins index
20:45:17.839 DEBUG: GET 200 ***api/plugins/installed | time=32ms
20:45:26.857 DEBUG: loading config FileBasedConfig[/root/.gitconfig]
20:45:27.000 DEBUG: 498 non excluded files in this Git repository
20:45:27.029 DEBUG: Evaluate issue exclusions for 'webpack.dev.js'
20:45:28.579 INFO: 448 files indexed
20:45:28.579 INFO: 462 files ignored because of inclusion/exclusion patterns
20:45:28.580 INFO: 1 file ignored because of scm ignore settings
20:45:28.581 INFO: Quality profile for css: Sonar way
20:45:39.541 INFO: 29 source files to be analyzed
20:45:39.669 DEBUG: Initializing linter "default" with ucfg,ucfg,u..........
20:46:13.433 INFO: Sensor CSS Rules [javascript] (done) | time=219ms
20:46:13.433 INFO: Sensor JavaScript/TypeScript Coverage [javascript]
20:46:13.434 DEBUG: Property sonar.javascript.lcov.reportPaths is used.
20:46:13.434 DEBUG: Using './unit-tests-coverage/2_lcov.info' to resolve LCOV files
20:46:13.434 DEBUG: Using './unit-tests-coverage/1_lcov.info' to resolve LCOV files
20:46:13.434 DEBUG: Using './unit-tests-coverage/4_lcov.info' to resolve LCOV files
20:46:13.434 DEBUG: Using './unit-tests-coverage/3_lcov.info' to resolve LCOV files
20:46:13.435 INFO: Analysing [/github/workspace/./unit-tests-coverage/2_lcov.info, /github/workspace/./unit-tests-coverage/1_lcov.info, /github/workspace/./unit-tests-coverage/4_lcov.info, /github/workspace/./unit-tests-coverage/3_lcov.info]
20:46:13.529 INFO: Sensor JavaScript/TypeScript Coverage [javascript] (done) | time=96ms
20:46:13.530 INFO: Sensor Import of ESLint issues [javascript]
20:46:13.531 INFO: Importing /github/workspace/./eslint-report/eslint-report.json
20:46:28.808 INFO: ------------------------------------------------------------------------
20:46:28.808 INFO: EXECUTION SUCCESS
20:46:28.808 INFO: ------------------------------------------------------------------------

Hey there.

Take a look at this post.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.