-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
124 lines (101 loc) · 2.72 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
SRCS := $(shell find . -name '*.go')
LINTERS := \
golang.org/x/lint/golint \
honnef.co/go/tools/cmd/staticcheck
APP_NAME := gh-contributions-plus-plus
BANNER:=\
"\n"\
"/**\n"\
" * @project $(APP_NAME)\n"\
" */\n"\
"\n"
## build.linux : Build application for Linux runtime
.PHONY: build.linux
build.linux:
env GOOS=linux go build -ldflags="-s -w" -o bin/$(APP_NAME) cmd/server/main.go
## build.mac : Build application for Mac runtime
.PHONY: build.mac
build.mac:
env GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o bin/$(APP_NAME) cmd/server/main.go
## clean : Clean application objects
.PHONY: clean
clean:
go clean -i ./...
## deps : Download dependencies
.PHONY: deps
deps:
go get -d -v ./...
## docker.build : Build application as docker
.PHONY: docker.build
docker.build:
docker build . -t $(APP_NAME)
## docker.run : Run application in docker
.PHONY: docker.run
docker.run:
docker run -p 3000:3000 $(APP_NAME)
## docker : Build and run application as docker
.PHONY: docker
docker: docker.build docker.run
## golint : Run golint on all *.go files
.PHONY: golint
golint:
for file in $(SRCS); do \
golint $${file}; \
if [ -n "$$(golint $${file})" ]; then \
exit 1; \
fi; \
done
## help : Show all available make targets
.PHONY : help
help :
@echo $(BANNER)
@echo \\tMake targets
@echo -----------------------------
@sed -n 's/^##//p' Makefile | sort
## install : Install dependencies
.PHONY: install
install: deps
go install ./...
## lint : Run golint, vet and staticcheck
.PHONY: lint
lint: golint vet staticcheck
## run : Run application from main.go
.PHONY: run
run:
go run cmd/server/main.go
## server.start : Run application as server from runtime binary
.PHONY: server.start
server.start:
./bin/$(APP_NAME)
## sls.build : Build application for Linux runtime
.PHONY: sls.build
sls.build:
env GOOS=linux go build -ldflags="-s -w" -o bin/$(APP_NAME) cmd/serverless/main.go
## sls.deploy : Deploy application as serverless
.PHONY: sls.deploy
sls.deploy:
sls deploy -v
## sls : Build and deploy application as serverless
.PHONY: sls
sls: build.linux deploy.sls
## staticcheck : Run staticcheck
.PHONY: staticcheck
staticcheck:
staticcheck ./...
## test : Run tests
.PHONY: test
test:
ENV=test go test -v -race -coverprofile=coverage.out ./...
## test.coverage : Show test coverage report
.PHONY: test.coverage
test.coverage:
go tool cover -html=coverage.out
## testdeps : Download test dependencies
.PHONY: testdeps
testdeps:
go get -d -v -t ./...
go get -v $(LINTERS)
## vet : Run vet
.PHONY: vet
vet:
go vet ./...