-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
68 lines (54 loc) · 2.02 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
# Change these variables as necessary.
MAIN_PACKAGE_PATH := ./cmd/
BINARY_NAME := dfaas
EXCLUDE_TEST := "TestContext"
# ==================================================================================== #
# HELPERS
# ==================================================================================== #
## help: print this help message
.PHONY: help
help:
@echo 'Usage:'
@sed -n s/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /
.PHONY: protobuf
protobuf:
protoc -I./proto --go_out=./proto --go_opt=paths=source_relative ./proto/*.proto
## test: run all tests
.PHONY: test
test: protobuf
go test -v -race -buildvcs $(shell go list ./... | grep -v 'runtime/')
## local/test: Exclude tests which can break local environment (like context)
.PHONY: local/test
local/test:
go test -v -race -buildvcs -tags exclude $(shell go list ./... | grep -v 'runtime/')
fmt:
@gofmt -l -w $(shell find . -type f -name '*.go' -not -path "./vendor/*")
lint:
golangci-lint run
## test/cover: run all tests and display coverage
.PHONY: test/cover
test/cover: protobuf
go test -v -race -buildvcs -coverprofile=/tmp/coverage.out $(shell go list ./... | grep -v 'runtime/')
go tool cover -html=/tmp/coverage.out
## build: build the application
.PHONY: build
build: protobuf
go build -o=./bin/${BINARY_NAME} ${MAIN_PACKAGE_PATH}
.PHONY: build/windows
build/windows: protobuf
env GOOS="windows" GOARCH="amd64" CGO_ENABLED="1" CC="x86_64-w64-mingw32-gcc" go build -o=./bin/${BINARY_NAME}.exe ${MAIN_PACKAGE_PATH}
## run: run the application
.PHONY: run
run: build
./bin/${BINARY_NAME}
.PHONY: run/live
run/live: protobuf
go run github.com/cosmtrek/[email protected] \
--build.cmd "make build" --build.bin "./bin/${BINARY_NAME}" --build.delay "100" \
--build.args_bin "server,start" \
--build.exclude_dir "runtimes,bin" \
--misc.clean_on_exit "true"
## production/deploy: deploy the application to production
.PHONY: production/deploy
production/deploy:
GOOS=linux GOARCH=amd64 go build -ldflags='-s' -o=./bin/${BINARY_NAME} ${MAIN_PACKAGE_PATH}