forked from flipt-io/flipt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
88 lines (70 loc) · 2.62 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
PROJECT = flipt
GOTOOLS = \
golang.org/x/tools/cmd/cover \
golang.org/x/tools/cmd/goimports \
google.golang.org/grpc \
github.com/golang/protobuf/protoc-gen-go \
github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway \
github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger \
github.com/golang/dep/cmd/dep \
PREFIX ?= $(shell pwd)
SOURCE_FILES ?= ./...
TEST_PATTERN ?= .
TEST_OPTS ?=
GO111MODULE ?= off
.PHONY: setup
setup: ## Install dev tools
@if [ ! -f $(GOPATH)/bin/golangci-lint ]; then \
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.12.5; \
fi
GO111MODULE=$(GO111MODULE) go get -u $(GOTOOLS)
.PHONY: test
test: ## Run all the tests
go test $(TEST_OPTS) -v -covermode=atomic -coverprofile=coverage.txt $(SOURCE_FILES) -run $(TEST_PATTERN) -timeout=30s
.PHONY: cover
cover: test ## Run all the tests and opens the coverage report
go tool cover -html=coverage.txt
.PHONY: fmt
fmt: ## Run gofmt and goimports on all go files
@find . -name '*.go' -not -wholename './rpc/*' -not -wholename './vendor/*' -not -wholename './ui/*' -not -wholename './swagger/*' | while read -r file; do gofmt -w -s "$$file"; goimports -w "$$file"; done
.PHONY: lint
lint: ## Run all the linters
golangci-lint run
.PHONY: clean
clean: ## Remove built binaries
go clean -i $(SOURCE_FILES)
rm -rf ./bin/* ./dist/*
.PHONY: proto
proto: ## Build protobufs
protoc -I/usr/local/include -I. \
-I $(GOPATH)/src \
-I $(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway \
-I $(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
-I rpc \
--go_out=plugins=grpc:./rpc \
--grpc-gateway_out=logtostderr=true,grpc_api_configuration=./rpc/flipt.yaml:./rpc \
--swagger_out=logtostderr=true,grpc_api_configuration=./rpc/flipt.yaml:./swagger/api \
$(PROJECT).proto
.PHONY: ui
ui: ## Builds the ui
@cd ./ui; yarn install && yarn run build
.PHONY: generate
generate: ## Run go generate
GO111MODULE=$(GO111MODULE) go generate ./...
.PHONY: check_generate
check_generate: generate
@if ! (git diff --quiet); then \
echo "Run 'make generate' and commit the changes to fix the error."; \
exit 1; \
fi
.PHONY: build
build: ## Build a local copy
GO111MODULE=$(GO111MODULE) go build -o ./bin/$(PROJECT) ./cmd/$(PROJECT)/main.go
.PHONY: dev
dev: ## Build and run in development mode
GO111MODULE=$(GO111MODULE) go run -tags=dev ./cmd/$(PROJECT)/main.go --config ./config/local.yml
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.DEFAULT_GOAL := help
default: help