-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
68 lines (50 loc) · 1.71 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
GO_FILES := $(find . -iname '*.go' -type f | grep -v /vendor/)
BINARY = aquarium
BUILD_DIR := "build"
GOARCH = amd64
TEST_REPORT = $(BUILD_DIR)/tests.xml
COVERAGE_DIR = $(BUILD_DIR)/coverage
COVERAGE_MODE = atomic
COVERAGE_PROFILE = $(COVERAGE_DIR)/profile.out
COVERAGE_XML = $(COVERAGE_DIR)/coverage.xml
COVERAGE_HTML = $(COVERAGE_DIR)/index.html
VERSION?=?
COMMIT=$(shell git rev-parse HEAD)
BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
# Setup the -ldflags option for go build here, interpolate the variable values
LDFLAGS = -ldflags "-X main.VERSION=${VERSION} -X main.COMMIT=${COMMIT} -X main.BRANCH=${BRANCH}"
all: deps lint build test
clean:
@rm -rf $(BUILD_DIR)/*
linux:
GOOS=linux GOARCH=${GOARCH} go build ${LDFLAGS} -o $(BUILD_DIR)/${BINARY}-linux-${GOARCH}
darwin:
GOOS=darwin GOARCH=${GOARCH} go build ${LDFLAGS} -o $(BUILD_DIR)/${BINARY}-windows-${GOARCH}
windows:
GOOS=windows GOARCH=${GOARCH} go build ${LDFLAGS} -o $(BUILD_DIR)/${BINARY}-windows-${GOARCH}
build-all: linux darwin windows
build: clean
@mkdir -p build && go build -o build/$(BINARY)
run: build
./build/$(BINARY)
lint:
@test -z $(gofmt -s -l $GO_FILES)
@golangci-lint run
test:
@go test -v -race $(GO_FILES)
coverage:
@mkdir -p $(COVERAGE_DIR)
@go test -v -race $(GO_FILES) -coverprofile $(COVERAGE_PROFILE) -covermode=$(COVERAGE_MODE)
go tool cover -html=$(COVERAGE_PROFILE) -o $(COVERAGE_HTML)
format:
@gofmt -l -s $(GO_FILES)
tools:
@go get -u github.com/golang/dep/cmd/dep
@go get -u golang.org/x/tools/cmd/cover
@go get -u github.com/tebeka/go2xunit
@go get -u github.com/goreleaser/goreleaser
@go install ./vendor/github.com/golangci/golangci-lint/cmd/golangci-lint/
deps:
@dep ensure
release:
@goreleaser