forked from raystack/entropy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
75 lines (60 loc) · 2.42 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
NAME=github.com/goto/entropy
VERSION=$(shell git describe --tags --always --first-parent 2>/dev/null)
COMMIT=$(shell git rev-parse --short HEAD)
PROTON_COMMIT="6c5bc2b621abe2812cc8288a5f6363570bab911a"
BUILD_TIME=$(shell date)
COVERAGE_DIR=coverage
BUILD_DIR=dist
EXE=entropy
.PHONY: all build clean tidy format test test-coverage proto
all: format clean test build
tidy:
@echo "Tidy up go.mod..."
@go mod tidy -v
install: ## install required dependencies
@echo "> installing dependencies"
go install github.com/vektra/mockery/v2@latest
go install google.golang.org/protobuf/cmd/[email protected]
go get -d google.golang.org/protobuf/[email protected]
go get -d 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]
format:
@echo "Running gofumpt..."
@gofumpt -l -w .
lint:
@echo "Running lint checks using golangci-lint..."
@golangci-lint run
clean: tidy
@echo "Cleaning up build directories..."
@rm -rf ${COVERAGE_DIR} ${BUILD_DIR}
generate:
@echo "Running go-generate..."
@go generate ./...
test: tidy
@mkdir -p ${COVERAGE_DIR}
@echo "Running unit tests..."
@go test ./... -coverprofile=${COVERAGE_DIR}/coverage.out
e2e-test: tidy
@echo "Running e2e-test tests..."
@go test -v ./test/e2e_test/... -timeout 20m
test-coverage: test
@echo "Generating coverage report..."
@go tool cover -html=${COVERAGE_DIR}/coverage.out
build: clean
@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}
proto: ## Generate the protobuf files
@echo " > generating protobuf from goto/proton"
@echo " > [info] make sure correct version of dependencies are installed using 'make install'"
@rm -rf ./proto
@buf generate https://github.com/goto/proton/archive/${PROTON_COMMIT}.zip#strip_components=1 --template buf.gen.yaml --path gotocompany/entropy --path gotocompany/common
@echo " > protobuf compilation finished"
download:
@go mod download
setup:
@go install github.com/vektra/mockery/[email protected]