forked from flipt-io/flipt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
117 lines (94 loc) · 3.31 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
PROJECT = flipt
SOURCE_FILES ?= ./...
BENCH_PATTERN ?= .
TEST_PATTERN ?= .
TEST_OPTS ?=
TEST_FLAGS ?= -v
TOOLS = \
"github.com/gobuffalo/packr/packr" \
"github.com/golang/protobuf/protoc-gen-go" \
"github.com/golangci/golangci-lint/cmd/golangci-lint" \
"github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway" \
"github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger" \
"golang.org/x/tools/cmd/cover" \
"golang.org/x/tools/cmd/goimports" \
"google.golang.org/grpc" \
"github.com/buchanae/github-release-notes" \
UI_PATH = ui
UI_SOURCE_FILES = $(wildcard $(UI_PATH)/static/* $(UI_PATH)/src/**/* $(UI_PATH)/src/**/**/* $(UI_PATH)/index.html)
UI_NODE_MODULES_PATH = $(UI_PATH)/node_modules
UI_OUTPUT_PATH = $(UI_PATH)/dist
$(UI_NODE_MODULES_PATH): $(UI_PATH)/package.json $(UI_PATH)/yarn.lock
@cd $(UI_PATH) && yarn --frozen-lockfile
$(UI_OUTPUT_PATH): $(UI_NODE_MODULES_PATH) $(UI_SOURCE_FILES)
@cd $(UI_PATH) && yarn build
.PHONY: setup
setup: ## Install dev tools
@echo ">> installing dev tools"
go install -v $(TOOLS)
.PHONY: bench
bench: ## Run all the benchmarks
@echo ">> running benchmarks"
go test -bench=$(BENCH_PATTERN) $(SOURCE_FILES) -run=XXX $(TEST_FLAGS)
.PHONY: test
test: ## Run all the tests
@echo ">> running tests"
go test $(TEST_OPTS) -covermode=atomic -count=1 -coverprofile=coverage.txt $(SOURCE_FILES) -run=$(TEST_PATTERN) -timeout=30s $(TEST_FLAGS)
.PHONY: cover
cover: test ## Run all the tests and opens the coverage report
@echo ">> generating test coverage"
go tool cover -html=coverage.txt
.PHONY: fmt
fmt: ## Run gofmt and goimports on all go files
@echo ">> running gofmt"
@find . -name '*.go' | while read -r file; do gofmt -w -s "$$file"; goimports -w "$$file"; done
.PHONY: lint
lint: ## Run all the linters
@echo ">> running golangci-lint"
golangci-lint run
.PHONY: clean
clean: ## Cleanup generated files
@echo ">> cleaning up"
go clean -i $(SOURCE_FILES)
packr clean
rm -rf dist/*
.PHONY: proto
proto: ## Build protobufs
@echo ">> generating protobufs"
protoc -I/usr/local/include -I. \
-Irpc \
--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 \
$(PROJECT).proto
.PHONY: assets
assets: $(UI_OUTPUT_PATH) ## Build the ui
.PHONY: pack
pack: ## Pack the assets in the binary
@echo ">> packing assets"
packr -i cmd/flipt
.PHONY: build
build: clean assets pack ## Build a local copy
@echo ">> building a local copy"
go build -o ./bin/$(PROJECT) ./cmd/$(PROJECT)/.
.PHONY: dev
dev: clean assets ## Build and run in development mode
@echo ">> building and running in development mode"
go run ./cmd/$(PROJECT)/. --config ./config/local.yml --force-migrate
.PHONY: snapshot
snapshot: clean assets pack ## Build a snapshot version
@echo ">> building a snapshot version"
@./script/build/snapshot
.PHONY: release
release: clean assets pack ## Build and publish a release
@echo ">> building and publishing a release"
@./script/build/release
.PHONY: clients
clients: ## Generate GRPC clients
@echo ">> generating clients"
@./script/build/clients
.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