-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
174 lines (141 loc) · 5.43 KB
/
Makefile
File metadata and controls
174 lines (141 loc) · 5.43 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# Project metadata
MODULE_NAME := nebula-sirius
PKG := ./...
BIN_DIR := bin
COVERAGE_FILE := coverage.out
# Tools
GOLINT := golangci-lint
GOFMT := gofmt
GODOC := godoc
# Tool installation stage
.PHONY: tools
tools:
@echo "🔧 Checking required tools..."
@if ! command -v gofmt >/dev/null 2>&1; then \
echo "Installing gofmt..."; \
go install golang.org/x/tools/cmd/gofmt@latest; \
else \
echo "✔ gofmt found"; \
fi
@if ! command -v golangci-lint >/dev/null 2>&1; then \
echo "Installing golangci-lint..."; \
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest; \
else \
echo "✔ golangci-lint found"; \
fi
@if ! command -v godoc >/dev/null 2>&1; then \
echo "Installing godoc..."; \
go install golang.org/x/tools/cmd/godoc@latest; \
else \
echo "✔ godoc found"; \
fi
@if ! command -v mockery >/dev/null 2>&1; then \
echo "Installing mockery..."; \
go install github.com/vektra/mockery/v2@latest; \
else \
echo "✔ mockery found"; \
fi
.PHONY: fmt
fmt:
@echo "🧹 Formatting Go code (excluding nebula/ and mocks/)..."
@find . -type f -name '*.go' \
! -path './nebula/*' \
! -path './mocks/*' \
-exec gofmt -s -w {} +
# Lint code
.PHONY: lint
lint:
@echo "Linting..."
@$(GOLINT) run
# Run `go mod tidy`
.PHONY: tidy
tidy:
@echo "Tidying modules..."
@go mod tidy
.PHONY: test
test:
@echo "Running tests..."
@go test -v -race -coverprofile=$(COVERAGE_FILE) $(PKG)
# Clean generated files
.PHONY: clean
clean:
@echo "Cleaning..."
@rm -rf $(BIN_DIR) $(COVERAGE_FILE)
# Display coverage in terminal
.PHONY: cover
cover:
@go tool cover -func=$(COVERAGE_FILE)
# Serve documentation locally
.PHONY: doc
doc:
@echo "Starting documentation server at http://localhost:6060"
@godoc -http=:6060
########################################################################
####### BEGIN: DOCKER COMPOSE PART
.PHONY: docker-compose-up
docker-compose-up:
cd nebulagraph-light-deployment && docker-compose -f docker-compose-lite.yml up -d
.PHONY: docker-compose-down
docker-compose-down:
cd nebulagraph-light-deployment && docker-compose -f docker-compose-lite.yml down
.PHONY: docker-compose-up-ssl
docker-compose-up-ssl:
cd nebulagraph-light-deployment && enable_ssl=true docker-compose -f docker-compose-lite-ssl.yml up -d
.PHONY: docker-compose-down-ssl
docker-compose-down-ssl:
cd nebulagraph-light-deployment && docker-compose -f docker-compose-lite-ssl.yml down
########################################################################
####### END: DOCKER COMPOSE PART
########################################################################
####### BEGIN: THRIFT FILES SYNC PART
########################################################################
THRIFT_FILES_DIR = ./thriftfiles
REMOTE_THRIFT_FILES_URL = https://raw.githubusercontent.com/vesoft-inc/nebula/master/src/interface
.PHONY: download-thrift-files
download-thrift-files: $(THRIFT_FILES_DIR)
curl -s -o $(THRIFT_FILES_DIR)/common.thrift $(REMOTE_THRIFT_FILES_URL)/common.thrift \
curl -s -o $(THRIFT_FILES_DIR)/meta.thrift $(REMOTE_THRIFT_FILES_URL)/meta.thrift \
curl -s -o $(THRIFT_FILES_DIR)/graph.thrift $(REMOTE_THRIFT_FILES_URL)/graph.thrift \
curl -s -o $(THRIFT_FILES_DIR)/storage.thrift $(REMOTE_THRIFT_FILES_URL)/storage.thrift \
curl -s -o $(THRIFT_FILES_DIR)/raftex.thrift $(REMOTE_THRIFT_FILES_URL)/raftex.thrift \
########################################################################
####### END: THRIFT FILES SYNC PART
########################################################################
########################################################################
####### BEGIN: APACHE THRIFT CODE GENERATION PART
########################################################################
# Variables
THRIFT_DIR := thriftfiles
OUTPUT_DIR := nebula
PACKAGE_PREFIX := nebula
# Find all Thrift files in the directory
THRIFT_FILES := $(wildcard $(THRIFT_DIR)/*.thrift)
.PHONY: generate-from-contracts
generate-from-contracts:
thrift --gen go:package_prefix=github.com/nebula-contrib/nebula-sirius/ -out . thriftfiles/graph.thrift \
thrift --gen go:package_prefix=github.com/nebula-contrib/nebula-sirius/ -out . thriftfiles/meta.thrift \
thrift --gen go:package_prefix=github.com/nebula-contrib/nebula-sirius/ -out . thriftfiles/storage.thrift \
thrift --gen go:package_prefix=github.com/nebula-contrib/nebula-sirius/ -out . thriftfiles/common.thrift
########################################################################
####### END: APACHE THRIFT CODE GENERATION PART
########################################################################
########################################################################
####### BEGIN: MOCK GENERATION PART
########################################################################
# Generate mocks for all interfaces
.PHONY: generate-mocks
generate-mocks:
@mockery --all --recursive --output=./mocks --case=underscore
# Generate mock for specific interface thrift.TTransport
.PHONY: generate-mock-thrift-transport
generate-mock-thrift-transport:
@mockery --name=TTransport --dir=$(go env GOPATH)/pkg/mod/github.com/apache/thrift@v0.21.0/lib/go/thrift --output=./mocks --case=underscore
# Clean generated mocks
.PHONY: clean-mocks
clean-mocks:
@echo "Cleaning mocks..."
@rm -rf ./mocks
# Add other targets as needed
########################################################################
####### END: MOCK GENERATION PART
########################################################################