Skip to content

Commit f2d9bc0

Browse files
committed
Fix go-generate calling, do more before running tests
Does a couple things: - `make generate` now infers files that might affect generation. This should work as long as we keep simple codegen (the server has moved beyond this, sadly). - `make generate` now forces re-generation regardless of need, because it's a nice workaround for dependency issues like happened in #1373 - `make test` and related targets now go-generate and fmt before running tests. Slower, but you can't forget to re-generate, and they're slow already so it's probably fine.
1 parent a71b70f commit f2d9bc0

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

Makefile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ $(THRIFT_GEN): $(THRIFT_FILES) $(BIN)/thriftrw $(BIN)/thriftrw-plugin-yarpc
217217

218218
# mockery is quite noisy so it's worth being kinda precise with the files.
219219
# 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 internal/internal_public.go internal/internal_task_pollers.go $(BIN)/mockery
220+
$(BUILD)/generate: $(shell grep --files-with-matches -E '^//go:generate' $(ALL_SRC)) $(BIN)/mockery
221221
$Q $(BIN_PATH) go generate ./...
222222
$Q touch $@
223223

@@ -303,7 +303,8 @@ errcheck: $(BIN)/errcheck $(BUILD)/fmt ## (re)run errcheck
303303
$(BIN)/errcheck ./...
304304

305305
.PHONY: generate
306-
generate: $(BUILD)/generate ## run go-generate
306+
generate: ## run go-generate (build, lint, fmt all do this for you if needed)
307+
$(call remake,generate)
307308

308309
.PHONY: tidy
309310
tidy:
@@ -372,7 +373,7 @@ UT_DIRS := $(filter-out $(INTEG_TEST_ROOT)%, $(sort $(dir $(filter %_test.go,$(A
372373
.PHONY: unit_test integ_test_sticky_off integ_test_sticky_on integ_test_grpc cover
373374
test: unit_test integ_test_sticky_off integ_test_sticky_on ## run all tests (requires a running cadence instance)
374375

375-
unit_test: $(ALL_SRC) ## run all unit tests
376+
unit_test: $(BUILD)/fmt ## run all unit tests
376377
$Q mkdir -p $(COVER_ROOT)
377378
$Q echo "mode: atomic" > $(UT_COVER_FILE)
378379
$Q FAIL=""; \
@@ -383,15 +384,15 @@ unit_test: $(ALL_SRC) ## run all unit tests
383384
done; test -z "$$FAIL" || (echo "Failed packages; $$FAIL"; exit 1)
384385
cat $(UT_COVER_FILE) > .build/cover.out;
385386

386-
integ_test_sticky_off: $(ALL_SRC)
387+
integ_test_sticky_off: $(BUILD)/fmt
387388
$Q mkdir -p $(COVER_ROOT)
388389
STICKY_OFF=true go test $(TEST_ARG) ./test -coverprofile=$(INTEG_STICKY_OFF_COVER_FILE) -coverpkg=./...
389390

390-
integ_test_sticky_on: $(ALL_SRC)
391+
integ_test_sticky_on: $(BUILD)/fmt
391392
$Q mkdir -p $(COVER_ROOT)
392393
STICKY_OFF=false go test $(TEST_ARG) ./test -coverprofile=$(INTEG_STICKY_ON_COVER_FILE) -coverpkg=./...
393394

394-
integ_test_grpc: $(ALL_SRC)
395+
integ_test_grpc: $(BUILD)/fmt
395396
$Q mkdir -p $(COVER_ROOT)
396397
STICKY_OFF=false go test $(TEST_ARG) ./test -coverprofile=$(INTEG_GRPC_COVER_FILE) -coverpkg=./...
397398

client/client.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
// when adding any, make sure you update the files that it checks in the makefile
2222
//go:generate mockery --srcpkg . --name Client --output ../mocks --boilerplate-file ../LICENSE
2323
//go:generate mockery --srcpkg . --name DomainClient --output ../mocks --boilerplate-file ../LICENSE
24-
//go:generate mockery --srcpkg go.uber.org/cadence/internal --name HistoryEventIterator --output ../mocks --boilerplate-file ../LICENSE
25-
//go:generate mockery --srcpkg go.uber.org/cadence/internal --name WorkflowRun --output ../mocks --boilerplate-file ../LICENSE
2624

2725
// Package client contains functions to create Cadence clients used to communicate to Cadence service.
2826
//

encoded/encoded.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
// THE SOFTWARE.
2020

21-
//go:generate mockery --srcpkg go.uber.org/cadence/internal --name Value --output ../mocks --boilerplate-file ../LICENSE
22-
2321
// Package encoded contains wrappers that are used for binary payloads deserialization.
2422
package encoded
2523

internal/encoded.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import (
2727
"go.uber.org/cadence/internal/common/util"
2828
)
2929

30+
//go:generate mockery --name Value --output ../mocks --boilerplate-file ../LICENSE
31+
3032
type (
3133
// Value is used to encapsulate/extract encoded value from workflow/activity.
3234
Value interface {

internal/internal_workflow_client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ import (
4141
"go.uber.org/cadence/internal/common/metrics"
4242
)
4343

44+
//go:generate mockery --name HistoryEventIterator --output ../mocks --boilerplate-file ../LICENSE
45+
//go:generate mockery --name WorkflowRun --output ../mocks --boilerplate-file ../LICENSE
46+
4447
// Assert that structs do indeed implement the interfaces
4548
var _ Client = (*workflowClient)(nil)
4649

0 commit comments

Comments
 (0)