-
Notifications
You must be signed in to change notification settings - Fork 66
/
Makefile
63 lines (47 loc) · 1.82 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
default: build
QRI_VERSION?="0.10.1-dev"
BUILD_FLAGS?=CGO_ENABLED=0
PKG=$(shell go list ./version)
GOLANG_VERSION=$(shell go version | awk '{print $$3}')
require-goversion:
# Parse version from go.mod, remove space so it matches `go version`
$(eval minver := $(shell grep "^go" go.mod | tr -s 'go ' 'go'))
# Magic happens. Sort using "." as the tab, keyed by groups of numbers,
# take the smallest.
$(eval match := $(shell echo "$(minver)\n$(GOLANG_VERSION)" | sort -t '.' -k 1,1 -k 2,2 -g -r | head -n 1))
# If the minimum version either matches exactly what we have, or does not match
# the result of the magic sort above, we're okay. Otherwise, our binary's
# version isn't good enough: error.
@if [ "$(GOLANG_VERSION)" != "$(minver)" ]; then \
if [ "$(match)" == "$(minver)" ]; then \
echo "Error: invalid go version $(GOLAND_VERSION), need $(minver)"; exit 1; \
fi; \
fi;
require-govvv:
ifeq (,$(shell which govvv))
@echo "installing govvv"
$(shell go install github.com/ahmetb/govvv)
endif
build: require-goversion require-govvv
$(BUILD_FLAGS) go build -ldflags="-X ${PKG}.GolangVersion=${GOLANG_VERSION} $(shell govvv -flags -pkg $(PKG) -version $(QRI_VERSION))" .
install: require-goversion require-govvv
$(BUILD_FLAGS) go install -ldflags="-X ${PKG}.GolangVersion=${GOLANG_VERSION} $(shell govvv -flags -pkg $(PKG) -version $(QRI_VERSION))" .
.PHONY: install
dscache_fbs:
cd dscache && flatc --go def.fbs
workdir:
mkdir -p workdir
lint:
golint ./...
test:
go test ./... -v --coverprofile=coverage.txt --covermode=atomic
test-all-coverage:
./.circleci/cover.test.sh
cli-docs:
cd docs && go run . --dir ../temp --filename cli_commands.md
api-spec:
cd docs && go run . --dir ../temp --apiOnly
serve-api-docs:
cd docs && go run . --http :2502
update-changelog:
conventional-changelog -p angular -i CHANGELOG.md -s