github.com/projecteru2/core@v0.0.0-20240321043226-06bcc1c23f58/Makefile (about) 1 .PHONY: grpc deps binary build test mock cloc unit-test 2 3 REPO_PATH := github.com/projecteru2/core 4 REVISION := $(shell git rev-parse HEAD || unknown) 5 BUILTAT := $(shell date +%Y-%m-%dT%H:%M:%S) 6 VERSION := $(shell git describe --tags $(shell git rev-list --tags --max-count=1)) 7 GO_LDFLAGS ?= -X $(REPO_PATH)/version.REVISION=$(REVISION) \ 8 -X $(REPO_PATH)/version.BUILTAT=$(BUILTAT) \ 9 -X $(REPO_PATH)/version.VERSION=$(VERSION) 10 ifneq ($(KEEP_SYMBOL), 1) 11 GO_LDFLAGS += -s 12 endif 13 14 grpc: 15 protoc --go_out=. --go-grpc_out=. \ 16 --go_opt=paths=source_relative \ 17 --go-grpc_opt=require_unimplemented_servers=false,paths=source_relative \ 18 ./rpc/gen/core.proto 19 20 deps: 21 go mod vendor 22 23 binary: 24 CGO_ENABLED=1 go build -mod=readonly -ldflags "$(GO_LDFLAGS)" -o eru-core 25 26 build: deps binary 27 28 test: deps unit-test 29 30 mock: deps 31 mockery --dir vendor/google.golang.org/grpc --output 3rdmocks --name ServerStream 32 mockery --dir vendor/github.com/docker/docker/client --output engine/docker/mocks --name APIClient 33 mockery --dir source --output source/mocks --name Source 34 mockery --dir store --output store/mocks --name Store 35 mockery --dir engine --output engine/mocks --name API 36 mockery --dir cluster --output cluster/mocks --name Cluster 37 mockery --dir wal --output wal/mocks --name WAL 38 mockery --dir lock --output lock/mocks --name DistributedLock 39 mockery --dir store/etcdv3/meta --output store/etcdv3/meta/mocks --all 40 mockery --dir vendor/go.etcd.io/etcd/client/v3 --output store/etcdv3/meta/mocks --name Txn 41 mockery --dir rpc/gen/ --output rpc/mocks --name CoreRPC_RunAndWaitServer 42 mockery --dir resource --output resource/mocks --name Manager 43 mockery --dir resource/plugins --output resource/plugins/mocks --name Plugin 44 45 .ONESHELL: 46 47 cloc: 48 cloc --exclude-dir=vendor,3rdmocks,mocks,tools,gen --not-match-f=test . 49 50 unit-test: 51 go vet `go list ./... | grep -v '/vendor/' | grep -v '/tools'` && \ 52 go test -race -timeout 600s -count=1 -vet=off -cover ./utils/... \ 53 ./types/... \ 54 ./store/etcdv3/. \ 55 ./store/etcdv3/embedded/. \ 56 ./store/etcdv3/meta/. \ 57 ./source/common/... \ 58 ./strategy/... \ 59 ./rpc/. \ 60 ./engine/. \ 61 ./lock/etcdlock/... \ 62 ./auth/simple/... \ 63 ./discovery/helium... \ 64 ./resource/types/. \ 65 ./resource/plugins/cpumem/. \ 66 ./resource/plugins/cpumem/schedule/. \ 67 ./wal/. \ 68 ./wal/kv/. \ 69 ./store/redis/... \ 70 ./lock/redis/... && \ 71 go test -timeout 600s -count=1 -cover ./cluster/calcium/... 72 73 lint: 74 golangci-lint run