Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix go-generate calling, do more before running tests #1377

Merged
merged 3 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,9 @@ $(THRIFT_GEN): $(THRIFT_FILES) $(BIN)/thriftrw $(BIN)/thriftrw-plugin-yarpc
$Q touch $@

# mockery is quite noisy so it's worth being kinda precise with the files.
# this needs to be both the files defining the generate command, AND the files that define the interfaces.
$(BUILD)/generate: client/client.go encoded/encoded.go internal/internal_workflow_client.go internal/internal_public.go internal/internal_task_pollers.go $(BIN)/mockery
# as long as the //go:generate line is in the file that defines the thing to mock, this will auto-discover it.
# if we build any fancier generators, like the server's wrappers, this might need adjusting / switch to completely manual.
$(BUILD)/generate: $(shell grep --files-with-matches -E '^//go:generate' $(ALL_SRC)) $(BIN)/mockery
$Q $(BIN_PATH) go generate ./...
$Q touch $@

Expand Down Expand Up @@ -303,7 +304,8 @@ errcheck: $(BIN)/errcheck $(BUILD)/fmt ## (re)run errcheck
$(BIN)/errcheck ./...

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

.PHONY: tidy
tidy:
Expand Down Expand Up @@ -372,7 +374,7 @@ UT_DIRS := $(filter-out $(INTEG_TEST_ROOT)%, $(sort $(dir $(filter %_test.go,$(A
.PHONY: unit_test integ_test_sticky_off integ_test_sticky_on integ_test_grpc cover
test: unit_test integ_test_sticky_off integ_test_sticky_on ## run all tests (requires a running cadence instance)

unit_test: $(ALL_SRC) ## run all unit tests
unit_test: $(BUILD)/fmt ## run all unit tests
$Q mkdir -p $(COVER_ROOT)
$Q echo "mode: atomic" > $(UT_COVER_FILE)
$Q FAIL=""; \
Expand All @@ -383,15 +385,15 @@ unit_test: $(ALL_SRC) ## run all unit tests
done; test -z "$$FAIL" || (echo "Failed packages; $$FAIL"; exit 1)
cat $(UT_COVER_FILE) > .build/cover.out;

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

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

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

Expand Down
2 changes: 0 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
// when adding any, make sure you update the files that it checks in the makefile
//go:generate mockery --srcpkg . --name Client --output ../mocks --boilerplate-file ../LICENSE
//go:generate mockery --srcpkg . --name DomainClient --output ../mocks --boilerplate-file ../LICENSE
//go:generate mockery --srcpkg go.uber.org/cadence/internal --name HistoryEventIterator --output ../mocks --boilerplate-file ../LICENSE
//go:generate mockery --srcpkg go.uber.org/cadence/internal --name WorkflowRun --output ../mocks --boilerplate-file ../LICENSE

// Package client contains functions to create Cadence clients used to communicate to Cadence service.
//
Expand Down
2 changes: 0 additions & 2 deletions encoded/encoded.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

//go:generate mockery --srcpkg go.uber.org/cadence/internal --name Value --output ../mocks --boilerplate-file ../LICENSE

// Package encoded contains wrappers that are used for binary payloads deserialization.
package encoded

Expand Down
2 changes: 2 additions & 0 deletions internal/encoded.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"go.uber.org/cadence/internal/common/util"
)

//go:generate mockery --name Value --output ../mocks --boilerplate-file ../LICENSE
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved these so they're in the file with the thing they define (so the dependency setup is trivial), and because it's simpler: no need to specify the internal-package bit.

code generation after this is identical.


type (
// Value is used to encapsulate/extract encoded value from workflow/activity.
Value interface {
Expand Down
3 changes: 3 additions & 0 deletions internal/internal_workflow_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ import (
"go.uber.org/cadence/internal/common/metrics"
)

//go:generate mockery --name HistoryEventIterator --output ../mocks --boilerplate-file ../LICENSE
//go:generate mockery --name WorkflowRun --output ../mocks --boilerplate-file ../LICENSE

// Assert that structs do indeed implement the interfaces
var _ Client = (*workflowClient)(nil)

Expand Down
Loading