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
congqixia 2024-03-27 15:29:10 +08:00 committed by GitHub
parent 5be395354c
commit f399416b92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 7 deletions

View File

@ -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:

View File

@ -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..."

View File

@ -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