-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
58 lines (45 loc) · 1.2 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
SHELL := /bin/bash
ifndef FH_SYSTEM_DUMP_TOOL_VERSION
FH_SYSTEM_DUMP_TOOL_VERSION := $(shell git describe --tags --abbrev=14)
endif
LDFLAGS := -X main.Version=$(FH_SYSTEM_DUMP_TOOL_VERSION)
IMPORT_PATH := github.com/feedhenry/fh-system-dump-tool
GO_DOCKER_IMAGE := golang:1.8
.PHONY: all
all:
@go install -v -ldflags '$(LDFLAGS)'
.PHONY: clean
clean:
@-go clean -i
.PHONY: ci
ci: check-gofmt check-goimports check-golint vet test test-race
# goimports doesn't support the -s flag to simplify code, therefore we use both
# goimports and gofmt -s.
.PHONY: check-gofmt
check-gofmt:
diff <(gofmt -s -d .) <(printf "")
.PHONY: check-goimports
check-goimports:
diff <(goimports -d .) <(printf "")
.PHONY: check-golint
check-golint:
diff <(golint ./...) <(printf "")
.PHONY: vet
vet:
go vet ./...
.PHONY: test
test:
go test -v -cpu=2 ./...
.PHONY: test-race
test-race:
go test -v -cpu=1,2,4 -short -race ./...
.PHONY: release
release:
docker run --rm \
-v "$(PWD):/go/src/$(IMPORT_PATH)" \
-w "/go/src/$(IMPORT_PATH)" \
"$(GO_DOCKER_IMAGE)" make dist
.PHONY: dist
dist: all
mkdir -p dist
tar -C "/go/bin" -czf "dist/fh-system-dump-tool-$(FH_SYSTEM_DUMP_TOOL_VERSION)-linux-amd64.tar.gz" "fh-system-dump-tool"