Merge pull request #4853 from khanhtc1202/adopt-gotestsum

Adopt gotestsum
This commit is contained in:
karmada-bot 2024-04-22 09:13:18 +08:00 committed by GitHub
commit e100008d03
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 15 deletions

View File

@ -87,7 +87,7 @@ jobs:
needs: build needs: build
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
env: env:
COLOR_GOTEST_ENABLED: enabled GOTESTSUM_ENABLED: enabled
steps: steps:
- name: checkout code - name: checkout code
uses: actions/checkout@v3 uses: actions/checkout@v3

View File

@ -102,26 +102,27 @@ push-chart:
helm push _output/charts/karmada-chart-${VERSION}.tgz oci://docker.io/karmada helm push _output/charts/karmada-chart-${VERSION}.tgz oci://docker.io/karmada
helm push _output/charts/karmada-operator-chart-${VERSION}.tgz oci://docker.io/karmada helm push _output/charts/karmada-operator-chart-${VERSION}.tgz oci://docker.io/karmada
COLOR_GOTEST_REGISTRY:=github.com/rakyll/gotest GOTESTSUM_REGISTRY:=gotest.tools/gotestsum
COLOR_GOTEST_VERSION:=aeb9f1f4739020c60963f21eec2e65672307a9ac GOTESTSUM_VERSION:=ec99a250836f069a524bb9d9b5de0a7a96334ea7 # v1.11.0
COLOR_GOTEST_ENABLED?= GOTESTSUM_FLAGS?=--format testname
GOTEST_PALETTE?=hired,higreen GOTESTSUM_ENABLED?=
GOTEST=go test GOTEST=go test
.PHONY: install_gotest .PHONY: install_gotestsum
install_gotest: install_gotestsum:
ifdef COLOR_GOTEST_ENABLED ifdef GOTESTSUM_ENABLED
go install ${COLOR_GOTEST_REGISTRY}@${COLOR_GOTEST_VERSION} go install ${GOTESTSUM_REGISTRY}@${GOTESTSUM_VERSION}
GOTEST=gotest GOTEST=gotestsum ${GOTESTSUM_FLAGS} --
endif endif
.PHONY: test .PHONY: test
test: install_gotest test: GO_TEST_FLAGS ?= --race --v -covermode=atomic
test: install_gotestsum
mkdir -p ./_output/coverage/ mkdir -p ./_output/coverage/
$(GOTEST) --race --v ./pkg/... -coverprofile=./_output/coverage/coverage_pkg.txt -covermode=atomic $(GOTEST) $(GO_TEST_FLAGS) ./pkg/... -coverprofile=./_output/coverage/coverage_pkg.txt
$(GOTEST) --race --v ./cmd/... -coverprofile=./_output/coverage/coverage_cmd.txt -covermode=atomic $(GOTEST) $(GO_TEST_FLAGS) ./cmd/... -coverprofile=./_output/coverage/coverage_cmd.txt
$(GOTEST) --race --v ./examples/... -coverprofile=./_output/coverage/coverage_examples.txt -covermode=atomic $(GOTEST) $(GO_TEST_FLAGS) ./examples/... -coverprofile=./_output/coverage/coverage_examples.txt
$(GOTEST) --race --v ./operator/... -coverprofile=./_output/coverage/coverage_operator.txt -covermode=atomic $(GOTEST) $(GO_TEST_FLAGS) ./operator/... -coverprofile=./_output/coverage/coverage_operator.txt
upload-images: images upload-images: images
@echo "push images to $(REGISTRY)" @echo "push images to $(REGISTRY)"