diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index d6fda7fbcb..780325ad26 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -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: diff --git a/Makefile b/Makefile index 6e79e35513..6f3a0c1fb2 100644 --- a/Makefile +++ b/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..." diff --git a/scripts/run_go_codecov.sh b/scripts/run_go_codecov.sh index e3f9b9750f..56ae9a4d35 100755 --- a/scripts/run_go_codecov.sh +++ b/scripts/run_go_codecov.sh @@ -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