Skip to content

Commit

Permalink
Don't require m3 repo to be under $GOPATH for code generation (except…
Browse files Browse the repository at this point in the history
… protobuf) (m3db#4135)

Since m3 is now a go.mod project, it's no longer necessary to be checked out under GOPATH.

This PR makes our code generation reflect that fact. I've switched to use of relative paths in generate.go, which as I understand
it is the preferred way of doing things generally.

Note: I haven't yet fixed the protobuf generation--there are a couple more kinks to work out there. This PR handles thrift and mocks.
  • Loading branch information
andrewmains12 authored Aug 10, 2022
1 parent 5765747 commit 42e0064
Show file tree
Hide file tree
Showing 59 changed files with 172 additions and 174 deletions.
10 changes: 4 additions & 6 deletions scripts/auto-gen-helpers.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/bin/bash

if [ -z "$GOPATH" ]; then
# assume a developer is running locally without a GOPATH
source .ci/variables.sh
else
source "${GOPATH}/src/github.com/m3db/m3/.ci/variables.sh"
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT="${DIR}/.."

source "${ROOT}/.ci/variables.sh"


set -e
Expand Down
4 changes: 2 additions & 2 deletions src/aggregator/aggregator/flush_mgr_mock.go

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

4 changes: 2 additions & 2 deletions src/aggregator/aggregator/flush_mock.go

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

2 changes: 1 addition & 1 deletion src/aggregator/client/keep_alivable_mock_test.go

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

4 changes: 2 additions & 2 deletions src/aggregator/client/queue_mock.go

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

4 changes: 2 additions & 2 deletions src/aggregator/client/writer_mgr_mock.go

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

4 changes: 2 additions & 2 deletions src/aggregator/client/writer_mock.go

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

30 changes: 15 additions & 15 deletions src/aggregator/generated/mocks/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@
// THE SOFTWARE.

// mockgen rules for generating mocks for exported interfaces (reflection mode).
//go:generate sh -c "mockgen -package=aggregator github.com/m3db/m3/src/aggregator/aggregator Aggregator,ElectionManager,FlushTimesManager,PlacementManager | genclean -pkg github.com/m3db/m3/src/aggregator/aggregator -out $GOPATH/src/github.com/m3db/m3/src/aggregator/aggregator/aggregator_mock.go"
//go:generate sh -c "mockgen -package=client github.com/m3db/m3/src/aggregator/client Client,AdminClient | genclean -pkg github.com/m3db/m3/src/aggregator/client -out $GOPATH/src/github.com/m3db/m3/src/aggregator/client/client_mock.go"
//go:generate sh -c "mockgen -package=handler github.com/m3db/m3/src/aggregator/aggregator/handler Handler | genclean -pkg github.com/m3db/m3/src/aggregator/aggregator/handler -out $GOPATH/src/github.com/m3db/m3/src/aggregator/aggregator/handler/handler_mock.go"
//go:generate sh -c "mockgen -package=runtime github.com/m3db/m3/src/aggregator/runtime OptionsWatcher | genclean -pkg github.com/m3db/m3/src/aggregator/runtime -out $GOPATH/src/github.com/m3db/m3/src/aggregator/runtime/runtime_mock.go"
//go:generate sh -c "mockgen -package=client net Conn | genclean -pkg github.com/m3db/m3/src/aggregator/client -out $GOPATH/src/github.com/m3db/m3/src/aggregator/client/conn_mock_test.go"
//go:generate sh -c "mockgen -package=aggregator github.com/m3db/m3/src/aggregator/aggregator Aggregator,ElectionManager,FlushTimesManager,PlacementManager | genclean -pkg github.com/m3db/m3/src/aggregator/aggregator -out ../../aggregator/aggregator_mock.go"
//go:generate sh -c "mockgen -package=client github.com/m3db/m3/src/aggregator/client Client,AdminClient | genclean -pkg github.com/m3db/m3/src/aggregator/client -out ../../client/client_mock.go"
//go:generate sh -c "mockgen -package=handler github.com/m3db/m3/src/aggregator/aggregator/handler Handler | genclean -pkg github.com/m3db/m3/src/aggregator/aggregator/handler -out ../../aggregator/handler/handler_mock.go"
//go:generate sh -c "mockgen -package=runtime github.com/m3db/m3/src/aggregator/runtime OptionsWatcher | genclean -pkg github.com/m3db/m3/src/aggregator/runtime -out ../../runtime/runtime_mock.go"
//go:generate sh -c "mockgen -package=client net Conn | genclean -pkg github.com/m3db/m3/src/aggregator/client -out ../../client/conn_mock_test.go"

// mockgen rules for generating mocks for unexported interfaces (file mode).
//go:generate sh -c "mockgen -package=aggregator -destination=$GOPATH/src/github.com/m3db/m3/src/aggregator/aggregator/flush_mgr_mock.go -source=$GOPATH/src/github.com/m3db/m3/src/aggregator/aggregator/flush_mgr.go"
//go:generate sh -c "mockgen -package=aggregator -destination=$GOPATH/src/github.com/m3db/m3/src/aggregator/aggregator/flush_mock.go -source=$GOPATH/src/github.com/m3db/m3/src/aggregator/aggregator/flush.go"
//go:generate sh -c "mockgen -package=client -destination=$GOPATH/src/github.com/m3db/m3/src/aggregator/client/writer_mgr_mock.go -source=$GOPATH/src/github.com/m3db/m3/src/aggregator/client/writer_mgr.go"
//go:generate sh -c "mockgen -package=client -destination=$GOPATH/src/github.com/m3db/m3/src/aggregator/client/writer_mock.go -source=$GOPATH/src/github.com/m3db/m3/src/aggregator/client/writer.go"
//go:generate sh -c "mockgen -package=client -destination=$GOPATH/src/github.com/m3db/m3/src/aggregator/client/queue_mock.go -source=$GOPATH/src/github.com/m3db/m3/src/aggregator/client/queue.go"
//go:generate sh -c "mockgen -package=deploy -destination=$GOPATH/src/github.com/m3db/m3/src/aggregator/tools/deploy/client_mock.go -source=$GOPATH/src/github.com/m3db/m3/src/aggregator/tools/deploy/client.go"
//go:generate sh -c "mockgen -package=deploy -destination=$GOPATH/src/github.com/m3db/m3/src/aggregator/tools/deploy/manager_mock.go -source=$GOPATH/src/github.com/m3db/m3/src/aggregator/tools/deploy/manager.go"
//go:generate sh -c "mockgen -package=deploy -destination=$GOPATH/src/github.com/m3db/m3/src/aggregator/tools/deploy/planner_mock.go -source=$GOPATH/src/github.com/m3db/m3/src/aggregator/tools/deploy/planner.go"
//go:generate sh -c "mockgen -package=deploy -destination=$GOPATH/src/github.com/m3db/m3/src/aggregator/tools/deploy/validator_mock.go -source=$GOPATH/src/github.com/m3db/m3/src/aggregator/tools/deploy/validator.go"
//go:generate sh -c "mockgen -package=client -destination=$GOPATH/src/github.com/m3db/m3/src/aggregator/client/keep_alivable_mock_test.go -source=$GOPATH/src/github.com/m3db/m3/src/aggregator/client/conn.go client keepAlivableConn"
//go:generate sh -c "mockgen -package=aggregator -destination=../../aggregator/flush_mgr_mock.go -source=../../aggregator/flush_mgr.go"
//go:generate sh -c "mockgen -package=aggregator -destination=../../aggregator/flush_mock.go -source=../../aggregator/flush.go"
//go:generate sh -c "mockgen -package=client -destination=../../client/writer_mgr_mock.go -source=../../client/writer_mgr.go"
//go:generate sh -c "mockgen -package=client -destination=../../client/writer_mock.go -source=../../client/writer.go"
//go:generate sh -c "mockgen -package=client -destination=../../client/queue_mock.go -source=../../client/queue.go"
//go:generate sh -c "mockgen -package=deploy -destination=../../tools/deploy/client_mock.go -source=../../tools/deploy/client.go"
//go:generate sh -c "mockgen -package=deploy -destination=../../tools/deploy/manager_mock.go -source=../../tools/deploy/manager.go"
//go:generate sh -c "mockgen -package=deploy -destination=../../tools/deploy/planner_mock.go -source=../../tools/deploy/planner.go"
//go:generate sh -c "mockgen -package=deploy -destination=../../tools/deploy/validator_mock.go -source=../../tools/deploy/validator.go"
//go:generate sh -c "mockgen -package=client -destination=../../client/keep_alivable_mock_test.go -source=../../client/conn.go client keepAlivableConn"

package mocks
4 changes: 2 additions & 2 deletions src/aggregator/tools/deploy/client_mock.go

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

4 changes: 2 additions & 2 deletions src/aggregator/tools/deploy/manager_mock.go

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

4 changes: 2 additions & 2 deletions src/aggregator/tools/deploy/planner_mock.go

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

4 changes: 2 additions & 2 deletions src/aggregator/tools/deploy/validator_mock.go

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

8 changes: 4 additions & 4 deletions src/cluster/generated/mocks/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
// THE SOFTWARE.

// mockgen rules for generating mocks for exported interfaces (reflection mode).
//go:generate sh -c "mockgen -package=client github.com/m3db/m3/src/cluster/client Client | genclean -pkg github.com/m3db/m3/src/cluster/client -out $GOPATH/src/github.com/m3db/m3/src/cluster/client/client_mock.go"
//go:generate sh -c "mockgen -package=client github.com/m3db/m3/src/cluster/client Client | genclean -pkg github.com/m3db/m3/src/cluster/client -out ../../client/client_mock.go"

// mockgen rules for generating mocks for unexported interfaces (file mode).
//go:generate sh -c "mockgen -package=placement -destination=$GOPATH/src/github.com/m3db/m3/src/cluster/placement/placement_mock.go -source=$GOPATH/src/github.com/m3db/m3/src/cluster/placement/types.go"
//go:generate sh -c "mockgen -package=services -destination=$GOPATH/src/github.com/m3db/m3/src/cluster/services/services_mock.go -source=$GOPATH/src/github.com/m3db/m3/src/cluster/services/types.go"
//go:generate sh -c "mockgen -package=kv -destination=$GOPATH/src/github.com/m3db/m3/src/cluster/kv/kv_mock.go -source=$GOPATH/src/github.com/m3db/m3/src/cluster/kv/types.go"
//go:generate sh -c "mockgen -package=placement -destination=../../placement/placement_mock.go -source=../../placement/types.go"
//go:generate sh -c "mockgen -package=services -destination=../../services/services_mock.go -source=../../services/types.go"
//go:generate sh -c "mockgen -package=kv -destination=../../kv/kv_mock.go -source=../../kv/types.go"

package mocks
4 changes: 2 additions & 2 deletions src/cluster/kv/kv_mock.go

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

4 changes: 2 additions & 2 deletions src/cluster/placement/placement_mock.go

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

4 changes: 2 additions & 2 deletions src/cluster/services/services_mock.go

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

2 changes: 1 addition & 1 deletion src/ctl/generated/mocks/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
// THE SOFTWARE.

// mockgen rules for generating mocks using file mode.
//go:generate sh -c "mockgen -package=store $PACKAGE/src/ctl/service/r2/store Store | genclean -pkg $PACKAGE/src/ctl/service/r2/store -out $GOPATH/src/$PACKAGE/src/ctl/service/r2/store/store_mock.go"
//go:generate sh -c "mockgen -package=store $PACKAGE/src/ctl/service/r2/store Store | genclean -pkg $PACKAGE/src/ctl/service/r2/store -out ../../service/r2/store/store_mock.go"

package mocks
2 changes: 1 addition & 1 deletion src/dbnode/client/client_mock.go

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

2 changes: 1 addition & 1 deletion src/dbnode/encoding/encoding_mock.go

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

Loading

0 comments on commit 42e0064

Please sign in to comment.