-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
61 lines (45 loc) · 2.26 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
ROOT_PROJECT_NAME := "hcc"
PROJECT_NAME := "cello"
PKG_LIST := $(shell go list ${ROOT_PROJECT_NAME}/${PROJECT_NAME}/...)
.PHONY: all build docker clean gofmt goreport goreport_deb test coverage coverhtml lint
all: build
copy_dir: ## Copy project folder to GOPATH
@mkdir -p $(GOPATH)/src/${ROOT_PROJECT_NAME}
@rm -rf $(GOPATH)/src/${ROOT_PROJECT_NAME}/${PROJECT_NAME}
@cp -Rp `pwd` $(GOPATH)/src/${ROOT_PROJECT_NAME}/${PROJECT_NAME}
lint_dep: ## Get the dependencies for golint
@$(GOROOT)/bin/go get -u golang.org/x/lint/golint
lint: ## Lint the files
@$(GOPATH)/bin/golint -set_exit_status ${PKG_LIST}
test: ## Run unittests
@sudo -E $(GOROOT)/bin/go test -v ${PKG_LIST}
race: ## Run data race detector
@sudo -E $(GOROOT)/bin/go test -race -v ${PKG_LIST}
coverage: ## Generate global code coverage report
@sudo -E $(GOROOT)/bin/go test -v -coverprofile=coverage.out ${PKG_LIST}
@$(GOROOT)/bin/go tool cover -func=coverage.out
coverhtml: coverage ## Generate global code coverage report in HTML
@$(GOROOT)/bin/go tool cover -html=coverage.out
gofmt: ## Run gofmt for go files
@find -name '*.go' -exec $(GOROOT)/bin/gofmt -s -w {} \;
goreport_dep: ## Get the dependencies for goreport
@make lint_dep
@$(GOROOT)/bin/go get -u github.com/gojp/goreportcard/cmd/goreportcard-cli
@rm -f install.sh
goreport: goreport_dep ## Make goreport
@git submodule sync --recursive
@git submodule update --init --recursive
@git --git-dir=$(PWD)/hcloud-badge/.git fetch --all
@git --git-dir=$(PWD)/hcloud-badge/.git checkout feature/dev
@git --git-dir=$(PWD)/hcloud-badge/.git pull origin feature/dev
@./hcloud-badge/hcloud_badge.sh ${PROJECT_NAME}
build: ## Build the binary file
@$(GOROOT)/bin/go build -o ${PROJECT_NAME} main.go
docker: ## Build docker image and push it to private docker registry
@sudo docker build -t ${PROJECT_NAME} .
@sudo docker tag ${ROOT_PROJECT_NAME}_${PROJECT_NAME}:latest 192.168.110.250:5000/${PROJECT_NAME}:latest
@sudo docker push 192.168.110.250:5000/${PROJECT_NAME}:latest
clean: ## Remove previous build
@rm -f ${PROJECT_NAME}
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}'