/
Makefile
80 lines (60 loc) · 2.74 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
GOVERSION := $(shell go version | cut -d ' ' -f 3 | cut -d '.' -f 2)
NAME=github.com/odpf/shield
TAG := "$(shell git rev-list --tags --max-count=1)"
VERSION := "$(shell git describe --tags ${TAG})"
.PHONY: build check fmt lint test test-race vet test-cover-html help install proto ui
.DEFAULT_GOAL := build
PROTON_COMMIT := "6a3ba5af8fb2e25094520ebe41692339783652e8"
ui:
@echo " > generating ui build"
@cd ui && $(MAKE)
install:
@echo "Clean up imports..."
@go mod download
@go get -d github.com/vektra/mockery/v2@v2.13.1
build:
CGO_ENABLED=0 go build -ldflags "-X ${NAME}/cmd.Version=${VERSION}" -o shield .
generate: ## run all go generate in the code base (including generating mock files)
go generate ./...
lint: ## Run linters
golangci-lint run
lint-fix:
golangci-lint run --fix
# TODO: create separate command for integration tests
test: ## Run tests
@go test -race $(shell go list ./... | grep -v /ui | grep -v /vendor/ | grep -v /test/) -coverprofile=coverage.out -count 3
test-all: test e2e-smoke-test e2e-regression-test integration-test ## Run all tests
e2e-test: ## Run all e2e tests
## run `docker network prune` if docker fails to find non-overlapping ipv4 address pool
go test -v -race ./test/e2e/...
e2e-smoke-test: ## Run smoke tests
go test -v -race ./test/e2e/smoke
e2e-regression-test: ## Run regression tests
go test -v -race ./test/e2e/regression
integration-test:
go test -v -race ./test/integration
benchmark: ## Run benchmarks
go test -run=XX -bench=Benchmark. -count 3 -benchtime=1s github.com/odpf/shield/test/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 odpf/proton"
@echo " > [info] make sure correct version of dependencies are installed using 'make install'"
@buf generate https://github.com/odpf/proton/archive/${PROTON_COMMIT}.zip#strip_components=1 --template buf.gen.yaml --path odpf/shield
@cp -R proto/odpf/shield/* proto/ && rm -Rf proto/odpf
@echo " > protobuf compilation finished"
clean-doc:
@echo "> cleaning up auto-generated docs"
@rm -rf ./docs/docs/reference/cli.md
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 ">genetaye api docs"
@cd $(CURDIR)/docs/docs; yarn docusaurus clean-api-docs all; yarn docusaurus gen-api-docs all
doc-build: ## Run documentation locally
@echo "> building docs"
@cd $(CURDIR)/docs/docs; yarn start
help:
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'