-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathMakefile
More file actions
91 lines (75 loc) · 2.42 KB
/
Makefile
File metadata and controls
91 lines (75 loc) · 2.42 KB
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
# 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: lint
lint: gofmt