I am running into a problem where SonarQube does not display code coverage information even though the coverage/lcov.info
file is successfully generated. Here are the details of my setup:
What am I doing wrong? I really got stuck and could not find any meaningful logs.
Sonar Logs
sonar.txt (40.0 KB)
sonar-project.properties
sonar.projectKey=sp-integration-watchtower_31db6318-6261-40f0-a837-89103cda2c15
sonar.projectName=sp-integration-watchtower
sonar.sources=.
sonar.tests=.
sonar.exclusions=**/node_modules/**, **/*.md
sonar.language=ts
sonar.test.inclusions = **/*.test.ts, **/*.test.tsx
sonar.coverage.exclusions=**/*.test.ts,**/*.test.tsx
sonar.javascript.lcov.reportPaths=coverage/lcov.info
jest.config.js
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: "ts-jest",
transform: {
"^.+\\.tsx?$": "ts-jest",
"^.+\\.(js|jsx)$": "babel-jest",
"node_modules/variables/.+\\.(j|t)sx?$": "babel-jest",
},
coverageDirectory: "coverage",
collectCoverage: true,
collectCoverageFrom: ["**/*.{ts, tsx, js}", "!**/node_modules/**"],
reporters: [["github-actions", { silent: false }], "summary"],
coverageThreshold: {
global: {
lines: 10,
},
},
};
GitHub Actions Workflow (relevant part)
.....
test:
name: Test
runs-on: az-weu-ubuntu-20.04-amd64-8cpu
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
node-version: [20.x]
needs: build
steps:
- name: Checkout repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v1.4.7
with:
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
cache-dependency-path: "package-lock.json"
- name: Install dependencies
run: npm ci
- name: Run Jest
run: npm run test --if-present
continue-on-error: true
- name: Coverage
run: |
pwd
cd coverage
ls -la
- name: SonarQube Scan
uses: sonarsource/sonarqube-scan-action@aecaf43ae57e412bd97d70ef9ce6076e672fe0a9 #v2.3.0
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
- name: SonarQube Quality Gate
uses: sonarsource/sonarqube-quality-gate-action@d304d050d930b02a896b0f85935344f023928496 #v1.1.0
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}