-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
94 lines (69 loc) · 2.68 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
NAME="github.com/raystack/compass"
COMMIT := $(shell git rev-parse --short HEAD)
TAG := "$(shell git rev-list --tags --max-count=1)"
VERSION := "$(shell git describe --tags ${TAG})-next"
BUILD_DIR=dist
PROTON_COMMIT := "ccbf219312db35a934361ebad895cb40145ca235"
.PHONY: all build clean test tidy vet proto setup format generat
all: clean test build format lint
tidy:
@echo "Tidy up go.mod..."
@go mod tidy -v
install:
@echo "Installing Guardian to ${GOBIN}..."
@go install
format:
@echo "Running go fmt..."
@go fmt
lint: ## Lint checker
@echo "Running lint checks using golangci-lint..."
@golangci-lint run
clean: tidy ## Clean the build artifacts
@echo "Cleaning up build directories..."
@rm -rf $coverage.out ${BUILD_DIR}
test: ## Run the tests
go test ./... -race -coverprofile=coverage.out
e2e: ## Run all e2e tests
go test ./test/... --tags=e2e
coverage: test ## Print the code coverage
@echo "Generating coverage report..."
@go tool cover -html=coverage.out
build: ## Build the compass binary
@echo "Building guardian version ${VERSION}..."
CGO_ENABLED=0 go build -ldflags "-X ${NAME}/cli.Version=${VERSION}"
@echo "Build complete"
buildr: setup
goreleaser --snapshot --skip-publish --rm-dist
vet:
go vet ./...
download:
@go mod download
generate: ## Run all go generate in the code base
@echo "Running go generate..."
go generate ./...
config: ## Generate the sample config file
@echo "Initializing sample server config..."
@cp config/config.yaml config.yaml
proto: ## Generate the protobuf files
@echo "Generating protobuf from raystack/proton"
@echo " [info] make sure correct version of dependencies are installed using 'make install'"
@buf generate https://github.com/raystack/proton/archive/${PROTON_COMMIT}.zip#strip_components=1 --template buf.gen.yaml --path raystack/compass -v
@echo "Protobuf compilation finished"
setup: ## Install required dependencies
@echo "> Installing dependencies..."
go mod tidy
go install github.com/vektra/mockery/[email protected]
go install google.golang.org/protobuf/[email protected]
go install google.golang.org/[email protected]
go install github.com/bufbuild/buf/cmd/[email protected]
swagger-md:
npx swagger-markdown -i proto/compass.swagger.yaml -o docs/docs/reference/api.md
clean-doc:
@echo "> cleaning up auto-generated docs"
@rm -rf ./docs/docs/reference/cli.md
@rm -f ./docs/docs/reference/api.md
doc: clean-doc update-swagger-md ## Generate api and cli references
@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}'