@@ -50,11 +50,11 @@ endif
5050# ====================================
5151
5252# note that vars that do not yet exist are empty, so stick to BUILD/BIN and probably nothing else.
53- $(BUILD ) /lint : $(BUILD ) /fmt $(BUILD ) /dummy # lint will fail if fmt or dummy fails, so run them first
54- $(BUILD ) /dummy : $(BUILD ) /fmt # do a build after fmt-ing
53+ $(BUILD ) /lint : $(BUILD ) /fmt # lint will fail if fmt (more generally, build) fails, so run it first
5554$(BUILD ) /fmt : $(BUILD ) /copyright # formatting must occur only after all other go-file-modifications are done
5655$(BUILD ) /copyright : $(BUILD ) /codegen # must add copyright to generated code
57- $(BUILD ) /codegen : $(BUILD ) /thrift # thrift is currently the only codegen, but this way it's easier to extend
56+ $(BUILD ) /codegen : $(BUILD ) /thrift $(BUILD ) /generate
57+ $(BUILD ) /generate : $(BUILD ) /thrift # go generate broadly requires compile-able code, which needs thrift
5858$(BUILD ) /thrift : $(BUILD ) /go_mod_check
5959$(BUILD ) /go_mod_check : | $(BUILD ) $(BIN )
6060
@@ -157,14 +157,13 @@ $(BIN)/errcheck: internal/tools/go.mod
157157$(BIN ) /goveralls : internal/tools/go.mod
158158 $(call go_build_tool,github.com/mattn/goveralls)
159159
160+ $(BIN ) /mockery : internal/tools/go.mod
161+ $(call go_build_tool,github.com/vektra/mockery/v2,mockery)
162+
160163# copyright header checker/writer. only requires stdlib, so no other dependencies are needed.
161164$(BIN ) /copyright : internal/cmd/tools/copyright/licensegen.go
162165 go build -mod=readonly -o $@ ./internal/cmd/tools/copyright/licensegen.go
163166
164- # dummy binary that ensures most/all packages build, without needing to wait for tests.
165- $(BUILD ) /dummy : $(ALL_SRC ) $(BUILD ) /go_mod_check
166- go build -mod=readonly -o $@ internal/cmd/dummy/dummy.go
167-
168167# ensures mod files are in sync for critical packages
169168$(BUILD ) /go_mod_check : go.mod internal/tools/go.mod
170169 $Q # ensure both have the same apache/thrift replacement
@@ -185,7 +184,7 @@ $(if $(wildcard THRIFT_FILES),,$(error idls/ submodule must exist, or build will
185184endef
186185
187186# codegen is done when thrift is done (it's just a naming-convenience, $(BUILD)/thrift would be fine too)
188- $(BUILD ) /codegen : $( BUILD ) /thrift | $(BUILD )
187+ $(BUILD ) /codegen : | $(BUILD )
189188 $Q touch $@
190189
191190THRIFT_FILES := idls/thrift/cadence.thrift idls/thrift/shadower.thrift
@@ -216,6 +215,12 @@ $(THRIFT_GEN): $(THRIFT_FILES) $(BIN)/thriftrw $(BIN)/thriftrw-plugin-yarpc
216215 $(subst $(BUILD ) ,idls/thrift,$@ )
217216 $Q touch $@
218217
218+ # mockery is quite noisy so it's worth being kinda precise with the files.
219+ # this needs to be both the files defining the generate command, AND the files that define the interfaces.
220+ $(BUILD ) /generate : client/client.go encoded/encoded.go internal/internal_workflow_client.go $(BIN ) /mockery
221+ $Q $(BIN_PATH ) go generate ./...
222+ $Q touch $@
223+
219224# ====================================
220225# other intermediates
221226# ====================================
@@ -268,7 +273,10 @@ $Q +$(MAKE) --no-print-directory $(addprefix $(BUILD)/,$(1))
268273endef
269274
270275.PHONY : build
271- build : $(BUILD ) /dummy # # ensure all packages build
276+ build : $(BUILD ) /fmt # # ensure all packages build
277+ go build ./...
278+ $Q # caution: some errors are reported on stdout for some reason
279+ go test -exec true ./... > /dev/null
272280
273281.PHONY : lint
274282# useful to actually re-run to get output again.
@@ -294,8 +302,16 @@ staticcheck: $(BIN)/staticcheck $(BUILD)/fmt ## (re)run staticcheck
294302errcheck : $(BIN ) /errcheck $(BUILD ) /fmt # # (re)run errcheck
295303 $(BIN ) /errcheck ./...
296304
305+ .PHONY : generate
306+ generate : $(BUILD ) /generate # # run go-generate
307+
308+ .PHONY : tidy
309+ tidy :
310+ go mod tidy
311+ cd internal/tools; go mod tidy
312+
297313.PHONY : all
298- all : $(BUILD ) /lint # # refresh codegen, lint, and ensure the dummy binary builds, if necessary
314+ all : $(BUILD ) /lint # # refresh codegen, lint, and ensure everything builds, whatever is necessary
299315
300316.PHONY : clean
301317clean :
0 commit comments