54 lines
2.0 KiB
Makefile
54 lines
2.0 KiB
Makefile
|
PROJECT_NAME := cmdb
|
||
|
OUTPUT_NAME := cmdb
|
||
|
MAIN_FILE := main.go
|
||
|
PKG := gitlab.com/go-course-project/go17/devcloud-mini/cmdb
|
||
|
|
||
|
.PHONY: all dep lint vet test test-coverage build clean
|
||
|
|
||
|
all: build
|
||
|
|
||
|
dep: ## Get the dependencies
|
||
|
@go mod tidy
|
||
|
|
||
|
lint: ## Lint Golang files
|
||
|
@golint -set_exit_status ${PKG_LIST}
|
||
|
|
||
|
vet: ## Run go vet
|
||
|
@go vet ${PKG_LIST}
|
||
|
|
||
|
test: ## Run unittests
|
||
|
@go test -short ${PKG_LIST}
|
||
|
|
||
|
test-coverage: ## Run tests with coverage
|
||
|
@go test -short -coverprofile cover.out -covermode=atomic ${PKG_LIST}
|
||
|
@cat cover.out >> coverage.txt
|
||
|
|
||
|
build: dep ## Build the binary file
|
||
|
@go build -a -o dist/${OUTPUT_NAME} -ldflags "-s -w" -ldflags "-X '${VERSION_PATH}.GIT_BRANCH=${BUILD_BRANCH}' -X '${VERSION_PATH}.GIT_COMMIT=${BUILD_COMMIT}' -X '${VERSION_PATH}.BUILD_TIME=${BUILD_TIME}' -X '${VERSION_PATH}.GO_VERSION=${BUILD_GO_VERSION}'" ${MAIN_FILE}
|
||
|
|
||
|
linux: dep ## Build the binary file
|
||
|
@GOOS=linux GOARCH=amd64 go build -a -o dist/${OUTPUT_NAME} -ldflags "-s -w" -ldflags "-X '${VERSION_PATH}.GIT_BRANCH=${BUILD_BRANCH}' -X '${VERSION_PATH}.GIT_COMMIT=${BUILD_COMMIT}' -X '${VERSION_PATH}.BUILD_TIME=${BUILD_TIME}' -X '${VERSION_PATH}.GO_VERSION=${BUILD_GO_VERSION}'" ${MAIN_FILE}
|
||
|
|
||
|
init: dep ## Inital project
|
||
|
@go run main.go init
|
||
|
|
||
|
run: dep ## Run Server
|
||
|
@go run main.go start
|
||
|
|
||
|
clean: ## Remove previous build
|
||
|
@go clean .
|
||
|
@rm -f dist/${PROJECT_NAME}
|
||
|
|
||
|
install: ## Install depence go package
|
||
|
@go install github.com/infraboard/mcube/v2/cmd/mcube@latest
|
||
|
@go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
|
||
|
@go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
|
||
|
@go install github.com/favadi/protoc-go-inject-tag@latest
|
||
|
|
||
|
pb: ## Copy mcube protobuf files to common/pb
|
||
|
@mkdir -pv common/pb/github.com/infraboard/mcube/v2/pb
|
||
|
@cp -r ${MCUBE_PKG_PATH}/pb/* common/pb/github.com/infraboard/mcube/v2/pb
|
||
|
@sudo rm -rf common/pb/github.com/infraboard/mcube/v2/pb/*/*.go
|
||
|
|
||
|
help: ## Display this help screen
|
||
|
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|