-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile
98 lines (76 loc) · 3.15 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
95
96
97
98
NAME="github.com/raystack/guardian"
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 := "9a4736fa34b310bb2d76371a72173ad984516050"
.PHONY: all build clean test tidy vet proto setup format generate
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
lintf: ## Lint checker and fix
@echo "Running lint checks using golangci-lint..."
@golangci-lint run --fix
clean: tidy ## Clean the build artifacts
@echo "Cleaning up build directories..."
@rm -rf $coverage.out ${BUILD_DIR}
test: tidy ## Run the tests
go test ./... -race -coverprofile=coverage.out
test-short:
@echo "Running short tests by disabling store tests..."
go test ./... -race -short -coverprofile=coverage.out
coverage: test ## Print the code coverage
@echo "Generating coverage report..."
@go tool cover -html=coverage.out
build: ## Build the guardian binary
@echo "Building guardian version ${VERSION}..."
go build -ldflags "-X ${NAME}/core.Version=${VERSION} -X ${NAME}/core.BuildCommit=${COMMIT}" -o dist/guardian .
@echo "Build complete"
buildr: setup
goreleaser --snapshot --skip-publish --rm-dist
vet:
go vet ./...
download:
@echo Download go.mod dependencies
@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 internal/server/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/guardian
@echo "Protobuf compilation finished"
setup: ## Install all the dependencies
@echo "Installing dependencies..."
go mod tidy
go install google.golang.org/protobuf/cmd/[email protected]
go install github.com/golang/protobuf/[email protected]
go install github.com/golang/protobuf/[email protected]
go install google.golang.org/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
go install github.com/grpc-ecosystem/grpc-gateway/v2/[email protected]
go install github.com/grpc-ecosystem/grpc-gateway/v2/[email protected]
go install github.com/bufbuild/buf/cmd/[email protected]
go install github.com/vektra/mockery/[email protected]
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}'
doc: ## Generate api documentation
@echo ">genetate 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