Skip to content

Commit a55fc13

Browse files
authored
Pin mockery and regenerate everything (#1328)
Seems like this has been left un-pinned and un-documented for a long time. Might as well fix that, so we can address the new async APIs in e.g. #1327 in a standardized way.
1 parent d17db37 commit a55fc13

File tree

12 files changed

+474
-48
lines changed

12 files changed

+474
-48
lines changed

Makefile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ $(BUILD)/lint: $(BUILD)/fmt $(BUILD)/dummy # lint will fail if fmt or dummy fail
5454
$(BUILD)/dummy: $(BUILD)/fmt # do a build after fmt-ing
5555
$(BUILD)/fmt: $(BUILD)/copyright # formatting must occur only after all other go-file-modifications are done
5656
$(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
57+
$(BUILD)/codegen: $(BUILD)/thrift $(BUILD)/generate
58+
$(BUILD)/generate: $(BUILD)/thrift # go generate broadly requires compile-able code, which needs thrift
5859
$(BUILD)/thrift: $(BUILD)/go_mod_check
5960
$(BUILD)/go_mod_check: | $(BUILD) $(BIN)
6061

@@ -157,6 +158,9 @@ $(BIN)/errcheck: internal/tools/go.mod
157158
$(BIN)/goveralls: internal/tools/go.mod
158159
$(call go_build_tool,github.com/mattn/goveralls)
159160

161+
$(BIN)/mockery: internal/tools/go.mod
162+
$(call go_build_tool,github.com/vektra/mockery/v2,mockery)
163+
160164
# copyright header checker/writer. only requires stdlib, so no other dependencies are needed.
161165
$(BIN)/copyright: internal/cmd/tools/copyright/licensegen.go
162166
go build -mod=readonly -o $@ ./internal/cmd/tools/copyright/licensegen.go
@@ -185,7 +189,7 @@ $(if $(wildcard THRIFT_FILES),,$(error idls/ submodule must exist, or build will
185189
endef
186190

187191
# 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)
192+
$(BUILD)/codegen: | $(BUILD)
189193
$Q touch $@
190194

191195
THRIFT_FILES := idls/thrift/cadence.thrift idls/thrift/shadower.thrift
@@ -216,6 +220,12 @@ $(THRIFT_GEN): $(THRIFT_FILES) $(BIN)/thriftrw $(BIN)/thriftrw-plugin-yarpc
216220
$(subst $(BUILD),idls/thrift,$@)
217221
$Q touch $@
218222

223+
# mockery is quite noisy so it's worth being kinda precise with the files.
224+
# this needs to be both the files defining the generate command, AND the files that define the interfaces.
225+
$(BUILD)/generate: client/client.go encoded/encoded.go internal/internal_workflow_client.go $(BIN)/mockery
226+
$Q $(BIN_PATH) go generate ./...
227+
$Q touch $@
228+
219229
# ====================================
220230
# other intermediates
221231
# ====================================
@@ -294,6 +304,9 @@ staticcheck: $(BIN)/staticcheck $(BUILD)/fmt ## (re)run staticcheck
294304
errcheck: $(BIN)/errcheck $(BUILD)/fmt ## (re)run errcheck
295305
$(BIN)/errcheck ./...
296306

307+
.PHONY: generate
308+
generate: $(BUILD)/generate ## run go-generate
309+
297310
.PHONY: all
298311
all: $(BUILD)/lint ## refresh codegen, lint, and ensure the dummy binary builds, if necessary
299312

client/client.go

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

21+
// when adding any, make sure you update the files that it checks in the makefile
22+
//go:generate mockery --srcpkg . --name Client --output ../mocks --boilerplate-file ../LICENSE
23+
//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
26+
2127
// Package client contains functions to create Cadence clients used to communicate to Cadence service.
2228
//
2329
// Use these to perform CRUD on domains and start or query workflow executions.

encoded/encoded.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
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+
2123
// Package encoded contains wrappers that are used for binary payloads deserialization.
2224
package encoded
2325

internal/tools/go.mod

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ require (
66
github.com/kisielk/errcheck v1.6.3
77
github.com/mattn/goveralls v0.0.11
88
github.com/mgechev/revive v1.2.5
9+
// last used version, would likely be good to upgrade if possible
10+
github.com/vektra/mockery/v2 v2.16.0
911
go.uber.org/thriftrw v1.25.0
1012
go.uber.org/yarpc v1.55.0
1113
golang.org/x/tools v0.5.0
@@ -16,31 +18,47 @@ require (
1618
github.com/BurntSushi/toml v1.2.1 // indirect
1719
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 // indirect
1820
github.com/chavacava/garif v0.0.0-20221024190013-b3ef35877348 // indirect
21+
github.com/chigopher/pathlib v0.12.0 // indirect
1922
github.com/fatih/color v1.14.1 // indirect
2023
github.com/fatih/structtag v1.2.0 // indirect
24+
github.com/fsnotify/fsnotify v1.5.4 // indirect
2125
github.com/golang/mock v1.5.0 // indirect
26+
github.com/hashicorp/hcl v1.0.0 // indirect
27+
github.com/inconshreveable/mousetrap v1.0.0 // indirect
2228
github.com/jessevdk/go-flags v1.4.0 // indirect
23-
github.com/kr/pretty v0.3.0 // indirect
29+
github.com/magiconair/properties v1.8.6 // indirect
2430
github.com/mattn/go-colorable v0.1.13 // indirect
2531
github.com/mattn/go-isatty v0.0.17 // indirect
2632
github.com/mattn/go-runewidth v0.0.14 // indirect
2733
github.com/mgechev/dots v0.0.0-20210922191527-e955255bf517 // indirect
2834
github.com/mitchellh/go-homedir v1.1.0 // indirect
35+
github.com/mitchellh/mapstructure v1.5.0 // indirect
2936
github.com/olekukonko/tablewriter v0.0.5 // indirect
37+
github.com/pelletier/go-toml v1.9.5 // indirect
38+
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
3039
github.com/pkg/errors v0.9.1 // indirect
3140
github.com/rivo/uniseg v0.4.3 // indirect
41+
github.com/rs/zerolog v1.27.0 // indirect
42+
github.com/spf13/afero v1.8.2 // indirect
43+
github.com/spf13/cast v1.5.0 // indirect
44+
github.com/spf13/cobra v1.4.0 // indirect
45+
github.com/spf13/jwalterweatherman v1.1.0 // indirect
46+
github.com/spf13/pflag v1.0.5 // indirect
47+
github.com/spf13/viper v1.12.0 // indirect
48+
github.com/subosito/gotenv v1.4.0 // indirect
3249
github.com/uber/tchannel-go v1.32.1 // indirect
3350
go.uber.org/atomic v1.9.0 // indirect
3451
go.uber.org/fx v1.13.1 // indirect
3552
go.uber.org/multierr v1.6.0 // indirect
3653
go.uber.org/zap v1.17.0 // indirect
54+
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
3755
golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9 // indirect
38-
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 // indirect
3956
golang.org/x/mod v0.7.0 // indirect
4057
golang.org/x/sys v0.4.0 // indirect
58+
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect
4159
golang.org/x/text v0.6.0 // indirect
42-
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect
43-
google.golang.org/grpc v1.46.2 // indirect
44-
google.golang.org/protobuf v1.28.0 // indirect
60+
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
61+
gopkg.in/ini.v1 v1.66.6 // indirect
4562
gopkg.in/yaml.v2 v2.4.0 // indirect
63+
gopkg.in/yaml.v3 v3.0.1 // indirect
4664
)

0 commit comments

Comments
 (0)