forked from thomaspoignant/go-feature-flag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
101 lines (77 loc) · 3.61 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
GOCMD=go
GOTEST=$(GOCMD) test
GOVET=$(GOCMD) vet
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
CYAN := $(shell tput -Txterm setaf 6)
RESET := $(shell tput -Txterm sgr0)
.PHONY: all test build vendor
all: help
## Build:
build: build-relayproxy build-lint build-editor-api build-jsonschema-generator ## Build all the binaries and put the output in out/bin/
create-out-dir:
mkdir -p out/bin
build-relayproxy: create-out-dir ## Build the relay proxy in out/bin/
CGO_ENABLED=0 GO111MODULE=on $(GOCMD) build -mod vendor -o out/bin/relayproxy ./cmd/relayproxy/
build-lint: create-out-dir ## Build the linter in out/bin/
CGO_ENABLED=0 GO111MODULE=on $(GOCMD) build -mod vendor -o out/bin/lint ./cmd/lint/
build-editor-api: create-out-dir ## Build the linter in out/bin/
CGO_ENABLED=0 GO111MODULE=on $(GOCMD) build -mod vendor -o out/bin/editor-api ./cmd/editor/
build-jsonschema-generator: create-out-dir ## Build the jsonschema-generator in out/bin/
CGO_ENABLED=0 GO111MODULE=on $(GOCMD) build -mod vendor -o out/bin/jsonschema-generator ./cmd/jsonschema-generator/
build-doc: ## Build the documentation
cd website; \
npm i && npm run build
clean: ## Remove build related file
-rm -fr ./bin ./out ./release
-rm -f ./junit-report.xml checkstyle-report.xml ./coverage.xml ./profile.cov yamllint-checkstyle.xml
vendor: ## Copy of all packages needed to support builds and tests in the vendor directory
$(GOCMD) mod tidy
$(GOCMD) mod vendor
## Dev:
watch-relayproxy: ## Launch the relay proxy in watch mode.
docker run -it --rm -w /go/src/github.com/thomaspoignant/go-feature-flag/ \
-v $(shell pwd):/go/src/github.com/thomaspoignant/go-feature-flag \
-v $(shell pwd)/cmd/relayproxy/testdata/config/valid-file.yaml:/goff/goff-proxy.yaml \
-p 1031:1031 cosmtrek/air \
--build.cmd "go build -mod vendor -o out/bin/relayproxy ./cmd/relayproxy/" \
--build.bin "./out/bin/relayproxy"
watch-doc: ## Launch a local server to work on the documentation
cd website; \
npm i && npx docusaurus start
serve-doc: ## Serve the doc build by the build-doc target
cd website; \
npm run serve
swagger: ## Build swagger documentation
$(GOCMD) install github.com/swaggo/swag/cmd/swag@latest
cd cmd/relayproxy && swag init --parseDependency --parseDepth=1 --parseInternal --markdownFiles docs
generate-helm-docs: ## Generates helm documentation for the project
$(GOCMD) install github.com/norwoodj/helm-docs/cmd/helm-docs@latest
helm-docs
## Test:
test: ## Run the tests of the project
$(GOTEST) -v -race ./... -tags=docker
provider-tests: ## Run the integration tests for the Open Feature Providers
./openfeature/provider_tests/integration_tests.sh
coverage: ## Run the tests of the project and export the coverage
$(GOTEST) -cover -covermode=count -tags=docker -coverprofile=coverage.cov.tmp ./... \
&& cat coverage.cov.tmp | grep -v "/examples/" > coverage.cov
bench: ## Launch the benchmark test
$(GOTEST) -tags=bench -bench Benchmark -cpu 2 -run=^$$
## Lint:
lint: ## Use golintci-lint on your project
mkdir -p ./bin
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s latest # Install linters
./bin/golangci-lint run --timeout=5m --timeout=5m ./... # Run linters
## Help:
help: ## Show this help.
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} { \
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
}' $(MAKEFILE_LIST)