-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile
116 lines (98 loc) · 3.35 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
# Copyright 2018 Iguazio
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
GIT_COMMIT_HASH := $(shell git rev-parse HEAD)
GIT_BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
ifeq ($(GIT_BRANCH),)
GIT_BRANCH="N/A"
endif
ifneq ($(TSDB_LABEL),)
GIT_REVISION := $(TSDB_LABEL)
else
GIT_REVISION := $(shell git describe --always)
endif
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
GOPATH ?= $(shell go env GOPATH)
TSDBCTL_BIN_NAME := tsdbctl-$(GIT_REVISION)-$(GOOS)-$(GOARCH)
# Use RFC3339 (ISO8601) date format
BUILD_TIME := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
# Use fully qualified package name
CONFIG_PKG=github.com/v3io/v3io-tsdb/pkg/config
# Use Go linker to set the build metadata
BUILD_OPTS := -ldflags " \
-X $(CONFIG_PKG).buildTime=$(BUILD_TIME) \
-X $(CONFIG_PKG).osys=$(GOOS) \
-X $(CONFIG_PKG).architecture=$(GOARCH) \
-X $(CONFIG_PKG).version=$(GIT_REVISION) \
-X $(CONFIG_PKG).commitHash=$(GIT_COMMIT_HASH) \
-X $(CONFIG_PKG).branch=$(GIT_BRANCH)" \
-v -o "$(GOPATH)/bin/$(TSDBCTL_BIN_NAME)"
TSDB_BUILD_COMMAND ?= GO111MODULE="on" CGO_ENABLED=0 go build $(BUILD_OPTS) ./cmd/tsdbctl
.PHONY: fmt
fmt:
gofmt -l -s -w .
.PHONY: get
get:
GO111MODULE="on" go mod tidy
.PHONY: test
test:
go test -v -race -tags unit -count 1 ./...
.PHONY: integration
integration:
go test -v -race -tags integration -p 1 -count 1 ./... # p=1 to force Go to run pkg tests serially.
.PHONY: bench
bench:
go test -run=XXX -bench='^BenchmarkIngest$$' -benchtime 10s -timeout 5m ./test/benchmark/...
.PHONY: build
build:
docker run \
--volume $(shell pwd):/go/src/github.com/v3io/v3io-tsdb \
--volume $(shell pwd):/go/bin \
--workdir /go/src/github.com/v3io/v3io-tsdb \
--env GOOS=$(GOOS) \
--env GOARCH=$(GOARCH) \
golang:1.12 \
make bin
.PHONY: bin
bin:
${TSDB_BUILD_COMMAND}
PHONY: gofmt
gofmt:
if [ "$(gofmt -l .)" != "" ]; then echo 'Please run `go fmt ./...` to format the code'; fi
.PHONY: impi
impi:
@echo Installing impi...
GO111MODULE=off go get -u github.com/pavius/impi/cmd/impi
@echo Verifying imports...
$(GOPATH)/bin/impi \
--local github.com/iguazio/provazio \
--skip pkg/controller/apis \
--skip pkg/controller/client \
--ignore-generated \
--scheme stdLocalThirdParty \
./...
$(GOPATH)/bin/golangci-lint:
@echo Installing golangci-lint...
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.49.0
cp ./bin/golangci-lint $(GOPATH)/bin/
.PHONY: lint
lint: gofmt impi $(GOPATH)/bin/golangci-lint
@echo Linting...
@$(GOPATH)/bin/golangci-lint run \
--disable-all --enable=deadcode --enable=goconst --enable=golint --enable=ineffassign \
--enable=interfacer --enable=unconvert --enable=varcheck --enable=errcheck --enable=gofmt --enable=misspell \
--enable=staticcheck --enable=gosimple --enable=govet --enable=goconst \
cmd/... pkg/... internal/...
@echo done linting