-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
89 lines (67 loc) · 1.93 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
include Makefile.help.mk
BINARY=orderedmap
MAIN_PACKAGE=cmd/${BINARY}/main.go
PACKAGES = $(shell go list ./...)
VERSION=`cat VERSION`
BUILD=`git symbolic-ref HEAD 2> /dev/null | cut -b 12-`-`git log --pretty=format:%h -1`
DIST_FOLDER=dist
DIST_INCLUDE_FILES=README.md LICENSE VERSION
# Setup -ldflags option for go build here, interpolate the variable values
LDFLAGS=-ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD}"
# Build & Install
install: ## Build and install package on your system
go install $(LDFLAGS) -v $(PACKAGES)
.PHONY: version
version: ## Show version information
@echo $(VERSION)-$(BUILD)
# Testing
.PHONY: test
test: ## Execute package tests
go test -v $(PACKAGES)
.PHONY: test-race
test-race:
go test -race -v $(PACKAGES)
.PHONY: cover-profile
cover-profile:
echo "mode: count" > coverage-all.out
$(foreach pkg,$(PACKAGES),\
go test -coverprofile=coverage.out -covermode=count $(pkg);\
tail -n +2 coverage.out >> coverage-all.out;)
rm -rf coverage.out
.PHONY: cover
cover: cover-profile
cover: ## Generate test coverage data
go tool cover -func=coverage-all.out
.PHONY: cover-html
cover-html: cover-profile
cover-html: ## Generate coverage report
go tool cover -html=coverage-all.out
.PHONY: codecov
codecov:
bash <(curl -s https://codecov.io/bash)
# BenchMarking
.PHONY: benchmark
benchmark: ## Execute package benchmarks
go test -v $(PACKAGES) -benchmem -bench .
# Dependencies
deps: ## Install build dependencies
go get -u=patch
go mod tidy -v
go mod download
go mod verify
dev-deps: deps
dev-deps: ## Install dev and build dependencies
.PHONY: clean
clean: ## Delete generated development environment
go clean
rm -rf ${BINARY}-*-*
rm -rf ${BINARY}-*-*.exe
rm -rf ${BINARY}-*-*.zip
rm -rf coverage-all.out
# Lint
.PHONY: lint
lint: ## Lint source code
./lint.bash
# Docs
godoc-serve: ## Serve documentation (godoc format) for this package at port HTTP 9090
godoc -http=":9090"