github动作声纳扫描仪可以在lcov.info中解决文件路径
首先,我知道,有一些与我相似的问题,但是我尝试了所有可能的答案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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论