圆形覆盖- github- 报告器
Jest报告/伊斯坦布尔从CircleCI到GitHub的覆盖统计.
基于 覆盖-github-报告员。 。 。 .
设置
GitHub Auth 托肯语
GitHub 认证符号需要发布到 github 上的评论 。 我建议建立一个单独的"机器人"GitHub账户 进入你的仓库.
- 导航到 个人访问标志 关于 GitHub 的
- 点击"Generate新令牌"并生成新令牌(与 还原 访问,如果您的回购是私人的)
- 打开 CircleCI 项目设置
- 构建设置的导航 > 环境变量
- 添加新变量
GH_AUTH_TOKEN带有新符号
以后的项目:
- 打开 CircleCI 项目设置
- 构建设置的导航 > 环境变量
- 单击“导入变量”
- 选择您先前添加的工程
GH_AUTH_TOKEN改为 - 单击旁边的复选框
GH_AUTH_TOKEN导入
CircleCI 人工活性 API 托肯
要获取私人取回的文物,需要CircleCI API令牌.
- 打开 CircleCI 项目设置
- 导航权限 > API 权限
- 点击“ 创建托肯”
- 从瞄准镜倒下选择“ 已建成的艺术”
- 将符号命名为“ 艺术”( 或随你喜欢的)
- 构建设置的导航 > 环境变量
- 添加新变量
CIRCLE_CI_API_TOKEN带有新符号
以覆盖度报告运行 Jest
添加到您的 package.json数字 :
npm install --save-dev @godaddy-wordpress/circleci-coverage-github-reporter
如果你使用杰斯特,我建议添加一个测试脚本 按照这些思路:
"scripts": {
"test-ci": "jest --ci --silent --coverage"
}
这将产生覆盖 coverage/
CircleCI 配置
更新您的 .circleci/config.yml数字 :
general:
artifacts:
- "coverage/lcov-report"
jobs:
build:
steps:
# … other steps (npm/yarn install, lint, etc)
- run:
name: Test
command: npm run test-ci
# Store coverage artifacts so they can be browsed and be diffed by other builds
- store_artifacts:
path: coverage
destination: coverage
- run:
name: Post coverage comment to GitHub
command: npx circleci-coverage-github-reporter
自定义
这个 circleci-coverage-github-reporter CLI 有一些自定义行为的选项:
Options:
-v, --verbose [true, false] Defaults to true
-b, --branch [value] Base branch to use if not PR (defaults to "master")
-j, --coverage-json [value] Relative path to istanbul coverage JSON (defaults to "coverage/coverage-final.json")
-r, --coverage-root [value] Relative path to coverage html root (for artifact links) (defaults to "coverage/lcov-report")
-h, --help Output usage information
-v, --version Output the version number