Debian Codegraph @

Makefile

raw
1 include Makefile.help.mk
2
3 BINARY=namegenerator
4 MAIN_PACKAGE=cmd/${BINARY}/main.go
5 PACKAGES = $(shell go list ./...)
6 VERSION=`cat VERSION`
7 BUILD=`git symbolic-ref HEAD 2> /dev/null | cut -b 12-`-`git log --pretty=format:%h -1`
8 DIST_FOLDER=dist
9 DIST_INCLUDE_FILES=README.md LICENSE VERSION
10
11 # Setup -ldflags option for go build here, interpolate the variable values
12 LDFLAGS=-ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD}"
13
14 # Build & Install
15
16 install: ## Build and install package on your system
17 go install $(LDFLAGS) -v $(PACKAGES)
18
19 .PHONY: version
20 version: ## Show version information
21 @echo $(VERSION)-$(BUILD)
22
23 # Testing
24
25 .PHONY: test
26 test: ## Execute package tests
27 go test -v $(PACKAGES)
28
29 .PHONY: test-race
30 test-race:
31 go test -race -v $(PACKAGES)
32
33 .PHONY: cover-profile
34 cover-profile:
35 echo "mode: count" > coverage-all.out
36 $(foreach pkg,$(PACKAGES),\
37 go test -coverprofile=coverage.out -covermode=count $(pkg);\
38 tail -n +2 coverage.out >> coverage-all.out;)
39 rm -rf coverage.out
40
41 .PHONY: cover
42 cover: cover-profile
43 cover: ## Generate test coverage data
44 go tool cover -func=coverage-all.out
45
46 .PHONY: cover-html
47 cover-html: cover-profile
48 cover-html: ## Generate coverage report
49 go tool cover -html=coverage-all.out
50
51 .PHONY: codecov
52 codecov:
53 bash <(curl -s https://codecov.io/bash)
54
55 # BenchMarking
56
57 .PHONY: benchmark
58 benchmark: ## Execute package benchmarks
59 go test -v $(PACKAGES) -benchmem -bench .
60
61 # Dependencies
62
63 deps: ## Install build dependencies
64 go get -u=patch
65 go mod tidy -v
66 go mod download
67 go mod verify
68
69 dev-deps: deps
70 dev-deps: ## Install dev and build dependencies
71
72 .PHONY: clean
73 clean: ## Delete generated development environment
74 go clean
75 rm -rf ${BINARY}-*-*
76 rm -rf ${BINARY}-*-*.exe
77 rm -rf ${BINARY}-*-*.zip
78 rm -rf coverage-all.out
79
80 # Lint
81
82 .PHONY: lint
83 lint: ## Lint source code
84 ./lint.bash
85
86 # Docs
87
88 godoc-serve: ## Serve documentation (godoc format) for this package at port HTTP 9090
89 godoc -http=":9090"