首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >gocov不会将完整的测试覆盖结果上传到codeclimate中

gocov不会将完整的测试覆盖结果上传到codeclimate中
EN

Stack Overflow用户
提问于 2020-08-25 08:54:06
回答 1查看 66关注 0票数 0

基于StackOverflow上的这个question,我将测试覆盖率添加到我的Gitlab CI/CD YAML文件中,我希望结果可以上传到codeclimate中。

代码语言:javascript
复制
- go get github.com/axw/gocov/gocov
- export CC_TEST_REPORTER_ID=My_REPO_ID
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
- gocov test -v ./... -coverprofile=out
- ./cc-test-reporter format-coverage --input-type gocov out
- ./cc-test-reporter upload-coverage

脚本在我的所有包中成功运行test,CI/CD的输出显示运行了不同包中的所有测试,但上传到codeclimate的报告仅显示只有一个具有test-coverage的文件,即最后一个测试包,而不是全部。

EN

回答 1

Stack Overflow用户

发布于 2020-08-25 23:16:02

我在同一个stackoverflow链接中混合了解决方案和另一个答案,最后创建了一个bash文件,并像这样从我的yaml文件运行它,因此报告输出包含所有包报告,这是我的脚本:

代码语言:javascript
复制
go get github.com/axw/gocov/gocov
export CC_TEST_REPORTER_ID=My_ID
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build

for pkg in $(go list ./... | grep -v vendor); do
    go test -coverprofile=$(echo $pkg | tr / -).cover $pkg
done
echo "mode: set" > c.out
grep -h -v "^mode:" ./*.cover >> c.out
rm -f *.cover

./cc-test-reporter after-build
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63570559

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档