gpt4 book ai didi

angular - Codecov、Github 操作和 Angular 11 "No coverage report found"

转载 作者:行者123 更新时间:2023-12-05 01:32:30 26 4
gpt4 key购买 nike

我正在尝试通过 Github 操作将 Angular (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.1

package.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目录下创建

enter image description here

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

enter image description here

为什么本地生成的文件找不到? Codecov 会寻找不同的报告扩展名吗?我怎样才能让它发挥作用?

最佳答案

这是因为 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 脚本将毫无问题地上传您的报告。

关于angular - Codecov、Github 操作和 Angular 11 "No coverage report found",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65450932/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com