-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
76 lines (59 loc) · 2.64 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
NAME=github.com/odpf/kay
VERSION=$(shell git describe --tags --always --first-parent 2>/dev/null)
COMMIT=$(shell git rev-parse --short HEAD)
BUILD_TIME=$(shell date)
COVERAGE_DIR=coverage
BUILD_DIR=dist
EXE=kay
PROTON_COMMIT := "f1b701ccaac3cb0a27b99cae6cd7a9e32188673d"
.PHONY: all build clean tidy format test test-coverage proto
all: clean test build format lint
tidy: ## Tidy up the code
@echo "Tidy up go.mod..."
@go mod tidy -v
install: ## Install the binary
@echo "Installing Kay to ${GOBIN}..."
@go install
format: ## Format the code
@echo "Running gofumpt..."
@gofumpt -l -w .
lint: ## Lint the code
@echo "Running lint checks using golangci-lint..."
@golangci-lint run
clean: tidy ## Clean up the build artifacts
@echo "Cleaning up build directories..."
@rm -rf ${COVERAGE_DIR} ${BUILD_DIR}
@echo "Running go-generate..."
@go generate ./...
test: tidy ## Run the tests
@mkdir -p ${COVERAGE_DIR}
@echo "Running unit tests..."
@go test ./... -coverprofile=${COVERAGE_DIR}/coverage.out
test-coverage: test ## Run the tests with coverage
@echo "Generating coverage report..."
@go tool cover -html=${COVERAGE_DIR}/coverage.out
build: clean ## Build the binary
@mkdir -p ${BUILD_DIR}
@echo "Running build for '${VERSION}' in '${BUILD_DIR}/'..."
@CGO_ENABLED=0 go build -ldflags '-X "${NAME}/pkg/version.Version=${VERSION}" -X "${NAME}/pkg/version.Commit=${COMMIT}" -X "${NAME}/pkg/version.BuildTime=${BUILD_TIME}"' -o ${BUILD_DIR}/${EXE}
download: ## Download go dependencies
@go mod download
proto: ## Generate the protobuf files
@echo " > generating protobuf from odpf/proton"
@echo " > [info] make sure correct version of dependencies are installed using 'make setup'"
@buf generate https://github.com/odpf/proton/archive/${PROTON_COMMIT}.zip#strip_components=1 --template buf.gen.yaml --path odpf/kay
@echo " > protobuf compilation finished"
setup: ## Install dependencies
@echo "> installing dependencies"
@go mod tidy
@go install github.com/vektra/mockery/[email protected]
@go install google.golang.org/protobuf/cmd/[email protected]
@go get google.golang.org/protobuf/[email protected]
@go get 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/envoyproxy/[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}'