-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
60 lines (45 loc) · 1.49 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
# Setup name variables for the package/tool
PREFIX?=$(shell pwd)
NAME := autocache
PKG := github.com/pomerium/$(NAME)
BUILDDIR := ${PREFIX}/dist
BINDIR := ${PREFIX}/bin
GO111MODULE=on
CGO_ENABLED := 0
# Set any default go build tags
BUILDTAGS :=
GOLANGCI_VERSION = v1.21.0 # .... for some reason v1.18.0 misses?
.PHONY: all
all: clean build-deps test lint build ## Runs a clean, build, fmt, lint, test, and vet.
.PHONY: clean
clean: ## Cleanup any build binaries or packages.
@echo "==> $@"
$(RM) -r $(BINDIR)
.PHONY: build-deps
build-deps: ## Install build dependencies
@echo "==> $@"
.PHONY: build
build: ## Builds dynamic executables and/or packages.
@echo "==> $@"
@CGO_ENABLED=0 GO111MODULE=on go build -tags "$(BUILDTAGS)" ${GO_LDFLAGS} -o $(BINDIR)/$(NAME)
.PHONY: test
test: ## Runs the go tests
@echo "==> $@"
@go test -tags "$(BUILDTAGS)" $(shell go list ./... | grep -v vendor)
.PHONY: lint
lint: build-deps ## Verifies `golint` passes.
@echo "==> $@"
@go run github.com/golangci/golangci-lint/cmd/golangci-lint run ./...
.PHONY: cover
cover: ## Runs go test with coverage
@echo "" > coverage.txt
@for d in $(shell go list ./... | grep -v vendor); do \
go test -race -coverprofile=profile.out -covermode=atomic "$$d"; \
if [ -f profile.out ]; then \
cat profile.out >> coverage.txt; \
rm profile.out; \
fi; \
done;
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'