This repository has been archived by the owner on Mar 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
68 lines (54 loc) · 1.89 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
GOTOOLS := \
github.com/alecthomas/gometalinter \
github.com/git-chglog/git-chglog/cmd/git-chglog \
github.com/golang/dep/cmd/dep \
golang.org/x/tools/cmd/cover \
DIRS ?= $(shell find . -name '*.go' | grep --invert-match 'vendor' | xargs -n 1 dirname | sort --unique)
PKG_NAME ?= scenery
VERSION := $(shell git describe --tags --always --dirty="-dev")
LDFLAGS := -ldflags='-w -s -X "main.Version=$(VERSION)"'
COVERAGE_PROFILE ?= coverage.out
.DEFAULT_GOAL := help
.PHONY: build
build: ## Builds a local Go binary
@echo "---> Building"
CGO_ENABLED=0 go build -o ./bin/$(PKG_NAME) $(LDFLAGS)
.PHONY: clean
clean: ## Removes Go temporary build files build directory
@echo "---> Cleaning"
@rm -rf ./bin
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: html
html: ## Generates an HTML coverage report
@echo "---> Generating HTML coverage report"
go tool cover -html $(COVERAGE_PROFILE)
.PHONY: install_tools
install_tools: ## Installs all development tool dependencies
@echo "--> Installing tools"
go get -u $(GOTOOLS)
gometalinter --install
.PHONY: lint
lint: ## Runs all linters
@echo "---> Linting... this might take a minute"
gometalinter --vendor --tests --deadline=3m $(LFLAGS) $(DIRS)
.PHONY: release
release: ## Creates a new release with the given tag
@echo "---> Creating new release"
ifndef tag
$(error tag must be specified)
endif
git-chglog --output CHANGELOG.md --next-tag $(tag)
git add CHANGELOG.md
git commit -m $(tag)
git tag $(tag)
git push origin master --tags
.PHONY: test
test: ## Runs all the tests and outputs the coverage report
@echo "---> Testing"
go test ./... -coverprofile $(COVERAGE_PROFILE) $(TFLAGS)
.PHONY: uninstall_tools ## test
uninstall_tools: ## Uninstalls all development tool dependencies
@echo "--> Uninstalling tools"
go clean -i $(GOTOOLS)