github.com/portworx/kvdb@v0.0.0-20241107215734-a185a966f535/Makefile (about)

     1  ifndef PKGS
     2  PKGS := $(shell go list ./... 2>&1 | grep -v test | grep -v mock)
     3  endif
     4  $(info PKGS=$(PKGS))
     5  
     6  HAS_ERRCHECK := $(shell command -v errcheck 2> /dev/null)
     7  
     8  all: test
     9  
    10  vendor:
    11  	go mod download
    12  	go mod tidy -compat=1.20
    13  	go mod vendor
    14  
    15  build:
    16  	@echo ">>> go build"
    17  	go build $(PKGS)
    18  
    19  install:
    20  	@echo ">>> go install"
    21  	go install $(PKGS)
    22  
    23  vet:
    24  	@echo ">>> go vet"
    25  	go vet $(PKGS)
    26  
    27  errcheck:
    28  ifndef HAS_ERRCHECK
    29  	go install github.com/kisielk/errcheck@latest
    30  endif
    31  	@echo ">>> errcheck"
    32  	errcheck \
    33  		github.com/portworx/kvdb \
    34  		github.com/portworx/kvdb/common \
    35  		github.com/portworx/kvdb/consul \
    36  		github.com/portworx/kvdb/mem \
    37  		github.com/portworx/kvdb/wrappers \
    38  		github.com/portworx/kvdb/zookeeper
    39  
    40  pretest: errcheck vet
    41  
    42  gotest:
    43  	@echo ">>> gotest"
    44  ifeq ($(PKGS),"")
    45  	$(error Error: No packages found to test)
    46  endif
    47  	for pkg in $(PKGS); \
    48  		do \
    49  			echo ">>> Testing $${pkg}"; \
    50  			go test --timeout 1h -v -tags unittest -coverprofile=profile.out -covermode=atomic $(BUILD_OPTIONS) $${pkg} || exit 1; \
    51  			if [ -f profile.out ]; then \
    52  				cat profile.out >> coverage.txt; \
    53  				rm profile.out; \
    54  			fi; \
    55  		done
    56  
    57  test: pretest gotest
    58  
    59  docker-build-kvdb-dev:
    60  	docker build -t portworx/kvdb:test_container -f $(GOPATH)/src/github.com/portworx/kvdb/Dockerfile.kvdb .
    61  
    62  docker-test:
    63  	docker run --rm \
    64  		-v $(GOPATH)/src/github.com/portworx/kvdb:/go/src/github.com/portworx/kvdb \
    65  		portworx/kvdb:test_container \
    66  		make gotest
    67  
    68  mockgen:
    69  	go generate -x ./...
    70  
    71  clean:
    72  	go clean -i ./...
    73  
    74  .PHONY: \
    75  	all \
    76  	vendor \
    77  	build \
    78  	install \
    79  	vet \
    80  	errcheck \
    81  	pretest \
    82  	gotest \
    83  	test \
    84  	clean