-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
73 lines (64 loc) · 1.77 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
# Set up script constants
BIN=genialo
GOCMD=go
GOBUILD=$(GOCMD) build
GOBUILD_CONTAINER=CGO_ENABLED=0 GOOS=linux $(GOCMD) build -a -installsuffix nocgo
GOCLEAN=$(GOCMD) clean
GOGET=$(GOCMD) get
# Install all the build and lint dependencies
.PHONY: setup
setup:
@echo "Installing dependencies..."
@$(GOGET) -u github.com/alecthomas/gometalinter
@$(GOGET) -u github.com/golang/dep/cmd/dep
gometalinter --install --update
@$(MAKE) dep
# Run dep ensure and prune
.PHONY: dep
dep:
@echo "Vendoring dependencies..."
dep ensure
# Run goimports on all go files
.PHONY: fmt
fmt:
@echo "Formating all .go files..."
find . -name '*.go' -not -wholename './vendor/*' | while read -r file; do goimports -w "$$file"; done
# Run all the linters
.PHONY: lint
lint:
@echo "Running linter on all .go files..."
gometalinter --vendor --disable-all \
--enable=deadcode \
--enable=ineffassign \
--enable=gosimple \
--enable=staticcheck \
--enable=gofmt \
--enable=goimports \
--enable=misspell \
--enable=errcheck \
--enable=vet \
--enable=vetshadow \
--deadline=10m \
./...
# Build a version
.PHONY: build
build:
@echo "Building $(BIN) application into dist folder..."
@$(GOBUILD) -o dist/$(BIN)
# Build a version for container
.PHONY: build-container
build-container:
@echo "Building $(BIN) application into dist folder..."
@$(GOBUILD_CONTAINER) -o dist/$(BIN)
# Remove temporary files
.PHONY: clean
clean:
@echo "Cleaning files..."
@$(GOCLEAN) && rm dist/$(BIN)
# Absolutely awesome: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.PHONY: help
help:
@echo "Command list: "
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# Sets default command
.DEFAULT_GOAL := build