[skip ci]Add go code coverage (#5024)

Signed-off-by: Xiangyu Wang <xiangyu.wang@zilliz.com>
This commit is contained in:
Xiangyu Wang 2021-04-24 15:10:24 +08:00 committed by GitHub
parent b855c283cb
commit 746fc556a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 0 deletions

4
.gitignore vendored
View File

@ -72,3 +72,7 @@ gtags.conf
# Delve generated file
**/__debug_bin
# go-codecov
coverage.txt
profile.out

View File

@ -154,6 +154,11 @@ test-cpp: build-cpp-with-unittest
@echo "Running cpp unittests..."
@(env bash $(PWD)/scripts/run_cpp_unittest.sh)
# Run go-codecov
go-codecov:
@echo "Running go unittests..."
@(env bash $(PWD)/scripts/run_go_codecov.sh)
#TODO: build each component to docker
docker: verifiers

12
scripts/run_go_codecov.sh Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -e
echo "" > coverage.txt
for d in $(go list ./internal... | grep -v vendor); do
go test -race -coverprofile=profile.out -covermode=atomic "$d"
if [ -f profile.out ]; then
cat profile.out >> coverage.txt
rm profile.out
fi
done