First off, I am aware, that there are resolved issues that are similar to mine, but I’ve tried every possible answer 50 times, so I think my case might be unique.
I’m trying to upload the lcov.info
coverage data, generated with nyc
of my mocha
tests, to my SonarQube instance.
Unfortunately, no matter what I try, the sonar-scanner can’t seem to find the files indicated in the lcov file:
WARN: Could not resolve 7 file paths in [/github/workspace/coverage/lcov.info]
WARN: First unresolved path: config/file:config/config.ts
Here are some relevant debug logs of the scanner: 2022-06-14T13:54:08.0400335Z ##[group]Run sonarsource/sonarqube-scan-action@mast - Pastebin.com
yarn test: nyc --reporter=lcovonly --reporter=text-summary mocha -r ts-node/register 'tests/run.test.ts'
SonarScanner workflow file:
name: Build
on:
push:
branches: [ master ]
pull_request:
types: [opened, synchronize, reopened]
branches: [ master ]
jobs:
sonarqube:
name: sonarqube
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install dependencies
run: yarn
- name: Run Tests
run: yarn test
## This is one of the suggested fixes.
## Im removing the dir paths that were tested for and make them relative paths.
- name: Fix coverage report
run: sed -i "s+/home/runner/work/rest-api/rest-api/++g" coverage/lcov.info
- name: Run SonarQube Scan
uses: sonarsource/sonarqube-scan-action@master
with:
## used to debug sonarqube-scan-action
args: >
-Dsonar.verbose=true
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
sonar-project.properties
sonar.language=ts
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.sources=.
sonar.tests=tests/
sonar.coverage.exclusions=tests/**
sonar.test.inclusions=tests/**
sonar.projectKey=<PROJECT-KEY>