-
Notifications
You must be signed in to change notification settings - Fork 303
/
Makefile
184 lines (140 loc) · 5.97 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
.PHONY: all install lint test test-go check-js test-js test-storybook integration wire-check wire ensure goimports vendor shellcheck release-container update-codegen update-codegen-go update-codegen-starlark update-codegen-ts
all: check-js test-js test-storybook
# There are 2 Go bugs that cause problems on CI:
# 1) Linker memory usage blew up in Go 1.11
# 2) Go incorrectly detects the number of CPUs when running in containers,
# and sets the number of parallel jobs to the number of CPUs.
# This makes CI blow up frequently without out-of-memory errors.
# Manually setting the number of parallel jobs helps fix this.
# https://github.com/golang/go/issues/26186#issuecomment-435544512
GO_PARALLEL_JOBS := 4
CIRCLECI := $(if $(CIRCLECI),$(CIRCLECI),false)
GOIMPORTS_LOCAL_ARG := -local github.com/tilt-dev
# Build a binary the current commit SHA
install:
go install -mod vendor -ldflags "-X 'github.com/tilt-dev/tilt/internal/cli.commitSHA=$$(git merge-base master HEAD)'" ./cmd/tilt/...
# disable optimizations and inlining, to allow more complete information when attaching a debugger or capturing a profile
install-debug:
go install -mod vendor -gcflags "all=-N -l" ./...
lint: golangci-lint
lintfix:
LINT_FLAGS=--fix make golangci-lint
build:
go test -mod vendor -p $(GO_PARALLEL_JOBS) -timeout 60s ./... -run nonsenseregex
test-go:
ifneq ($(CIRCLECI),true)
gotestsum -- -mod vendor -p $(GO_PARALLEL_JOBS) -timeout 100s ./...
else
mkdir -p test-results
gotestsum --format standard-quiet --junitfile test-results/unit-tests.xml -- ./... -mod vendor -p $(GO_PARALLEL_JOBS) -timeout 100s
endif
test: test-go test-js
# skip some tests that are slow and not always relevant
# TODO(matt) skiplargetiltfiletests only skips the tiltfile DC+Helm tests at the moment
# we might also want to skip the ones in engine
shorttest:
go test -mod vendor -p $(GO_PARALLEL_JOBS) -short -tags skipcontainertests,skiplargetiltfiletests -timeout 100s ./...
shorttestsum:
ifneq ($(CIRCLECI),true)
gotestsum -- -mod vendor -p $(GO_PARALLEL_JOBS) -short -tags skipcontainertests,skiplargetiltfiletests -timeout 100s ./...
else
mkdir -p test-results
gotestsum --format standard-quiet --junitfile test-results/unit-tests.xml --rerun-fails=2 --rerun-fails-max-failures=10 --packages="./..." -- -mod vendor -count 1 -p $(GO_PARALLEL_JOBS) -short -tags skipcontainertests,skiplargetiltfiletests -timeout 100s
endif
integration:
ifneq ($(CIRCLECI),true)
go test -mod vendor -v -count 1 -p $(GO_PARALLEL_JOBS) -tags 'integration' -timeout 30m ./integration
else
mkdir -p test-results
gotestsum --format dots --junitfile test-results/unit-tests.xml -- ./integration -mod vendor -count 1 -p $(GO_PARALLEL_JOBS) -tags 'integration' -timeout 1000s
endif
# Run the integration tests on kind
integration-kind:
KIND_CLUSTER_NAME=integration ./integration/kind-with-registry.sh
KUBECONFIG="$(kind get kubeconfig-path --name="integration")" go test -mod vendor -p $(GO_PARALLEL_JOBS) -tags 'integration' -timeout 30m ./integration -count 1
kind delete cluster --name=integration
# Run the extension integration tests against the current kubecontext
test-extensions:
scripts/test-extensions.sh
dev-js:
cd web && yarn install && yarn run start
check-js:
cd web && yarn install --immutable
# make sure there are no compilation errors or lint warnings
cd web && CI=true yarn build
cd web && yarn run check
build-js:
cd web && yarn install --immutable
cd web && yarn build
cp -r web/build/* pkg/assets/build
test-js:
cd web && yarn install --immutable
ifneq ($(CIRCLECI),true)
cd web && CI=true yarn test
else
cd web && CI=true yarn ci
endif
test-storybook:
cd web && yarn start-storybook --ci --smoke-test
goimports:
goimports -w -l $(GOIMPORTS_LOCAL_ARG) cmd/ integration/ internal/ pkg/
benchmark:
go test -mod vendor -run=XXX -bench=. ./...
golangci-lint:
ifneq ($(CIRCLECI),true)
GOFLAGS="-mod=vendor" golangci-lint run $(LINT_FLAGS) -v --timeout 300s
else
mkdir -p test-results
GOFLAGS="-mod=vendor" golangci-lint run -v --timeout 300s --out-format junit-xml > test-results/lint.xml
endif
wire:
# run wire in a container, which will then invoke `make wire-dev`
toast wire
wire-dev:
# run wire directly, both used by Toast job and useful for faster iteration
# if you have wire installed (but don't forget to run `make wire` before
# committing to generate the authoritative versions!)
wire ./internal/engine ./internal/engine/buildcontrol ./internal/cli
wire-check:
wire check ./internal/engine ./internal/engine/buildcontrol ./internal/cli
release-container:
scripts/build-tilt-releaser.sh
ci-container:
docker buildx build --push --pull --platform linux/amd64 -t docker/tilt-ci -f .circleci/Dockerfile .circleci
ci-integration-container:
docker buildx build --push --pull --platform linux/amd64 -t docker/tilt-integration-ci -f .circleci/Dockerfile.integration .circleci
clean:
go clean -cache -testcache -r -i ./...
prettier:
cd web && yarn install
cd web && yarn prettier
storybook:
cd web && yarn install
cd web && yarn storybook
tilt-toast-container:
docker build --platform linux/amd64 -t docker/tilt-toast -f Dockerfile.toast .circleci
docker push docker/tilt-toast
ensure: vendor
vendor:
go mod vendor
go mod tidy
cli-docs:
rm -fR ../tilt.build/docs/cli
mkdir ../tilt.build/docs/cli
tilt dump cli-docs --dir=../tilt.build/docs/cli
test_install_version_check: install
NO_INSTALL=1 PATH="~/go/bin:$$PATH" scripts/install.sh
shellcheck:
find ./scripts -type f -name '*.sh' -exec docker run --rm -it -e SHELLCHECK_OPTS="-e SC2001" -v $$(pwd):/mnt nlknguyen/alpine-shellcheck {} \;
update-codegen: update-codegen-go update-codegen-ts update-codegen-starlark
update-codegen-go:
scripts/update-codegen.sh
goimports -w -l $(GOIMPORTS_LOCAL_ARG) pkg
update-codegen-starlark:
go install github.com/tilt-dev/tilt-starlark-codegen@latest
tilt-starlark-codegen ./pkg/apis/core/v1alpha1 ./internal/tiltfile/v1alpha1
goimports -w -l $(GOIMPORTS_LOCAL_ARG) internal/
update-codegen-ts:
toast proto-ts
release-build:
toast -f build.toast.yml