我正试图通过Github操作将角(v11)库的代码覆盖发布到Codecov.io。
我已经在市场上设置了Codecov github的官方行动
name: tests
on:
pull_request:
branches: [ master ]
jobs:
build:
# Machine environment:
# We specify the Node.js version manually below, and use versioned Chrome from Puppeteer.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14
uses: actions/setup-node@v1
with:
node-version: 14
- name: Install dependencies
run: npm install
- name: Build
run: npm run build-lib
- name: Test
run: npm run test-lib-headless
- name: Codecov
uses: codecov/codecov-action@v1.1.1package.json中的任务
"test-lib-headless": "ng test ngx-scrollbar --watch=false --no-progress --browsers=ChromeHeadless --code-coverage",karma.conf.js
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
jasmine: {
// you can add configuration options for Jasmine here
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
// for example, you can disable the random execution with `random: false`
// or set a specific seed with `seed: 4321`
},
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
jasmineHtmlReporter: {
suppressAll: true // removes the duplicated traces
},
coverageReporter: {
dir: require('path').join(__dirname, './coverage'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' }
]
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
customLaunchers: {
ChromeHeadlessCI: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
},
singleRun: false,
restartOnFileChange: true,
capabilities: {
chromeOptions: {
args: ["--headless"]
},
'browserName': 'chrome'
},
});
};覆盖文件在coverage目录中创建。

在Github CI中,它显示codecov没有找到文件!

为什么在本地生成的文件都找不到?科德科夫是否在寻找不同的报告分机?我怎么才能让它起作用?
发布于 2021-01-14 19:42:47
这是因为codecov不支持默认生成的覆盖率报告。
简单的解决方案就是将lcov报告添加到配置中。
https://istanbul.js.org/docs/advanced/alternative-reporters/#lcovonly
coverageReporter: {
dir: require('path').join(__dirname, './coverage/peach-tree'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' },
{ type: 'lcovonly' },
]
},然后由codecov提供的bash脚本将上传您的报告,没有任何问题。
https://stackoverflow.com/questions/65450932
复制相似问题