github动作声纳扫描仪可以在lcov.info中解决文件路径

发布于 2025-02-07 04:08:34 字数 2119 浏览 2 评论 0原文

首先,我知道,有一些与我相似的问题,但是我尝试了所有可能的答案50次,所以我认为我的情况可能是独一无二的。

我正在尝试将lcov.info覆盖范围数据上传,该数据由我的mocha测试的nyc生成,并将其上传到我的Sonarqube实例。 不幸的是,无论我尝试什么,Sonar-Scanner似乎都找不到LCOV文件中指示的文件:

WARN: Could not resolve 7 file paths in [/github/workspace/coverage/lcov.info]
WARN: First unresolved path: config/file:config/config.ts

以下是扫描仪的一些相关调试日志: https://pastebin.com/n8hhzmg4

yarn test: nyc -reporter = lcovonly -reporter -reporter -reporter = text -summary mocha -r -r -r -r TS节点/寄存器'tests/run.test.ts'

sonarscanner工作流文件:

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>

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文