-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
70 lines (55 loc) · 2.7 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
NAME="github.com/odpf/siren"
LAST_COMMIT := $(shell git rev-parse --short HEAD)
LAST_TAG := "$(shell git rev-list --tags --max-count=1)"
APP_VERSION := "$(shell git describe --tags ${LAST_TAG})-next"
PROTON_COMMIT := "9cdffc3c1838ec72b35b2a1b9a170ca9c138db66"
.PHONY: all build test clean dist vet proto install
all: build
build: ## Build the siren binary
@echo " > building siren version ${APP_VERSION}"
go build -ldflags "-X main.Version=${APP_VERSION}" ${NAME}
@echo " - build complete"
test: ## Run the tests
go test -race $(shell go list ./... | grep -v /test/) -covermode=atomic -coverprofile=coverage.out
e2e-test: ## Run all e2e tests
go test -v -race ./test/e2e_test/... -coverprofile=coverage.out --timeout 300s
coverage: ## Print code coverage
go test -race -coverprofile coverage.out -covermode=atomic ./... && go tool cover -html=coverage.out
generate: ## run all go generate in the code base (including generating mock files)
find . -type d -name "mocks" | xargs rm -r
go generate ./...
lint: ## lint checker
golangci-lint run
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/siren
@echo " > protobuf compilation finished"
clean: ## Clean the build artifacts
rm -rf siren dist/
update-swagger-md:
@echo "> updating reference api docs"
@npx swagger-markdown -i proto/siren.swagger.yaml -o docs/docs/reference/api.md
install: ## install required dependencies
@echo "> installing dependencies"
go mod tidy
go get -d github.com/vektra/mockery/[email protected]
go get -d google.golang.org/protobuf/cmd/[email protected]
go get google.golang.org/protobuf/[email protected]
go get google.golang.org/[email protected]
go get -d google.golang.org/grpc/cmd/[email protected]
go get -d github.com/grpc-ecosystem/grpc-gateway/v2/[email protected]
go get -d github.com/grpc-ecosystem/grpc-gateway/v2/[email protected]
go get -d github.com/bufbuild/buf/cmd/[email protected]
go get github.com/envoyproxy/[email protected]
clean-doc:
@echo "> cleaning up auto-generated docs"
@rm -rf ./docs/docs/reference/cli
@rm -f ./docs/docs/reference/api.md
# Generates the config file documentation.
# remove ansi color & escape html
doc: clean-doc update-swagger-md
@echo "> generate cli docs"
@go run . reference --plain | sed '1 s,.*,# CLI,' > ./docs/docs/reference/cli.md
help: ## Display this help message
@cat $(MAKEFILE_LIST) | grep -e "^[a-zA-Z_\-]*: *.*## *" | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'