-
Notifications
You must be signed in to change notification settings - Fork 187
/
Makefile
89 lines (66 loc) · 2.16 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
PWD := $(shell pwd)
GOPATH := $(shell go env GOPATH)
UIPATH := $(PWD)/browser/flagr-ui
################################
### Public
################################
all: deps gen build build_ui run
rebuild: gen build
test: verifiers
@go test -race -covermode=atomic -coverprofile=coverage.txt github.com/openflagr/flagr/pkg/...
.PHONY: benchmark
benchmark:
@go test -race -benchmem -run=^$$ -bench . ./pkg/...
ci: test
.PHONY: vendor
vendor:
@go mod tidy
@go mod vendor
build:
@echo "Building Flagr Server to $(PWD)/flagr ..."
@go build -o $(PWD)/flagr github.com/openflagr/flagr/swagger_gen/cmd/flagr-server
build_ui:
@echo "Building Flagr UI ..."
@cd ./browser/flagr-ui/; npm install && npm run build
run_ui:
@cd ./browser/flagr-ui/; npm run serve
run:
@$(PWD)/flagr --port 18000
start:
$(MAKE) -j run run_ui
gen: api_docs swagger
deps:
@go install github.com/go-swagger/go-swagger/cmd/[email protected]
@go install github.com/golangci/golangci-lint/cmd/[email protected]
serve_docs:
@npm install -g docsify-cli@4
@docsify serve $(PWD)/docs
################################
### Private
################################
api_docs:
@echo "Installing swagger-merger" && npm install swagger-merger -g
@swagger-merger -i $(PWD)/swagger/index.yaml -o $(PWD)/docs/api_docs/bundle.yaml
verifiers: verify_lint verify_swagger
verify_lint:
@echo "Running $@"
@golangci-lint run --timeout 5m -D errcheck ./pkg/...
verify_swagger:
@echo "Running $@"
@swagger validate $(PWD)/docs/api_docs/bundle.yaml
verify_swagger_nochange: swagger
@echo "Running verify_swagger_nochange to make sure the swagger generated code is checked in"
@git diff --exit-code
clean:
@echo "Cleaning up all the generated files"
@find . -name '*.test' | xargs rm -fv
@rm -rf build
@rm -rf release
swagger: verify_swagger
@echo "Regenerate swagger files"
@rm -f /tmp/configure_flagr.go
@cp $(PWD)/swagger_gen/restapi/configure_flagr.go /tmp/configure_flagr.go 2>/dev/null || :
@rm -rf $(PWD)/swagger_gen
@mkdir $(PWD)/swagger_gen
@swagger generate server -t ./swagger_gen -f $(PWD)/docs/api_docs/bundle.yaml
@cp /tmp/configure_flagr.go $(PWD)/swagger_gen/restapi/configure_flagr.go 2>/dev/null || :