Hello,
We are trying to get code coverage information on SonarCloud dashboard and in the Github PR :
As you can see, it detect 0% coverage but we do have some coverage :
Our setup is the following:
Github sonar workflow
name: Sonar
on:
push:
branches:
- develop
pull_request:
types: [opened, synchronize, reopened]
jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
token: ${{ secrets.PAT_TOKEN }}
- name: Use Node.js 12
uses: actions/setup-node@v1
with:
node-version: 12
- run: npm run install:all
- run: npm run cover
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
sonar-project.properties
sonar.projectKey=******
sonar.organization=******
sonar.projectName=******
sonar.projectVersion=1.0
sonar.sources=src/**/cartridges/**/cartridge/
sonar.exclusions=src/**/cartridges/app_storefront_base/**/*, metadata/**/*, node_modules/**, .idea/**/*, .vscode/**/*, test/reports/**/*, **/jobs/decisionManager.js, **/jobsteps/OrderStatus.js, test/integration/**/*, .scannerwork/**/*, src/submodules/**/*
sonar.javascript.lcov.reportPaths=coverage/lcov.info,test/reports/coverage/lcov.info
sonar.coverage.exclusions=test/**/*, src/**/cartridges/**/cartridge/controllers/**
# Encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8
package.json (relevant part only):
{
"name": "****",
"version": "0.0.1",
"description": "New overlay cartridge",
"main": "index.js",
"scripts": {
"install:all": "npm install && node .utils/install.js all",
"install:cartridge": "node .utils/install.js cartridge=%npm_config_name%",
"test": "sgmf-scripts --test 'test/unit/**/*.js'",
"cover": "sgmf-scripts --cover 'test/unit/**/*.js' --exclude app_path.js",
"cover:report": "istanbul cover node_modules/mocha/bin/_mocha --dir test/reports/coverage/ -- -R spec --recursive test/unit/**/*.js",
"git:submodule:update": "git submodule update --init --recursive",
"dev": "webpack --env.dev --env.map=%npm_config_source_map%",
"build": "webpack --env.dev=false",
Relevant github action workflow part:
Any help is greatly appreciated.
Thank you!