-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
96 lines (70 loc) · 2.38 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
EXECUTABLE ?= aws-health-exporter
IMAGE ?= andreziviani/$(EXECUTABLE)
TAG ?= dev-$(shell git log -1 --pretty=format:"%h")
LD_FLAGS = -X "main.version=$(TAG)"
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
PKGS=$(shell go list ./... | grep -v /vendor)
.PHONY: _no-target-specified
_no-target-specified:
$(error Please specify the target to make - `make list` shows targets.)
.PHONY: list
list:
@$(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
LICENSEI_VERSION = 0.0.7
bin/licensei: ## Install license checker
@mkdir -p ./bin/
curl -sfL https://raw.githubusercontent.com/goph/licensei/master/install.sh | bash -s v${LICENSEI_VERSION}
.PHONY: license-check
license-check: bin/licensei ## Run license check
@bin/licensei check
.PHONY: license-cache
license-cache: bin/licensei ## Generate license cache
@bin/licensei cache
all: clean deps fmt vet docker push
clean:
go clean -i ./...
deps:
go get ./...
fmt:
@gofmt -w ${GOFILES_NOVENDOR}
vet:
@go vet -composites=false ./...
docker:
docker build --rm -t $(IMAGE):$(TAG) .
docker-run:
docker run -e AWS_REGION=$${AWS_REGION} -e AWS_SECRET_ACCESS_KEY=$${AWS_SECRET_ACCESS_KEY} -e AWS_SESSION_TOKEN=$${AWS_SESSION_TOKEN} -e AWS_ACCESS_KEY_ID=$${AWS_ACCESS_KEY_ID} -it --rm -p 8080:8080 $(IMAGE):$(TAG)
push:
docker push $(IMAGE):$(TAG)
run-dev:
go run $(wildcard *.go)
build:
go build -o $(EXECUTABLE) $(wildcard *.go)
build-all: fmt lint vet build
misspell: install-misspell
misspell -w ${GOFILES_NOVENDOR}
lint: install-golint
golint -min_confidence 0.9 -set_exit_status $(PKGS)
install-golint:
GOLINT_CMD=$(shell command -v golint 2> /dev/null)
ifndef GOLINT_CMD
go get github.com/golang/lint/golint
endif
install-misspell:
MISSPELL_CMD=$(shell command -v misspell 2> /dev/null)
ifndef MISSPELL_CMD
go get -u github.com/client9/misspell/cmd/misspell
endif
install-ineffassign:
INEFFASSIGN_CMD=$(shell command -v ineffassign 2> /dev/null)
ifndef INEFFASSIGN_CMD
go get -u github.com/gordonklaus/ineffassign
endif
install-gocyclo:
GOCYCLO_CMD=$(shell command -v gocyclo 2> /dev/null)
ifndef GOCYCLO_CMD
go get -u github.com/fzipp/gocyclo
endif
ineffassign: install-ineffassign
ineffassign ${GOFILES_NOVENDOR}
gocyclo: install-gocyclo
gocyclo -over 19 ${GOFILES_NOVENDOR}