-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathMakefile
78 lines (58 loc) · 1.78 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
OS = Linux
VERSION = 0.0.1
ROOT_PACKAGE=github.com/hoorayman/popple
CURDIR = $(shell pwd)
SOURCEDIR = $(CURDIR)
COVER = $($3)
ECHO = echo
RM = rm -rf
MKDIR = mkdir
CLIENT = github.com/hoorayman/popple/cmd/popcli
.PHONY: test grpc
default: test lint vet
test:
go test -v ./...
race:
go test -cover=true -race $(PACKAGES)
# http://golang.org/cmd/go/#hdr-Run_gofmt_on_package_sources
fmt:
go fmt ./...
# https://godoc.org/golang.org/x/tools/cmd/goimports
imports:
goimports -e -d -w -local $(ROOT_PACKAGE) ./
# https://github.com/golang/lint
# go get github.com/golang/lint/golint
lint:
golint ./...
# http://godoc.org/code.google.com/p/go.tools/cmd/vet
# go get code.google.com/p/go.tools/cmd/vet
vet:
go vet ./...
tidy:
go mod tidy
all: test
grpc:
sh ./scripts/grpc.sh
#grpc-go:
# bash ./scripts/grpc-go.sh
#
init:
bash ./scripts/init.sh
BUILD_PATH = $(shell if [ "$(CI_DEST_DIR)" != "" ]; then echo "$(CI_DEST_DIR)" ; else echo "$(PWD)"; fi)
build:
@$(ECHO) "Will build on "$(BUILD_PATH)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -ldflags "-w -s" -v -o $(BUILD_PATH)/bin/${MODULE} $(ROOT_PACKAGE)
client:
@$(ECHO) "Will build on "$(BUILD_PATH)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -ldflags "-w -s" -v -o $(BUILD_PATH)/bin/${MODULE} ${CLIENT}
help:
@$(ECHO) "Targets:"
@$(ECHO) "all - test"
@$(ECHO) "test - run all unit tests"
@$(ECHO) "race - run all unit tests in race condition"
@$(ECHO) "fmt - run go fmt command to format code"
@$(ECHO) "lint - run go lint command to check code style"
@$(ECHO) "vet - run go vet command to check code errors"
@$(ECHO) "build - build and exports using CI_DEST_DIR"
@$(ECHO) "grpc - run 'grpc-gen-pb' and 'grpc-go-mock'"
@$(ECHO) "init - init the project"