-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
52 lines (40 loc) · 1.43 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
SHELL = /bin/bash
CURRENT_DIRECTORY = $(shell pwd)
# Build variables
REPORTS_DIR ?= reports
CI_SERVICE ?=
COVERALLS_TOKEN ?=
# Go variables
GOFILES = $(shell find . -type f -name '*.go' -not -path "*/mock/*.go")
.PHONY: all
all: dep ## Get deps and build binary
.PHONY: clean
clean: ## Clean the working area and the project
rm -rf $(REPORTS_DIR)
.PHONY: dep
dep: ## Install dependencies
@go get -d golang.org/x/tools/cmd/cover
@go install github.com/mattn/goveralls@latest
@go mod tidy
@go get -v -t ./...
.PHONY: format
format: ## Format the source
@goimports -w $(GOFILES)
.PHONY: test
test: ## Run unit tests
mkdir -p $(REPORTS_DIR)
rm -f $(REPORTS_DIR)/*
@go test -v -covermode=count -coverprofile="$(REPORTS_DIR)/coverage.out" ./...
.PHONY: publish-test-results
publish-test-results: ## Publish test results
@goveralls -coverprofile="$(REPORTS_DIR)/coverage.out" -service=$(CI_SERVICE) -repotoken $(COVERALLS_TOKEN)
.PHONY: list
list: ## List all make targets
@$(MAKE) -pRrn : -f $(MAKEFILE_LIST) 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | sort
.PHONY: help
.DEFAULT_GOAL := help
help: ## Get help output
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# Variable outputting/exporting rules
var-%: ; @echo $($*)
varexport-%: ; @echo $*=$($*)