2

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: https://pastebin.com/n8hhzMG4

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>
Mavial
  • 31
  • 6
  • Please copy/paste relevant error messages directly into the question in order for people with the same problem to find your question. – rethab Jun 15 '22 at 06:01
  • The important error message is in the question: ```WARN: Could not resolve 7 file paths in [/github/workspace/coverage/lcov.info] WARN: First unresolved path: config/file:config/config.ts ``` – Mavial Jun 15 '22 at 10:31

0 Answers0