-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
52 lines (36 loc) · 1.67 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
.PHONY: help clean build test test-cover fmt coverage-out coverage-html
export GO111MODULE=on
export CGO_ENABLED=0
SRCS = $(shell git ls-files '*.go' | grep -v '^vendor/')
MAIN_DIRECTORY:=./cmd/tabia
BIN_OUTPUT:=$(if $(filter $(shell go env GOOS), Windows), bin/tabia.exe, bin/tabia)
TAG_NAME:=$(shell git tag -l --contains HEAD)
SHA:=$(shell git rev-parse HEAD)
VERSION:=$(if $(TAG_NAME),$(TAG_NAME),$(SHA))
help: ## Display this help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
clean: ## Clean build output
@echo BIN_OUTPUT: ${BIN_OUTPUT}
rm -rf bin/ cover.out
install-tools: ## Installs tool dependencies
@cat tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % go install %
test: ## Run tests
CGO_ENABLED=1 go test -v -race -count=1 ./...
test-cover: ## Run tests with coverage
CGO_ENABLED=1 go test -v -race -count=1 -covermode=atomic -coverprofile=coverage.out ./...
generate: ## Generate generates code using go:generate statements in source
go generate ./...
build: clean generate ## Build binary
@echo VERSION: $(VERSION)
go build -v -trimpath -ldflags '-X "main.version=${VERSION}"' -o ${BIN_OUTPUT} ${MAIN_DIRECTORY}
outdated: ## Checks for outdated dependencies
go list -u -m -json all | go-mod-outdated -update
fmt: ## formats all *.go files added to git
gofmt -s -l -w $(SRCS)
coverage-out: test-cover ## Show coverage in cli
@echo Coverage details
@go tool cover -func=coverage.out
coverage-html: test-cover ## Show coverage in browser
@go tool cover -html=coverage.out
dockerize: ## Created development docker image
docker build -t philipssoftware/tabia:dev .