@@ -180,6 +180,11 @@ $(BIN)/mockery: internal/tools/go.mod
180
180
$(BIN ) /enumer : internal/tools/go.mod
181
181
$(call go_build_tool,github.com/dmarkham/enumer)
182
182
183
+ # organizes imports and reformats
184
+ $(BIN ) /gci : internal/tools/go.mod
185
+ $(call go_build_tool,github.com/daixiang0/gci)
186
+
187
+ # removes unused imports and reformats
183
188
$(BIN ) /goimports : internal/tools/go.mod
184
189
$(call go_build_tool,golang.org/x/tools/cmd/goimports)
185
190
@@ -352,10 +357,13 @@ $(BUILD)/lint: $(LINT_SRC) $(BIN)/revive | $(BUILD)
352
357
# if either changes, this will need to change.
353
358
MAYBE_TOUCH_COPYRIGHT =
354
359
355
- $(BUILD ) /fmt : $(ALL_SRC ) $(BIN ) /goimports | $(BUILD )
356
- $Q echo " goimports..."
357
- $Q # use FRESH_ALL_SRC so it won't miss any generated files produced earlier
358
- $Q $(BIN ) /goimports -local " github.com/uber/cadence" -w $(FRESH_ALL_SRC )
360
+ # use FRESH_ALL_SRC so it won't miss any generated files produced earlier.
361
+ $(BUILD ) /fmt : $(ALL_SRC ) $(BIN ) /goimports $(BIN ) /gci | $(BUILD )
362
+ $Q echo " removing unused imports..."
363
+ $Q # goimports thrashes on internal/tools, sadly. just hide it.
364
+ $Q $(BIN ) /goimports -w $(filter-out ./internal/tools/tools.go,$(FRESH_ALL_SRC ) )
365
+ $Q echo " grouping imports..."
366
+ $Q $(BIN ) /gci write --section standard --section ' Prefix(github.com/uber/cadence/)' --section default --section blank $(FRESH_ALL_SRC )
359
367
$Q touch $@
360
368
$Q $(MAYBE_TOUCH_COPYRIGHT )
361
369
@@ -386,8 +394,8 @@ endef
386
394
lint : # # (re)run the linter
387
395
$(call remake,proto-lint lint)
388
396
389
- # intentionally not re-making, goimports is slow and it's clear when it's unnecessary
390
- fmt : $(BUILD ) /fmt # # run goimports
397
+ # intentionally not re-making, it's a bit slow and it's clear when it's unnecessary
398
+ fmt : $(BUILD ) /fmt # # run gofmt / organize imports / etc
391
399
392
400
# not identical to the intermediate target, but does provide the same codegen (or more).
393
401
copyright : $(BIN ) /copyright | $(BUILD ) # # update copyright headers
@@ -463,6 +471,14 @@ release: ## Re-generate generated code and run tests
463
471
$(MAKE ) --no-print-directory go-generate
464
472
$(MAKE ) --no-print-directory test
465
473
474
+ build : # # Build all packages and all tests (ensures everything compiles)
475
+ $Q echo ' Building all packages...'
476
+ $Q go build ./...
477
+ $Q # "tests" by building and then running `true`, and hides test-success output
478
+ $Q echo ' Building all tests (~5x slower)...'
479
+ $Q # intentionally not -race due to !race build tags
480
+ $Q go test -exec /usr/bin/true ./... > /dev/null
481
+
466
482
clean : # # Clean build products
467
483
rm -f $(BINS )
468
484
rm -Rf $(BUILD )
@@ -472,7 +488,7 @@ clean: ## Clean build products
472
488
473
489
# v----- not yet cleaned up -----v
474
490
475
- .PHONY : git-submodules test bins clean cover cover_ci help
491
+ .PHONY : git-submodules test bins build clean cover cover_ci help
476
492
477
493
TOOLS_CMD_ROOT =./cmd/tools
478
494
INTEG_TEST_ROOT =./host
0 commit comments