forked from appsody/controller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (56 loc) · 2.08 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
.DEFAULT_GOAL := help
#### Constant variables
# Set a default VERSION only if it is not already set
VERSION ?= vlatest
COMMAND := appsody-controller
BUILD_PATH := ./build
PACKAGE_PATH := ./package
GO_PATH := $(shell go env GOPATH)
GOLANGCI_LINT_BINARY := $(GO_PATH)/bin/golangci-lint
GOLANGCI_LINT_VERSION := v1.16.0
.PHONY: all
all: lint test package ## Run lint, test, build, and package
.PHONY: test
test: ## Run the automated tests
go test -v -count=1 ./test/*
.PHONY: lint
lint: $(GOLANGCI_LINT_BINARY) ## Run the static code analyzers
# Configure the linter here. Helpful commands include `golangci-lint linters` and `golangci-lint run -h`
# Set exclude-use-default to true if this becomes to noisy.
golangci-lint run -v --disable-all \
--enable deadcode \
--enable errcheck \
--enable gosimple \
--enable govet \
--enable ineffassign \
--enable staticcheck \
--enable structcheck \
--enable typecheck \
--enable unused \
--enable varcheck \
--enable gofmt \
--enable golint \
--enable gofmt \
--exclude-use-default=true \
./...
# not PHONY, installs golangci-lint if it doesn't exist
$(GOLANGCI_LINT_BINARY):
# see https://github.com/golangci/golangci-lint
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GO_PATH)/bin $(GOLANGCI_LINT_VERSION)
.PHONY: clean
clean: ## Removes existing build artifacts in order to get a fresh build
rm -rf $(BUILD_PATH)
rm -rf $(PACKAGE_PATH)
rm -f $(GOLANGCI_LINT_BINARY)
go clean
.PHONY: build
build: ## Build binary for linux stores it in the build/ dir
GOOS=linux GOARCH=amd64 go build -o $(BUILD_PATH)/$(COMMAND) -ldflags "-X main.VERSION=$(VERSION)"
.PHONY: package
package: build ## Build the linux binary and stores it in package/ dir
mkdir -p $(PACKAGE_PATH)
cp -p $(BUILD_PATH)/$(COMMAND) $(PACKAGE_PATH)/
# Auto documented help from http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.PHONY: help
help: ## Prints this help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'