Skip to content

Commit

Permalink
Pin mockery and regenerate everything (#1328)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Groxx authored Apr 1, 2024
1 parent d17db37 commit a55fc13
Show file tree
Hide file tree
Showing 12 changed files with 474 additions and 48 deletions.
17 changes: 15 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ $(BUILD)/lint: $(BUILD)/fmt $(BUILD)/dummy # lint will fail if fmt or dummy fail
$(BUILD)/dummy: $(BUILD)/fmt # do a build after fmt-ing
$(BUILD)/fmt: $(BUILD)/copyright # formatting must occur only after all other go-file-modifications are done
$(BUILD)/copyright: $(BUILD)/codegen # must add copyright to generated code
$(BUILD)/codegen: $(BUILD)/thrift # thrift is currently the only codegen, but this way it's easier to extend
$(BUILD)/codegen: $(BUILD)/thrift $(BUILD)/generate
$(BUILD)/generate: $(BUILD)/thrift # go generate broadly requires compile-able code, which needs thrift
$(BUILD)/thrift: $(BUILD)/go_mod_check
$(BUILD)/go_mod_check: | $(BUILD) $(BIN)

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

$(BIN)/mockery: internal/tools/go.mod
$(call go_build_tool,github.com/vektra/mockery/v2,mockery)

# copyright header checker/writer. only requires stdlib, so no other dependencies are needed.
$(BIN)/copyright: internal/cmd/tools/copyright/licensegen.go
go build -mod=readonly -o $@ ./internal/cmd/tools/copyright/licensegen.go
Expand Down Expand Up @@ -185,7 +189,7 @@ $(if $(wildcard THRIFT_FILES),,$(error idls/ submodule must exist, or build will
endef

# codegen is done when thrift is done (it's just a naming-convenience, $(BUILD)/thrift would be fine too)
$(BUILD)/codegen: $(BUILD)/thrift | $(BUILD)
$(BUILD)/codegen: | $(BUILD)
$Q touch $@

THRIFT_FILES := idls/thrift/cadence.thrift idls/thrift/shadower.thrift
Expand Down Expand Up @@ -216,6 +220,12 @@ $(THRIFT_GEN): $(THRIFT_FILES) $(BIN)/thriftrw $(BIN)/thriftrw-plugin-yarpc
$(subst $(BUILD),idls/thrift,$@)
$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 $(BIN)/mockery
$Q $(BIN_PATH) go generate ./...
$Q touch $@

# ====================================
# other intermediates
# ====================================
Expand Down Expand Up @@ -294,6 +304,9 @@ staticcheck: $(BIN)/staticcheck $(BUILD)/fmt ## (re)run staticcheck
errcheck: $(BIN)/errcheck $(BUILD)/fmt ## (re)run errcheck
$(BIN)/errcheck ./...

.PHONY: generate
generate: $(BUILD)/generate ## run go-generate

.PHONY: all
all: $(BUILD)/lint ## refresh codegen, lint, and ensure the dummy binary builds, if necessary

Expand Down
6 changes: 6 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

// 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.
//
// Use these to perform CRUD on domains and start or query workflow executions.
Expand Down
2 changes: 2 additions & 0 deletions encoded/encoded.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
// 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
28 changes: 23 additions & 5 deletions internal/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ require (
github.com/kisielk/errcheck v1.6.3
github.com/mattn/goveralls v0.0.11
github.com/mgechev/revive v1.2.5
// last used version, would likely be good to upgrade if possible
github.com/vektra/mockery/v2 v2.16.0
go.uber.org/thriftrw v1.25.0
go.uber.org/yarpc v1.55.0
golang.org/x/tools v0.5.0
Expand All @@ -16,31 +18,47 @@ require (
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 // indirect
github.com/chavacava/garif v0.0.0-20221024190013-b3ef35877348 // indirect
github.com/chigopher/pathlib v0.12.0 // indirect
github.com/fatih/color v1.14.1 // indirect
github.com/fatih/structtag v1.2.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/golang/mock v1.5.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jessevdk/go-flags v1.4.0 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mgechev/dots v0.0.0-20210922191527-e955255bf517 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rivo/uniseg v0.4.3 // indirect
github.com/rs/zerolog v1.27.0 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.4.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.12.0 // indirect
github.com/subosito/gotenv v1.4.0 // indirect
github.com/uber/tchannel-go v1.32.1 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/fx v1.13.1 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.17.0 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9 // indirect
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect
golang.org/x/text v0.6.0 // indirect
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect
google.golang.org/grpc v1.46.2 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/ini.v1 v1.66.6 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit a55fc13

Please sign in to comment.