forked from databricks/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
214 lines (153 loc) · 7.32 KB
/
Makefile
File metadata and controls
214 lines (153 loc) · 7.32 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
default: checks fmt lint
# Default packages to test (all)
TEST_PACKAGES = ./acceptance/internal ./libs/... ./internal/... ./cmd/... ./bundle/... ./experimental/ssh/... .
# Default acceptance test filter (all)
ACCEPTANCE_TEST_FILTER = ""
GO_TOOL ?= go tool -modfile=tools/go.mod
GOTESTSUM_FORMAT ?= pkgname-and-test-fails
GOTESTSUM_CMD ?= ${GO_TOOL} gotestsum --format ${GOTESTSUM_FORMAT} --no-summary=skipped --jsonfile test-output.json --rerun-fails
LOCAL_TIMEOUT ?= 30m
lintfull: ./tools/golangci-lint
./tools/golangci-lint run --fix
lint: ./tools/golangci-lint
./tools/lintdiff.py ./tools/golangci-lint run --fix
tidy:
@# not part of golangci-lint, apparently
go mod tidy
lintcheck: ./tools/golangci-lint
./tools/golangci-lint run ./...
fmtfull: ./tools/golangci-lint ./tools/yamlfmt
ruff format -n
./tools/golangci-lint fmt
./tools/yamlfmt .
fmt: ./tools/golangci-lint ./tools/yamlfmt
ruff format -n
./tools/lintdiff.py ./tools/golangci-lint fmt
./tools/yamlfmt .
# pre-building yamlfmt because it is invoked from tests and scripts
tools/yamlfmt: tools/go.mod tools/go.sum
go build -modfile=tools/go.mod -o tools/yamlfmt github.com/google/yamlfmt/cmd/yamlfmt
tools/yamlfmt.exe: tools/go.mod tools/go.sum
go build -modfile=tools/go.mod -o tools/yamlfmt.exe github.com/google/yamlfmt/cmd/yamlfmt
# pre-building golangci-lint because it's faster to run pre-built version
tools/golangci-lint: tools/go.mod tools/go.sum
go build -modfile=tools/go.mod -o tools/golangci-lint github.com/golangci/golangci-lint/v2/cmd/golangci-lint
ws:
./tools/validate_whitespace.py
wsfix:
./tools/validate_whitespace.py --fix
links:
./tools/update_github_links.py
# Checks other than 'fmt' and 'lint'; these are fast, so can be run first
checks: tidy ws links
# Run short unit and acceptance tests (testing.Short() is true).
test: test-unit test-acc
# Run all unit and acceptance tests.
test-slow: test-slow-unit test-slow-acc
test-unit:
${GOTESTSUM_CMD} --packages "${TEST_PACKAGES}" -- -timeout=${LOCAL_TIMEOUT} -short
test-slow-unit:
${GOTESTSUM_CMD} --packages "${TEST_PACKAGES}" -- -timeout=${LOCAL_TIMEOUT}
test-acc:
${GOTESTSUM_CMD} --packages ./acceptance/... -- -timeout=${LOCAL_TIMEOUT} -short -run ${ACCEPTANCE_TEST_FILTER}
test-slow-acc:
${GOTESTSUM_CMD} --packages ./acceptance/... -- -timeout=${LOCAL_TIMEOUT} -run ${ACCEPTANCE_TEST_FILTER}
# Updates acceptance test output (local tests)
test-update:
-go test ./acceptance -run '^TestAccept$$' -update -timeout=${LOCAL_TIMEOUT}
@# at the moment second pass is required because some tests show diff against output of another test for easier review
-go test ./acceptance -run '^TestAccept$$' -update -timeout=${LOCAL_TIMEOUT}
# Updates acceptance test output for template tests only
test-update-templates:
-go test ./acceptance -run '^TestAccept/bundle/templates' -update -timeout=${LOCAL_TIMEOUT}
# Regenerate out.test.toml files without running tests
generate-out-test-toml:
go test ./acceptance -run '^TestAccept$$' -only-out-test-toml -timeout=${LOCAL_TIMEOUT}
# Updates acceptance test output (integration tests, requires access)
test-update-aws:
deco env run -i -n aws-prod-ucws -- go test ./acceptance -run ^TestAccept$$ -update -timeout=1h -skiplocal -v
test-update-all: test-update test-update-aws
slowest:
${GO_TOOL} gotestsum tool slowest --jsonfile test-output.json --threshold 1s --num 50
cover:
rm -fr ./acceptance/build/cover/
VERBOSE_TEST=1 ${GOTESTSUM_CMD} --packages "${TEST_PACKAGES}" -- -coverprofile=coverage.txt -timeout=${LOCAL_TIMEOUT}
VERBOSE_TEST=1 CLI_GOCOVERDIR=build/cover ${GOTESTSUM_CMD} --packages ./acceptance/... -- -timeout=${LOCAL_TIMEOUT} -run ${ACCEPTANCE_TEST_FILTER}
rm -fr ./acceptance/build/cover-merged/
mkdir -p acceptance/build/cover-merged/
go tool covdata merge -i $$(printf '%s,' acceptance/build/cover/* | sed 's/,$$//') -o acceptance/build/cover-merged/
go tool covdata textfmt -i acceptance/build/cover-merged -o coverage-acceptance.txt
showcover:
go tool cover -html=coverage.txt
acc-showcover:
go tool cover -html=coverage-acceptance.txt
build: tidy
go build
# builds the binary in a VM environment (such as Parallels Desktop) where your files are mirrored from the host os
build-vm: tidy
go build -buildvcs=false
snapshot:
go build -o .databricks/databricks
# Produce release binaries and archives in the dist folder without uploading them anywhere.
# Useful for "databricks ssh" development, as it needs to upload linux releases to the /Workspace.
snapshot-release:
goreleaser release --clean --skip docker --snapshot
schema:
go run ./bundle/internal/schema ./bundle/internal/schema ./bundle/schema/jsonschema.json
docs:
go run ./bundle/docsgen ./bundle/internal/schema ./bundle/docsgen
INTEGRATION = go run -modfile=tools/go.mod ./tools/testrunner/main.go ${GO_TOOL} gotestsum --format github-actions --rerun-fails --jsonfile output.json --packages "./acceptance ./integration/..." -- -parallel 4 -timeout=2h
integration:
$(INTEGRATION)
integration-short:
VERBOSE_TEST=1 $(INTEGRATION) -short
generate-validation:
go run ./bundle/internal/validation/.
gofmt -w -s ./bundle/internal/validation/generated
# Rule to generate the CLI from a new version of the OpenAPI spec.
# I recommend running this rule from Arca because of faster build times
# because of better caching and beefier machines, but it should also work
# fine from your local mac.
#
# By default, this rule will use the universe directory in your home
# directory. You can override this by setting the UNIVERSE_DIR
# environment variable.
#
# Example:
# UNIVERSE_DIR=/Users/shreyas.goenka/universe make generate
UNIVERSE_DIR ?= $(HOME)/universe
GENKIT_BINARY := $(UNIVERSE_DIR)/bazel-bin/openapi/genkit/genkit_/genkit
generate:
@echo "Checking out universe at SHA: $$(cat .codegen/_openapi_sha)"
cd $(UNIVERSE_DIR) && git fetch origin master && git checkout $$(cat $(PWD)/.codegen/_openapi_sha)
@echo "Building genkit..."
cd $(UNIVERSE_DIR) && bazel build //openapi/genkit
@echo "Generating CLI code..."
$(GENKIT_BINARY) update-sdk
.PHONY: lint lintfull tidy lintcheck fmt fmtfull test test-unit test-acc test-slow test-slow-unit test-slow-acc cover showcover build snapshot snapshot-release schema integration integration-short acc-cover acc-showcover docs ws wsfix links checks test-update test-update-templates generate-out-test-toml test-update-aws test-update-all generate-validation
test-exp-aitools:
make test TEST_PACKAGES="./experimental/aitools/..." ACCEPTANCE_TEST_FILTER="TestAccept/apps"
test-exp-ssh:
make test TEST_PACKAGES="./experimental/ssh/..." ACCEPTANCE_TEST_FILTER="TestAccept/ssh"
test-pipelines:
make test TEST_PACKAGES="./cmd/pipelines/..." ACCEPTANCE_TEST_FILTER="TestAccept/pipelines"
# Benchmarks:
bench1k:
BENCHMARK_PARAMS="--jobs 1000" go test ./acceptance -v -tail -run TestAccept/bundle/benchmarks -timeout=120m
bench100:
BENCHMARK_PARAMS="--jobs 100" go test ./acceptance -v -tail -run TestAccept/bundle/benchmarks -timeout=120m
# small benchmark to quickly test benchmark-related code
bench10:
BENCHMARK_PARAMS="--jobs 10" go test ./acceptance -v -tail -run TestAccept/bundle/benchmarks -timeout=120m
bench1k.log:
make bench1k | tee $@
bench100.log:
make bench100 | tee $@
bench10.log:
make bench10 | tee $@
bench1k_summary: bench1k.log
./tools/bench_parse.py $<
bench100_summary: bench100.log
./tools/bench_parse.py $<
bench10_summary: bench10.log
./tools/bench_parse.py $<