-
Notifications
You must be signed in to change notification settings - Fork 444
Expand file tree
/
Copy pathMakefile
More file actions
312 lines (244 loc) · 15 KB
/
Makefile
File metadata and controls
312 lines (244 loc) · 15 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
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
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"))
UID_GID := $(shell id -u):$(shell id -g)
CLIENT_JARS_BUCKET="s3://treeverse-clients-us-east/"
# https://openapi-generator.tech
OPENAPI_GENERATOR_IMAGE=treeverse/openapi-generator-cli:v7.0.1.4
OPENAPI_GENERATOR=$(DOCKER) run -e JAVA_OPTS="-Dlog.level=error" --user $(UID_GID) --rm -v $(shell pwd):/mnt $(OPENAPI_GENERATOR_IMAGE)
PY_OPENAPI_GENERATOR=$(DOCKER) run -e JAVA_OPTS="-Dlog.level=error" -e PYTHON_POST_PROCESS_FILE="/mnt/clients/python-static/pydantic.sh" --user $(UID_GID) --rm -v $(shell pwd):/mnt $(OPENAPI_GENERATOR_IMAGE)
OPENAPI_RUST_GENERATOR_IMAGE=openapitools/openapi-generator-cli:v7.5.0
OPENAPI_RUST_GENERATOR=$(DOCKER) run -e JAVA_OPTS="-Dlog.level=error" --user $(UID_GID) --rm -v $(shell pwd):/mnt $(OPENAPI_RUST_GENERATOR_IMAGE)
BUF_CLI_VERSION=v1.54.0
ifndef PACKAGE_VERSION
PACKAGE_VERSION=0.0.0
endif
PYTHON_IMAGE=python:3.10
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_FLAGS=-count=1 -race -failfast
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
@mkdir -p $(UI_BUILD_DIR) && touch $(UI_BUILD_DIR)/.gitkeep
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-serve: ### Serve local docs
$(DOCKER) run --rm -it -p 4000:4000 -v ./docs:/docs --entrypoint /bin/sh squidfunk/mkdocs-material:9 -c "cd /docs && pip install -r requirements-docs.txt && mkdocs serve --dev-addr=0.0.0.0:4000"
gen-docs: ## Generate CLI docs automatically
$(GOCMD) run cmd/lakectl/main.go docs > docs/src/reference/cli.md
.PHONY: tools
tools: ## Install tools
$(GOCMD) install github.com/bufbuild/buf/cmd/buf@$(BUF_CLI_VERSION)
client-python: api/swagger.yml ## Generate SDK for Python client - openapi generator version 7.0.0
@rm -rf clients/python
@mkdir -p clients/python
@cp clients/python-static/.openapi-generator-ignore clients/python
@echo "Generating Python client SDK"
$(PY_OPENAPI_GENERATOR) generate \
-i /mnt/$< \
-g python \
-t /mnt/clients/python-static/templates \
-c /mnt/clients/python-static/python-codegen-config.yaml \
--enable-post-process-file \
--package-name lakefs_sdk \
--http-user-agent "lakefs-python-sdk/$(PACKAGE_VERSION)" \
--git-user-id treeverse --git-repo-id lakeFS \
--additional-properties=infoName=Treeverse,infoEmail=services@treeverse.io,packageVersion=$(PACKAGE_VERSION),projectName=lakefs-sdk,packageUrl=https://github.com/treeverse/lakeFS/tree/master/clients/python \
-o /mnt/clients/python
sdk-rust: api/swagger.yml ## Generate SDK for Rust client - openapi generator version 7.1.0
@rm -rf clients/rust
@mkdir -p clients/rust
@echo "Generating Rust client SDK"
$(OPENAPI_RUST_GENERATOR) generate \
-i /mnt/api/swagger.yml \
-g rust \
--additional-properties=infoName=Treeverse,infoEmail=services@treeverse.io,packageName=lakefs_sdk,packageVersion=$(PACKAGE_VERSION),packageUrl=https://github.com/treeverse/lakeFS/tree/master/clients/rust \
-o /mnt/clients/rust
client-java: api/swagger.yml api/java-gen-ignore ## Generate SDK for Java (and Scala) client
@rm -rf clients/java
@mkdir -p clients/java
@cp api/java-gen-ignore clients/java/.openapi-generator-ignore
@echo "Generating Java client SDK"
$(OPENAPI_GENERATOR) generate \
-i /mnt/api/swagger.yml \
-g java \
--invoker-package io.lakefs.clients.sdk \
--http-user-agent "lakefs-java-sdk/$(PACKAGE_VERSION)-v1" \
--additional-properties disallowAdditionalPropertiesIfNotPresent=false,useSingleRequestParameter=true,hideGenerationTimestamp=true,artifactVersion=$(PACKAGE_VERSION),parentArtifactId=lakefs-parent,parentGroupId=io.lakefs,parentVersion=0,groupId=io.lakefs,artifactId='sdk',artifactDescription='lakeFS OpenAPI Java client',artifactUrl=https://lakefs.io,apiPackage=io.lakefs.clients.sdk,modelPackage=io.lakefs.clients.sdk.model,mainPackage=io.lakefs.clients.sdk,developerEmail=services@treeverse.io,developerName='Treeverse lakeFS dev',developerOrganization='lakefs.io',developerOrganizationUrl='https://lakefs.io',licenseName=apache2,licenseUrl=http://www.apache.org/licenses/,scmConnection=scm:git:git@github.com:treeverse/lakeFS.git,scmDeveloperConnection=scm:git:git@github.com:treeverse/lakeFS.git,scmUrl=https://github.com/treeverse/lakeFS \
-o /mnt/clients/java
.PHONY: clients client-python client-java
clients: client-python client-java sdk-rust
package-python: package-python-sdk package-python-wrapper
package-python-sdk: 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-python-wrapper:
$(DOCKER) run --user $(UID_GID) --rm -v $(shell pwd):/mnt -e HOME=/tmp/ -w /mnt/clients/python-wrapper $(PYTHON_IMAGE) /bin/bash -c \
"python -m pip install build --user && python -m build --sdist --wheel --outdir dist/"
package: package-python
.PHONY: gen-api
gen-api: ## Run the swagger code generator
$(GOGENERATE) ./pkg/api/apigen ./pkg/auth ./pkg/authentication
.PHONY: gen-code
gen-code: gen-api ## Run the generator for inline commands
$(GOGENERATE) \
./contrib/auth/acl \
./pkg/actions \
./pkg/distributed \
./pkg/graveler \
./pkg/graveler/committed \
./pkg/graveler/sstable \
./pkg/kv \
./pkg/permissions \
./pkg/pyramid \
./tools/wrapgen/testcode
LD_FLAGS := "-X github.com/treeverse/lakefs/pkg/version.Version=$(VERSION)-$(REVISION)"
build: gen build-binaries ## Download dependencies and build the default binary
build-binaries:
$(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: ## Lint code
$(GOCMD) tool golangci-lint run ./... $(GOLANGCI_LINT_FLAGS)
cd $(UI_DIR) && npm run lint
esti: ## run esti (system testing)
$(GOTEST) -v ./esti --args --system-tests
test: test-go test-hadoopfs ## Run tests for the project
test-go: gen-api # Run parallelism > num_cores: most of our slow tests are *not* CPU-bound.
go list -f '{{.Dir}}/...' -m | xargs $(GOTEST) -coverprofile=cover.out -cover $(GOTEST_FLAGS) ./...
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 ./...
fast-test: ## Run tests without race detector (faster)
$(GOTEST) -count=1 -coverprofile=cover.out -short -cover -failfast ./...
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) buildx build --target lakefs -t treeverse/$(DOCKER_IMAGE):$(DOCKER_TAG) .
gofmt: ## gofmt code formating
@echo Running go formating with the following command:
$(GOFMT) -e -s -w .
.PHONY: validate-proto
validate-proto: gen-proto ## build proto and check if diff found
git diff --quiet -- pkg/actions/actions.pb.go || (echo "Modification verification failed! pkg/actions/actions.pb.go"; false)
git diff --quiet -- pkg/auth/model/model.pb.go || (echo "Modification verification failed! pkg/auth/model/model.pb.go"; false)
git diff --quiet -- pkg/catalog/catalog.pb.go || (echo "Modification verification failed! pkg/catalog/catalog.pb.go"; false)
git diff --quiet -- pkg/gateway/multipart/multipart.pb.go || (echo "Modification verification failed! pkg/gateway/multipart/multipart.pb.go"; false)
git diff --quiet -- pkg/graveler/graveler.pb.go || (echo "Modification verification failed! pkg/graveler/graveler.pb.go"; false)
git diff --quiet -- pkg/graveler/committed/committed.pb.go || (echo "Modification verification failed! pkg/graveler/committed/committed.pb.go"; false)
git diff --quiet -- pkg/graveler/settings/test_settings.pb.go || (echo "Modification verification failed! pkg/graveler/settings/test_settings.pb.go"; false)
git diff --quiet -- pkg/kv/secondary_index.pb.go || (echo "Modification verification failed! pkg/kv/secondary_index.pb.go"; false)
git diff --quiet -- pkg/kv/kvtest/test_model.pb.go || (echo "Modification verification failed! pkg/kv/kvtest/test_model.pb.go"; false)
.PHONY: validate-mockgen
validate-mockgen: gen-code
git diff --quiet -- pkg/actions/mock/mock_actions.go || (echo "Modification verification failed! pkg/actions/mock/mock_actions.go"; false)
git diff --quiet -- pkg/auth/mock/mock_auth_client.go || (echo "Modification verification failed! pkg/auth/mock/mock_auth_client.go"; false)
git diff --quiet -- pkg/authentication/api/mock_authentication_client.go || (echo "Modification verification failed! pkg/authentication/api/mock_authentication_client.go"; false)
git diff --quiet -- pkg/graveler/committed/mock/batch_write_closer.go || (echo "Modification verification failed! pkg/graveler/committed/mock/batch_write_closer.go"; false)
git diff --quiet -- pkg/graveler/committed/mock/meta_range.go || (echo "Modification verification failed! pkg/graveler/committed/mock/meta_range.go"; false)
git diff --quiet -- pkg/graveler/committed/mock/range_manager.go || (echo "Modification verification failed! pkg/graveler/committed/mock/range_manager.go"; false)
git diff --quiet -- pkg/graveler/mock/graveler.go || (echo "Modification verification failed! pkg/graveler/mock/graveler.go"; false)
git diff --quiet -- pkg/graveler/hooks_handler_isvalid.gen.go || (echo "Modification verification failed! pkg/graveler/hooks_handler_isvalid.gen.go"; false)
git diff --quiet -- pkg/kv/mock/store.go || (echo "Modification verification failed! pkg/kv/mock/store.go"; false)
git diff --quiet -- pkg/pyramid/mock/pyramid.go || (echo "Modification verification failed! pkg/pyramid/mock/pyramid.go"; false)
git diff --quiet -- contrib/auth/apigen/authapi.gen.go || (echo "Modification verification failed! contrib/auth/apigen/authapi.gen.go"; false)
.PHONY: validate-permissions-gen
validate-permissions-gen: gen-code
git diff --quiet -- pkg/permissions/actions.gen.go || (echo "Modification verification failed! pkg/permissions/actions.gen.go"; false)
.PHONY: validate-api
validate-api: gen-api
git diff --quiet -- pkg/api/apigen/lakefs.gen.go || (echo "Modification verification failed! pkg/api/apigen/lakefs.gen.go"; false)
git diff --quiet -- pkg/auth/client.gen.go || (echo "Modification verification failed! pkg/auth/client.gen.go"; false)
git diff --quiet -- pkg/authentication/apiclient/client.gen.go || (echo "Modification verification failed! pkg/authentication/apiclient/client.gen.go"; false)
.PHONY: validate-wrapper
validate-wrapper: gen-code
git diff --quiet -- pkg/auth/service_wrapper.gen.go || (echo "Modification verification failed! pkg/auth/service_wrapper.gen.go"; false)
git diff --quiet -- pkg/auth/service_inviter_wrapper.gen.go || (echo "Modification verification failed! pkg/auth/service_inviter_wrapper.gen.go"; false)
.PHONY: validate-wrapgen-testcode
validate-wrapgen-testcode: gen-code
git diff --quiet -- ./tools/wrapgen/testcode || (echo "Modification verification failed! tools/wrapgen/testcode"; false)
validate-reference:
git diff --quiet -- docs/src/reference/cli.md || (echo "Modification verification failed! docs/src/reference/cli.md"; false)
validate-client-python: validate-python-sdk
validate-python-sdk:
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)
validate-client-rust:
git diff --quiet -- clients/rust || (echo "Modification verification failed! rust client"; false)
validate-python-wrapper:
sphinx-apidoc -o clients/python-wrapper/docs clients/python-wrapper/lakefs sphinx-apidoc --full -A 'Treeverse' -eq
git diff --quiet -- clients/python-wrapper || (echo 'Modification verification failed! python wrapper client'; false)
validate-ui-format: ## Validate UI code formatting with prettier
cd $(UI_DIR) && $(NPM) run format:check
# Run all validation/linting steps
checks-validator: lint validate-proto validate-ui-format \
validate-client-python validate-client-java validate-client-rust validate-reference \
validate-mockgen \
validate-permissions-gen \
validate-api \
validate-wrapper validate-wrapgen-testcode
python-wrapper-lint:
$(DOCKER) run --user $(UID_GID) --rm -v $(shell pwd):/mnt -e HOME=/tmp/ -w /mnt/clients/python-wrapper $(PYTHON_IMAGE) /bin/bash -c "./lint.sh"
python-wrapper-gen-docs:
@version=$$(python -m pip install -r clients/python-wrapper/requirements.txt && python clients/python-wrapper/_version.py)
sphinx-build -b html -W clients/python-wrapper/docs clients/python-wrapper/_site/
sphinx-build -b html -W clients/python-wrapper/docs clients/python-wrapper/_site/$$version
$(UI_DIR)/node_modules:
cd $(UI_DIR) && $(NPM) install
gen-ui: $(UI_DIR)/node_modules ## Build UI web app
cd $(UI_DIR) && $(NPM) run build
gen-proto: ## Build Protocol Buffers (proto) files using Buf CLI
go run github.com/bufbuild/buf/cmd/buf@$(BUF_CLI_VERSION) generate
.PHONY: publish-scala
publish-scala: ## sbt publish spark client jars to Maven Central and to s3 bucket
cd clients/spark && \
sbt -Dpublish.bucket=$(S3_PUBLISH_BUCKET) '+assembly; +publishSigned; +s3Upload; sonaRelease'
.PHONY: publish-lakefsfs-test
publish-lakefsfs-test: ## sbt publish spark lakefsfs test jars to s3 bucket
cd test/lakefsfs && sbt 'assembly; 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-ui gen-api gen-code clients gen-docs
validate-clients-untracked-files:
scripts/verify_clients_untracked_files.sh