forked from treeverse/lakeFS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
257 lines (197 loc) · 10.9 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
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
GOCMD=$(or $(shell which go), $(error "Missing dependency - no go in PATH"))
DOCKER=$(or $(shell which docker), $(error "Missing dependency - no docker in PATH"))
GOBINPATH=$(shell $(GOCMD) env GOPATH)/bin
NPM=$(or $(shell which npm), $(error "Missing dependency - no npm in PATH"))
#my comment
UID_GID := $(shell id -u):$(shell id -g)
# Protoc is a Docker dependency (since it's a pain to install locally and manage versions of it)
PROTOC_IMAGE="treeverse/protoc:3.14.0"
PROTOC=$(DOCKER) run --rm -v $(shell pwd):/mnt $(PROTOC_IMAGE)
CLIENT_JARS_BUCKET="s3://treeverse-clients-us-east/"
# https://openapi-generator.tech
OPENAPI_GENERATOR_IMAGE=openapitools/openapi-generator-cli:v5.3.0
OPENAPI_GENERATOR=$(DOCKER) run --user $(UID_GID) --rm -v $(shell pwd):/mnt $(OPENAPI_GENERATOR_IMAGE)
ifndef PACKAGE_VERSION
PACKAGE_VERSION=0.1.0-SNAPSHOT
endif
PYTHON_IMAGE=python:3
export PATH:= $(PATH):$(GOBINPATH)
GOBUILD=$(GOCMD) build
GORUN=$(GOCMD) run
GOCLEAN=$(GOCMD) clean
GOTOOL=$(GOCMD) tool
GOGENERATE=$(GOCMD) generate
GOTEST=$(GOCMD) test
GOTESTRACE=$(GOTEST) -race
GOGET=$(GOCMD) get
GOFMT=$(GOCMD)fmt
GOTEST_PARALLELISM=4
GO_TEST_MODULES=$(shell $(GOCMD) list ./... | grep -v 'lakefs/pkg/api/gen/')
LAKEFS_BINARY_NAME=lakefs
LAKECTL_BINARY_NAME=lakectl
UI_DIR=webui
UI_BUILD_DIR=$(UI_DIR)/dist
DOCKER_IMAGE=lakefs
DOCKER_TAG=dev
VERSION=dev
export VERSION
# This cannot detect whether untracked files have yet to be added.
# That is sort-of a git feature, but can be a limitation here.
DIRTY=$(shell git diff-index --quiet HEAD -- || echo '.with.local.changes')
GIT_REF=$(shell git rev-parse --short HEAD --)
REVISION=$(GIT_REF)$(DIRTY)
export REVISION
.PHONY: all clean esti lint test gen help
all: build
clean:
@rm -rf \
$(LAKECTL_BINARY_NAME) \
$(LAKEFS_BINARY_NAME) \
$(UI_BUILD_DIR) \
$(UI_DIR)/node_modules \
pkg/actions/mock \
pkg/api/lakefs.gen.go \
pkg/auth/client.gen.go \
pkg/graveler/sstable/mock \
pkg/graveler/committed/mock \
pkg/graveler/mock
check-licenses: check-licenses-go-mod check-licenses-npm
check-licenses-go-mod:
$(GOCMD) install github.com/google/go-licenses@latest
$(GOBINPATH)/go-licenses check ./cmd/$(LAKEFS_BINARY_NAME)
$(GOBINPATH)/go-licenses check ./cmd/$(LAKECTL_BINARY_NAME)
check-licenses-npm:
$(GOCMD) install github.com/senseyeio/diligent/cmd/diligent@latest
# The -i arg is a workaround to ignore NPM scoped packages until https://github.com/senseyeio/diligent/issues/77 is fixed
$(GOBINPATH)/diligent check -w permissive -i ^@[^/]+?/[^/]+ $(UI_DIR)
docs/assets/js/swagger.yml: api/swagger.yml
@cp api/swagger.yml docs/assets/js/swagger.yml
docs: docs/assets/js/swagger.yml
docs-serve: ### Serve local docs
cd docs; bundle exec jekyll serve
gen-docs: go-install ## Generate CLI docs automatically
$(GOCMD) run cmd/lakectl/main.go docs > docs/reference/commands.md
gen-metastore: ## Run Metastore Code generation
@thrift -r --gen go --gen go:package_prefix=github.com/treeverse/lakefs/pkg/metastore/hive/gen-go/ -o pkg/metastore/hive pkg/metastore/hive/hive_metastore.thrift
go-mod-download: ## Download module dependencies
$(GOCMD) mod download
go-install: go-mod-download ## Install dependencies
$(GOCMD) install github.com/deepmap/oapi-codegen/cmd/oapi-codegen
$(GOCMD) install github.com/golang/mock/mockgen
$(GOCMD) install github.com/golangci/golangci-lint/cmd/golangci-lint
$(GOCMD) install google.golang.org/protobuf/cmd/protoc-gen-go
client-python: api/swagger.yml ## Generate SDK for Python client
# remove the build folder as it also holds lakefs_client folder which keeps because we skip it during find
rm -rf clients/python/build; cd clients/python && \
find . -depth -name lakefs_client -prune -o ! \( -name client.py -or -name Gemfile -or -name Gemfile.lock -or -name _config.yml -or -name .openapi-generator-ignore \) -delete
$(OPENAPI_GENERATOR) generate \
-i /mnt/$< \
-g python \
--package-name lakefs_client \
--git-user-id treeverse --git-repo-id lakeFS \
--additional-properties=infoName=Treeverse,[email protected],packageName=lakefs_client,packageVersion=$(PACKAGE_VERSION),projectName=lakefs-client,packageUrl=https://github.com/treeverse/lakeFS/tree/master/clients/python \
-o /mnt/clients/python
client-java: api/swagger.yml ## Generate SDK for Java (and Scala) client
rm -rf clients/java
$(OPENAPI_GENERATOR) generate \
-i /mnt/$< \
-g java \
--invoker-package io.lakefs.clients.api \
--additional-properties=hideGenerationTimestamp=true,artifactVersion=$(PACKAGE_VERSION),parentArtifactId=lakefs-parent,parentGroupId=io.lakefs,parentVersion=0,groupId=io.lakefs,artifactId='api-client',artifactDescription='lakeFS OpenAPI Java client',artifactUrl=https://lakefs.io,apiPackage=io.lakefs.clients.api,modelPackage=io.lakefs.clients.api.model,mainPackage=io.lakefs.clients.api,[email protected],developerName='Treeverse lakeFS dev',developerOrganization='lakefs.io',developerOrganizationUrl='https://lakefs.io',licenseName=apache2,licenseUrl=http://www.apache.org/licenses/,scmConnection=scm:git:[email protected]:treeverse/lakeFS.git,scmDeveloperConnection=scm:git:[email protected]:treeverse/lakeFS.git,scmUrl=https://github.com/treeverse/lakeFS \
-o /mnt/clients/java
.PHONY: clients client-python client-java
clients: client-python client-java
package-python: client-python
$(DOCKER) run --user $(UID_GID) --rm -v $(shell pwd):/mnt -e HOME=/tmp/ -w /mnt/clients/python $(PYTHON_IMAGE) /bin/bash -c \
"python -m pip install build --user && python -m build --sdist --wheel --outdir dist/"
package: package-python
gen-api: go-install ## Run the swagger code generator
$(GOGENERATE) ./pkg/api
$(GOGENERATE) ./pkg/auth
.PHONY: gen-code
gen-code: go-install ## Run the generator for inline commands
$(GOGENERATE) \
./pkg/graveler/sstable \
./pkg/graveler/committed \
./pkg/graveler \
./pkg/pyramid \
./pkg/onboard \
./pkg/actions \
./pkg/auth
LD_FLAGS := "-X github.com/treeverse/lakefs/pkg/version.Version=$(VERSION)-$(REVISION)"
build: gen docs ## Download dependencies and build the default binary
$(GOBUILD) -o $(LAKEFS_BINARY_NAME) -ldflags $(LD_FLAGS) -v ./cmd/$(LAKEFS_BINARY_NAME)
$(GOBUILD) -o $(LAKECTL_BINARY_NAME) -ldflags $(LD_FLAGS) -v ./cmd/$(LAKECTL_BINARY_NAME)
lint: go-install ## Lint code
$(GOBINPATH)/golangci-lint run $(GOLANGCI_LINT_FLAGS)
npx eslint $(UI_DIR)/src --ext .js,.jsx,.ts,.tsx
esti: ## run esti (system testing)
$(GOTEST) -v ./esti --args --system-tests
test: test-go test-hadoopfs ## Run tests for the project
test-go: gen # Run parallelism > num_cores: most of our slow tests are *not* CPU-bound.
$(GOTEST) -count=1 -coverprofile=cover.out -race -cover -failfast --parallel="$(GOTEST_PARALLELISM)" $(GO_TEST_MODULES)
test-hadoopfs:
cd clients/hadoopfs && mvn test
run-test: ## Run tests without generating anything (faster if already generated)
$(GOTEST) -count=1 -coverprofile=cover.out -race -short -cover -failfast $(GO_TEST_MODULES)
fast-test: ## Run tests without race detector (faster)
$(GOTEST) -count=1 -coverprofile=cover.out -short -cover -failfast $(GO_TEST_MODULES)
test-html: test ## Run tests with HTML for the project
$(GOTOOL) cover -html=cover.out
system-tests: # Run system tests locally
./esti/scripts/runner.sh -r all
build-docker: build ## Build Docker image file (Docker required)
$(DOCKER) build -t treeverse/$(DOCKER_IMAGE):$(DOCKER_TAG) .
gofmt: ## gofmt code formating
@echo Running go formating with the following command:
$(GOFMT) -e -s -w .
validate-fmt: ## Validate go format
@echo checking gofmt...
@res=$$($(GOFMT) -d -e -s $$(find . -type d \( -path ./pkg/metastore/hive/gen-go \) -prune -o \( -path ./pkg/ddl \) -prune -o \( -path ./pkg/webui \) -prune -o \( -path ./pkg/api/gen \) -prune -o -name '*.go' -print)); \
if [ -n "$${res}" ]; then \
echo checking gofmt fail... ; \
echo "$${res}"; \
exit 1; \
else \
echo Your code formatting is according to gofmt standards; \
fi
.PHONY: validate-proto
validate-proto: proto ## build proto and check if diff found
git diff --quiet -- pkg/catalog/catalog.pb.go || (echo "Modification verification failed! graveler's catalog proto"; false)
git diff --quiet -- pkg/graveler/committed/committed.pb.go || (echo "Modification verification failed! graveler's committed proto"; false)
git diff --quiet -- pkg/graveler/graveler.pb.go || (echo "Modification verification failed! graveler's proto"; false)
git diff --quiet -- pkg/graveler/settings/test_settings.pb.go || (echo "Modification verification failed! graveler's settings test proto"; false)
validate-reference:
git diff --quiet -- docs/reference/commands.md || (echo "Modification verification failed! commands docs"; false)
validate-client-python:
git diff --quiet -- clients/python || (echo "Modification verification failed! python client"; false)
validate-client-java:
git diff --quiet -- clients/java || (echo "Modification verification failed! java client"; false)
# Run all validation/linting steps
checks-validator: lint validate-fmt validate-proto validate-client-python validate-client-java validate-reference
$(UI_DIR)/node_modules:
cd $(UI_DIR) && $(NPM) install
# UI operations
ui-build: $(UI_DIR)/node_modules ## Build UI app
cd $(UI_DIR) && $(NPM) run build
gen-ui: ui-build
proto: ## Build proto (Protocol Buffers) files
$(PROTOC) --proto_path=pkg/catalog --go_out=pkg/catalog --go_opt=paths=source_relative catalog.proto
$(PROTOC) --proto_path=pkg/graveler/committed --go_out=pkg/graveler/committed --go_opt=paths=source_relative committed.proto
$(PROTOC) --proto_path=pkg/graveler --go_out=pkg/graveler --go_opt=paths=source_relative graveler.proto
$(PROTOC) --proto_path=pkg/graveler/settings --go_out=pkg/graveler/settings --go_opt=paths=source_relative test_settings.proto
$(PROTOC) --proto_path=pkg/kv/kvtest --go_out=pkg/kv/kvtest --go_opt=paths=source_relative test_model.proto
$(PROTOC) --proto_path=pkg/kv --go_out=pkg/kv --go_opt=paths=source_relative secondary_index.proto
$(PROTOC) --proto_path=pkg/gateway/multiparts --go_out=pkg/gateway/multiparts --go_opt=paths=source_relative multipart.proto
$(PROTOC) --proto_path=pkg/actions --go_out=pkg/actions --go_opt=paths=source_relative actions.proto
$(PROTOC) --proto_path=pkg/auth/model --go_out=pkg/auth/model --go_opt=paths=source_relative model.proto
publish-scala: ## sbt publish spark client jars to nexus and s3 bucket
cd clients/spark && sbt assembly && sbt s3Upload && sbt publishSigned
aws s3 cp --recursive --acl public-read $(CLIENT_JARS_BUCKET) $(CLIENT_JARS_BUCKET) --metadata-directive REPLACE
publish-lakefsfs-test: ## sbt publish spark lakefsfs test jars to s3 bucket
cd test/lakefsfs && sbt assembly && sbt s3Upload
aws s3 cp --recursive --acl public-read $(CLIENT_JARS_BUCKET) $(CLIENT_JARS_BUCKET) --metadata-directive REPLACE
help: ## Show Help menu
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# helpers
gen: gen-api gen-ui gen-code clients gen-docs