gpt4 book ai didi

node.js - Gitlab 测试覆盖率可视化不起作用

转载 作者:行者123 更新时间:2023-12-03 17:09:21 26 4
gpt4 key购买 nike

大家好,我有一个快速应用程序,我正在使用 gitlab 添加 Gitlab test coverage visualization
这是我的 .gitlab-ci.yml

stages:
- test
- dockerize
- staging
- production

unit-tests:
stage: test
script:
- npm install
- npm run test
- npm run test-coverage
- cat coverage/cobertura-coverage.xml
- "echo 'Code coverage: 90.90'"
coverage: '/Code coverage: \d+\.\d+/'
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH == "master"'
- if: '$CI_COMMIT_BRANCH == "release-v1"'
artifacts:
reports:
cobertura: coverage/cobertura-coverage.xml
tags:
- demo

dockerize-application:
stage: dockerize
script:
- echo "dockerizing application"
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH == "master"'
- if: '$CI_COMMIT_BRANCH == "release-v1"'
tags:
- demo


deploy_to_staging:
stage: staging
script:
- echo "deploying to staging"
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
tags:
- demo

deploy_to_production:
stage: staging
script:
- echo "deploying to production"
rules:
- if: '$CI_COMMIT_BRANCH == "release-v1"'
tags:
- demo
在我的包 json 中,这里是重要的部分:
"scripts": {
"start": "node ./bin/www",
"debug": "nodemon ./bin/www",
"test": "npx nyc --reporter text mocha",
"test-coverage": "npx nyc --reporter cobertura mocha"
}
在日志中,我可以看到覆盖文件已上传。
Runtime platform                                    arch=amd64 os=windows pid=19548 revision=775dd39d version=13.8.0
coverage/cobertura-coverage.xml: found 1 matching files and directories
Uploading artifacts as "cobertura" to coordinator... ok id=1097622443 responseStatus=201 Created token=6wcrN_d_
我做了很多研究,但我仍然不明白为什么!我认为这是一个功能标志,默认情况下关闭此功能,但不再关闭:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/43711
这是 link到我的项目:我主要是为了试验 gitlab ci/cd 而创建的

最佳答案

它现在正在工作。问题是我需要等待整个管道成功才能真正看到可视化。
这是一个在 Gitlab 中打开的问题:
https://gitlab.com/gitlab-org/gitlab/-/issues/236248

关于node.js - Gitlab 测试覆盖率可视化不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66632969/

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