forked from raystack/siren
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
80 lines (62 loc) · 3.12 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
NAME="github.com/goto/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 := "97b7716bc946189937bbd20655e355f6123f4e87"
.PHONY: all build test clean dist vet proto install
all: build
build: build-main build-plugins
build-main: ## Build the siren binary
@echo " > building siren version ${APP_VERSION}"
go build -ldflags "-X main.Version=${APP_VERSION}" ${NAME}
@echo " > building plugins version ${APP_VERSION}"
@echo " - build complete"
build-plugins:
@echo " > building plugins"
@go list -m | grep providers | while read path; do go build -o ./plugin/${shell basename "$$path"} "$$path"; done
@echo " - build complete"
test: ## Run the tests
go test -race $(shell go list ./... | grep -v /test/ | grep -v /mocks) -covermode=atomic -coverprofile=coverage.out
e2e-test: build-plugins ## 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)
@go generate ./...
@echo " > generating mock files"
@mockery
lint: ## lint checker
golangci-lint run
proto: ## Generate the protobuf files
@echo " > generating protobuf from gotocompany/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/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
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
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
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}'