-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
71 lines (56 loc) · 2.12 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
MODULE = $(shell go list -m)
VERSION ?= $(shell git describe --tags --always --dirty --match=v* 2> /dev/null || echo "1.0.0")
PACKAGES := $(shell go list ./... | grep -v /vendor/)
LDFLAGS := -ldflags "-X main.Version=${VERSION}"
CONFIG_FILE ?= ./configs/local.yml
APP_DSN ?= $(shell sed -n 's/^dsn:[[:space:]]*"\(.*\)"/\1/p' $(CONFIG_FILE))
PID_FILE := './.pid'
FSWATCH_FILE := './fswatch.cfg'
.PHONY: default
default: help
# generate help info from comments: thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.PHONY: help
help: ## help information about make commands
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: test
test: ## run unit tests
@echo "mode: count" > coverage-all.out
@$(foreach pkg,$(PACKAGES), \
go test -p=1 -cover -covermode=count -coverprofile=coverage.out ${pkg}; \
tail -n +2 coverage.out >> coverage-all.out;)
.PHONY: test-cover
test-cover: test ## run unit tests and show test coverage information
go tool cover -html=coverage-all.out
.PHONY: run
run: ## run the API server
go run ${LDFLAGS} cmd/excel/main.go -config=./configs/local.yml
.PHONY: build-excel
build-excel: ## build the API server binary
CGO_ENABLED=0 go build -o excel cmd/excel/main.go
chmod 0755 excel
.PHONY: build-notification
build-notification: ## build the API server binary
CGO_ENABLED=0 go build -o notification cmd/notification/main.go
chmod 0755 notification
.PHONY: clean
clean: ## remove temporary files
rm -rf server coverage.out coverage-all.out
.PHONY: version
version: ## display the version of the API server
@echo $(VERSION)
.PHONY: lint
lint: ## run golint on all Go package
@golint $(PACKAGES)
.PHONY: fmt
fmt: ## run "go fmt" on all Go packages
@go fmt $(PACKAGES)
.PHONY: server
server: ## start go-excel server
CGO_ENABLED=0 go build -o excel cmd/excel/main.go
chmod 0755 excel
supervisorctl restart go-excel
.PHONY: notification
notification: ## start notification
CGO_ENABLED=0 go build -o notification cmd/notification/main.go
chmod 0755 notification
supervisorctl restart go-notification