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

Separating tools dependencies from main dependencies #4895

Merged
merged 6 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
46 changes: 33 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ $(BUILD)/proto-lint:
$(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, sometimes needs re-formatting
$(BUILD)/codegen: $(BUILD)/thrift $(BUILD)/protoc
$(BUILD)/thrift:
$(BUILD)/protoc:
$(BUILD)/thrift: $(BUILD)/go_mod_check
$(BUILD)/protoc: $(BUILD)/go_mod_check
$(BUILD)/go_mod_check:

# ====================================
# helper vars
Expand Down Expand Up @@ -110,7 +111,19 @@ LINT_SRC := $(filter-out %_test.go ./.gen/%, $(ALL_SRC))
# downloads and builds a go-gettable tool, versioned by go.mod, and installs
# it into the build folder, named the same as the last portion of the URL.
define go_build_tool
@echo "building $(or $(2), $(notdir $(1))) from $(1)..."
@echo "building $(or $(2), $(notdir $(1))) from internal/tools/go.mod..."
@go build -mod=readonly -modfile=internal/tools/go.mod -o $(BIN)/$(or $(2), $(notdir $(1))) $(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

won't this fail your @ rule?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if merged without updating it, yes.
stacked PRs are not a thing github supports though, so I have to either include its changes in this PR, or wait for it to merge first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated!

endef

# same as go_build_tool, but uses our main module file, not the tools one.
# this is necessary / useful for tools that we are already importing in the repo, e.g. yarpc.
# versions here are checked to make sure the tools version matches the service version.
#
# this is an imperfect check as it only checks the top-level version.
# checks of other packages are handled in $(BUILD)/go_mod_check
define go_mod_build_tool
@echo "building $(or $(2), $(notdir $(1))) from go.mod..."
@./scripts/check-gomod-version.sh $(1) $(if $(test_v),-v)
@go build -mod=readonly -o $(BIN)/$(or $(2), $(notdir $(1))) $(1)
endef

Expand All @@ -120,35 +133,42 @@ $(BIN) $(BUILD):
@mkdir -p $@

$(BIN)/thriftrw: go.mod
$(call go_build_tool,go.uber.org/thriftrw)
$(call go_mod_build_tool,go.uber.org/thriftrw)

$(BIN)/thriftrw-plugin-yarpc: go.mod
$(call go_build_tool,go.uber.org/yarpc/encoding/thrift/thriftrw-plugin-yarpc)
$(call go_mod_build_tool,go.uber.org/yarpc/encoding/thrift/thriftrw-plugin-yarpc)

$(BIN)/mockgen: go.mod
$(BIN)/mockgen: internal/tools/go.mod
$(call go_build_tool,github.com/golang/mock/mockgen)

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

$(BIN)/enumer: go.mod
$(BIN)/enumer: internal/tools/go.mod
$(call go_build_tool,github.com/dmarkham/enumer)

$(BIN)/goimports: go.mod
$(BIN)/goimports: internal/tools/go.mod
$(call go_build_tool,golang.org/x/tools/cmd/goimports)

$(BIN)/revive: go.mod
$(BIN)/revive:internal/tools/ go.mod
$(call go_build_tool,github.com/mgechev/revive)

$(BIN)/protoc-gen-gogofast: go.mod | $(BIN)
$(call go_build_tool,github.com/gogo/protobuf/protoc-gen-gogofast)
$(call go_mod_build_tool,github.com/gogo/protobuf/protoc-gen-gogofast)

$(BIN)/protoc-gen-yarpc-go: go.mod | $(BIN)
$(call go_build_tool,go.uber.org/yarpc/encoding/protobuf/protoc-gen-yarpc-go)
$(call go_mod_build_tool,go.uber.org/yarpc/encoding/protobuf/protoc-gen-yarpc-go)

$(BIN)/goveralls: go.mod
$(BIN)/goveralls: internal/tools/go.mod
$(call go_build_tool,github.com/mattn/goveralls)

$(BUILD)/go_mod_check: go.mod internal/tools/go.mod
@# ensure both have the same apache/thrift replacement
@./scripts/check-gomod-version.sh github.com/apache/thrift/lib/go/thrift $(if $(test_v),-v)
@# generated == used is occasionally important for gomock / mock libs in general. this is not a definite problem if violated though.
@./scripts/check-gomod-version.sh github.com/golang/mock/gomock $(if $(test_v),-v)
@touch $@

# copyright header checker/writer. only requires stdlib, so no other dependencies are needed.
$(BIN)/copyright: cmd/tools/copyright/licensegen.go
@go build -o $@ ./cmd/tools/copyright/licensegen.go
Expand Down
3 changes: 2 additions & 1 deletion client/admin/interface_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/clientBean_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion client/frontend/interface_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion client/history/interface_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion client/matching/interface_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions common/domain/dlqMessageHandler_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions common/domain/handler_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions common/domain/replicationTaskHandler_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions common/domain/replication_queue_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions common/dynamicconfig/clientInterface_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions common/persistence/client/bean_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

117 changes: 0 additions & 117 deletions common/thrift_util.go

This file was deleted.

Loading