mirror of https://github.com/milvus-io/milvus.git
enhance: Use gotestsum to run go unit test (#31622)
See also #31490 --------- Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>pull/31615/head^2
parent
5be395354c
commit
f399416b92
|
@ -174,7 +174,7 @@ jobs:
|
|||
run: |
|
||||
chmod +x build/builder.sh
|
||||
chmod +x scripts/run_go_codecov.sh
|
||||
./build/builder.sh /bin/bash -c ./scripts/run_go_codecov.sh
|
||||
./build/builder.sh /bin/bash -c "make codecov-go-without-build"
|
||||
- name: Archive result
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
|
|
9
Makefile
9
Makefile
|
@ -178,10 +178,6 @@ INTERATION_PATH = $(PWD)/tests/integration
|
|||
integration-test: getdeps
|
||||
@echo "Building integration tests ..."
|
||||
@(env bash $(PWD)/scripts/run_intergration_test.sh "$(INSTALL_PATH)/gotestsum --")
|
||||
#@source $(PWD)/scripts/setenv.sh && \
|
||||
mkdir -p $(INSTALL_PATH) && go env -w CGO_ENABLED="1" && \
|
||||
GO111MODULE=on $(GO) build -ldflags="-r $${RPATH} -X '$(OBJPREFIX).BuildTags=$(BUILD_TAGS)' -X '$(OBJPREFIX).BuildTime=$(BUILD_TIME)' -X '$(OBJPREFIX).GitCommit=$(GIT_COMMIT)' -X '$(OBJPREFIX).GoVersion=$(GO_VERSION)'" \
|
||||
-tags dynamic -o $(INSTALL_PATH)/integration-test $(INTERATION_PATH)/ #1>/dev/null
|
||||
|
||||
BUILD_TAGS = $(shell git describe --tags --always --dirty="-dev")
|
||||
BUILD_TAGS_GPU = ${BUILD_TAGS}-gpu
|
||||
|
@ -330,6 +326,11 @@ codecov-go: build-cpp-with-coverage
|
|||
@echo "Running go coverage..."
|
||||
@(env bash $(PWD)/scripts/run_go_codecov.sh)
|
||||
|
||||
# Run codecov-go without build core again, used in github action
|
||||
codecov-go-without-build: getdeps
|
||||
@echo "Running go coverage..."
|
||||
@(env bash $(PWD)/scripts/run_go_codecov.sh "$(INSTALL_PATH)/gotestsum --")
|
||||
|
||||
# Run codecov-cpp
|
||||
codecov-cpp: build-cpp-with-coverage
|
||||
@echo "Running cpp coverage..."
|
||||
|
|
|
@ -28,10 +28,15 @@ echo "mode: atomic" > ${FILE_COVERAGE_INFO}
|
|||
# run unittest
|
||||
echo "Running unittest under ./internal & ./pkg"
|
||||
|
||||
TEST_CMD=$@
|
||||
if [ -z "$TEST_CMD" ]; then
|
||||
TEST_CMD="go test"
|
||||
fi
|
||||
|
||||
# starting the timer
|
||||
beginTime=`date +%s`
|
||||
for d in $(go list ./internal/... | grep -v -e vendor -e kafka -e planparserv2/generated -e mocks); do
|
||||
go test -race -tags dynamic -v -coverpkg=./... -coverprofile=profile.out -covermode=atomic "$d"
|
||||
$TEST_CMD -race -tags dynamic -v -coverpkg=./... -coverprofile=profile.out -covermode=atomic "$d"
|
||||
if [ -f profile.out ]; then
|
||||
grep -v kafka profile.out | grep -v planparserv2/generated | grep -v mocks | sed '1d' >> ${FILE_COVERAGE_INFO}
|
||||
rm profile.out
|
||||
|
@ -39,7 +44,7 @@ for d in $(go list ./internal/... | grep -v -e vendor -e kafka -e planparserv2/g
|
|||
done
|
||||
pushd pkg
|
||||
for d in $(go list ./... | grep -v -e vendor -e kafka -e planparserv2/generated -e mocks); do
|
||||
go test -race -tags dynamic -v -coverpkg=./... -coverprofile=profile.out -covermode=atomic "$d"
|
||||
$TEST_CMD -race -tags dynamic -v -coverpkg=./... -coverprofile=profile.out -covermode=atomic "$d"
|
||||
if [ -f profile.out ]; then
|
||||
grep -v kafka profile.out | grep -v planparserv2/generated | grep -v mocks | sed '1d' >> ../${FILE_COVERAGE_INFO}
|
||||
rm profile.out
|
||||
|
|
Loading…
Reference in New Issue