forked from raystack/frontier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
69 lines (52 loc) · 2.53 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
GOVERSION := $(shell go version | cut -d ' ' -f 3 | cut -d '.' -f 2)
.PHONY: build check fmt lint test test-race vet test-cover-html help install proto
.DEFAULT_GOAL := build
PROTON_COMMIT := "e0c6ae65649c06de6e3dd9af5028ea583a9ed999"
install:
@echo "Clean up imports..."
@go mod download
@go get -d github.com/vektra/mockery/[email protected]
build: ## build all
CGO_ENABLED=0 go build -o shield .
generate: ## run all go generate in the code base (including generating mock files)
@go generate ./...
@echo " > generating mock files"
@mockery
lint: ## Run linters
@golangci-lint run
format:
@echo "Running gofumpt..."
@gofumpt -l -w .
# TODO: create separate command for integration tests
test: ## Run tests
go test -race $(shell go list ./... | grep -v /mocks | grep -v /test/ | grep -v /proto/) -covermode=atomic -coverprofile=coverage.out
e2e-test: ## Run all e2e tests
go test -v -race ./test/e2e_test/... -covermode=atomic -coverprofile=coverage.out
e2e-smoke-test: ## Run smoke tests
go test -v -race ./test/e2e_test/smoke -covermode=atomic -coverprofile=coverage.out
e2e-regression-test: ## Run regression tests
go test -v -race ./test/e2e_test/regression -covermode=atomic -coverprofile=coverage.out
benchmark: ## Run benchmarks
go test -run=XX -bench=Benchmark. -count 3 -benchtime=1s github.com/goto/shield/integration
coverage: ## print code coverage
go test -race -coverprofile coverage.out -covermode=atomic ./... -tags=unit_test && go tool cover -html=coverage.txt
clean :
rm -rf dist
proto: ## Generate the protobuf files
@echo " > generating protobuf from goto/proton"
@echo " > [info] make sure correct version of dependencies are installed using 'make install'"
@buf generate https://github.com/goto/proton/archive/${PROTON_COMMIT}.zip#strip_components=1 --template buf.gen.yaml --path gotocompany/shield
@cp -R proto/gotocompany/shield/* proto/ && rm -Rf proto/gotocompany
@echo " > protobuf compilation finished"
help:
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
doc: clean-doc ## Generate api and cli documentation
@echo "> generate cli docs"
@go run . reference --plain | sed '1 s,.*,# CLI,' > ./docs/docs/reference/cli.md
@echo ">generate api docs"
@cd $(CURDIR)/docs/docs; yarn docusaurus clean-api-docs all; yarn docusaurus gen-api-docs all
@echo "> format api docs"
@npx prettier --write $(CURDIR)/docs/docs/apis/*.mdx
doc-build: ## Run documentation locally
@echo "> building docs"
@cd $(CURDIR)/docs/docs; yarn start