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!