-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmakefile
41 lines (28 loc) · 1.01 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
GOPATH=$(shell go env GOPATH)
PROGRAM=delayqueue
BINARY=bin/${PROGRAM}
MAIN_FILE=cmd/delayqueue/main.go
VERSION=$(shell git describe --tags --always --long --dirty)
GIT_ADDR=$(shell git remote -v | head -n 1 | awk '{print $$2}')
BUILD_TIME=$(shell date +%FT%T%z)
GO_VERSION=$(shell go version | awk '{print $$3}')
REPO=github.com/changsongl/delay-queue/
LDFLAGS=-ldflags "-X ${REPO}vars.BuildProgram=${PROGRAM} -X ${REPO}vars.GoVersion=${GO_VERSION} -X ${REPO}vars.BuildTime=${BUILD_TIME} -X ${REPO}vars.BuildVersion=${VERSION} -X ${REPO}vars.BuildGitPath=${GIT_ADDR}"
.PHONY: build clean test test-unit test-integration run env
test-unit:
go test --count=1 `go list ./... | grep -v integration`
test-integration:
go test --count=1 ./test/integration/...
test:
go test --count=1 ./...
build:
golint ./...
go mod download
go fmt ./...
go build -o ${BINARY} ${LDFLAGS} ${MAIN_FILE}
env:
go env
run:
./${BINARY} -config.file ./config/config.yaml
clean:
@if [ -f ${BINARY} ]; then rm ${BINARY} && rmdir bin; fi