File: Makefile

package info (click to toggle)
golang-github-xorcare-pointer 1.1.0%2Bgit20200211.75cc9bc-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 116 kB
  • sloc: makefile: 49
file content (68 lines) | stat: -rw-r--r-- 1,859 bytes parent folder | download
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
# Based on https://git.io/fjkGc

# The full path to the main package is use in the
# imports tool to format imports correctly.
NAMESPACE = github.com/xorcare/pointer

# The name of the file recommended in the standard
# documentation go test -cover and used codecov.io
# to check code coverage.
COVER_FILE ?= coverage.out

# Main targets.
.DEFAULT_GOAL := help

.PHONY: build
build: ## Build the project binary
	@go build ./...

.PHONY: ci
ci: check ## Target for integration with ci pipeline

.PHONY: check
check: static test build ## Check project with static checks and unit tests

.PHONY: help
help: ## Print this help
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
	awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: imports
imports: tools ## Check and fix import section by import rules
	@test -z $$(for d in $$(go list -f {{.Dir}} ./...); do goimports -e -l -local $(NAMESPACE) -w $$d/*.go; done)

.PHONY: lint
lint: tools ## Check the project with lint
	@golint -set_exit_status ./...

.PHONY: static
static: imports vet lint ## Run static checks (lint, imports, vet, ...) all over the project

.PHONY: test
test: ## Run unit tests
	@go test ./... -count=1 -race
	@go test ./... -count=1 -coverprofile=$(COVER_FILE) -covermode=atomic $d
	@go tool cover -func=$(COVER_FILE) | grep ^total

CDTOOLS ?= @cd internal/tools &&
.PHONY: tools
tools: ## Install all needed tools, e.g. for static checks
	$(CDTOOLS) \
	go install \
	golang.org/x/lint/golint \
	golang.org/x/tools/cmd/goimports

.PHONY: toolsup
toolsup: ## Update all needed tools, e.g. for static checks
	$(CDTOOLS) \
	go mod tidy && \
	go get \
	golang.org/x/lint/golint@latest \
	golang.org/x/tools/cmd/goimports@latest && \
	go mod download && \
	go mod verify
	$(MAKE) tools

.PHONY: vet
vet: ## Check the project with vet
	@go vet ./...