diff options
author | Yuxuan 'fishy' Wang <yuxuan.wang@reddit.com> | 2022-10-28 10:29:25 -0700 |
---|---|---|
committer | Yuxuan 'fishy' Wang <fishywang@gmail.com> | 2022-11-02 15:44:07 -0700 |
commit | e8353cb46e9f5e71f9b76f55d6bf59530b7f98ef (patch) | |
tree | 0a115e7b4edaf865c497a01196f9fc60acd8d734 | |
parent | 2acfe0fc7a1747c327da66c8a693840ba0c5a016 (diff) | |
download | thrift-e8353cb46e9f5e71f9b76f55d6bf59530b7f98ef.tar.gz |
Use multi-module to cleanup top level go.mod
Client: go
The go library itself does not have any third-party dependencies. We
have one third party dependency from the test code, which kind of
polluted from top-level go.mod file to the users of thrift go library.
We previous tried to clean that up by creating go.mod file at
lib/go/thrift, which caused issues to the release process and thus
reverted.
Use multi-module to separate tests requiring mock to their own modules
so that we can keep the top-level go.mod file clean.
Also some minor fixes on the github actions go workflow.
-rw-r--r-- | .github/workflows/build.yml | 4 | ||||
-rw-r--r-- | go.mod | 9 | ||||
-rw-r--r-- | lib/go/Makefile.am | 6 | ||||
-rw-r--r-- | lib/go/test/Makefile.am | 14 | ||||
-rw-r--r-- | lib/go/test/fuzz/Makefile.am | 2 | ||||
-rw-r--r-- | lib/go/test/go.mod | 10 | ||||
-rw-r--r-- | lib/go/test/go.sum | 25 | ||||
-rw-r--r-- | lib/go/test/tests/thrifttest_handler.go | 4 | ||||
-rw-r--r-- | test/go/Makefile.am | 16 | ||||
-rw-r--r-- | test/go/genmock.sh | 4 | ||||
-rw-r--r-- | test/go/go.mod | 17 | ||||
-rw-r--r-- | test/go/go.sum (renamed from go.sum) | 0 | ||||
-rw-r--r-- | tutorial/go/Makefile.am | 16 |
13 files changed, 79 insertions, 48 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b3ecd1eca..252ff2b55 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -78,7 +78,6 @@ jobs: run: | ./configure \ --disable-debug \ - --disable-tests \ --disable-dependency-tracking \ --without-cpp \ --without-c_glib \ @@ -118,9 +117,6 @@ jobs: - name: Run make check for lib/go run: make -C lib/go check - - name: Run make check for lib/go/test - run: make -C lib/go/test check - - name: Run make check for test/go run: make -C test/go check @@ -1,12 +1,3 @@ module github.com/apache/thrift go 1.18 - -require github.com/golang/mock v1.6.0 - -require ( - golang.org/x/mod v0.4.2 // indirect - golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect - golang.org/x/tools v0.1.1 // indirect - golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect -) diff --git a/lib/go/Makefile.am b/lib/go/Makefile.am index 06399f5f4..18b6b75f4 100644 --- a/lib/go/Makefile.am +++ b/lib/go/Makefile.am @@ -39,14 +39,14 @@ install: # NOTE: We have to disable stdmethods in go vet until # https://github.com/golang/go/issues/52445 is fixed. check-local: - $(GO) vet -mod=mod -stdmethods=false github.com/apache/thrift/lib/go/thrift - $(GO) test -mod=mod -race ./thrift + $(GO) vet -stdmethods=false github.com/apache/thrift/lib/go/thrift + $(GO) test -race ./thrift clean-local: $(RM) -rf pkg all-local: - $(GO) build $(GOBUILDEXTRA) -mod=mod ./thrift + $(GO) build $(GOBUILDEXTRA) ./thrift EXTRA_DIST = \ thrift \ diff --git a/lib/go/test/Makefile.am b/lib/go/test/Makefile.am index b9c00d969..663b42e89 100644 --- a/lib/go/test/Makefile.am +++ b/lib/go/test/Makefile.am @@ -17,16 +17,12 @@ # under the License. # -if GOVERSION_GE_118 GOBUILDEXTRA = -buildvcs=false -else -GOBUILDEXTRA = -endif THRIFT_GO_ARGS_BASE = thrift_import=github.com/apache/thrift/lib/go/thrift,package_prefix=github.com/apache/thrift/lib/go/test/gopath/src/ THRIFTARGS = -out gopath/src/ --gen go:$(THRIFT_GO_ARGS_BASE)$(COMPILER_EXTRAFLAG) -THRIFTTEST = $(top_srcdir)/test/v0.16/ThriftTest.thrift +THRIFTTEST = $(top_srcdir)/test/ThriftTest.thrift THRIFTARGS_SKIP_REMOTE = -out gopath/src/ --gen go:skip_remote,$(THRIFT_GO_ARGS_BASE)$(COMPILER_EXTRAFLAG) @@ -105,7 +101,7 @@ gopath: $(THRIFT) $(THRIFTTEST) \ touch gopath check: gopath - $(GO) build $(GOBUILDEXTRA) -mod=mod \ + $(GO) build $(GOBUILDEXTRA) \ ./gopath/src/includestest \ ./gopath/src/binarykeytest \ ./gopath/src/servicestest \ @@ -126,14 +122,14 @@ check: gopath ./gopath/src/processormiddlewaretest \ ./gopath/src/clientmiddlewareexceptiontest \ ./gopath/src/validatetest - $(GO) test -mod=mod github.com/apache/thrift/lib/go/thrift - $(GO) test -mod=mod ./gopath/src/tests ./gopath/src/dontexportrwtest + $(GO) test github.com/apache/thrift/lib/go/thrift + $(GO) test ./gopath/src/tests ./gopath/src/dontexportrwtest clean-local: $(RM) -r gopath ThriftTest.thrift gen-go client: stubs - $(GO) run -mod=mod TestClient.go + $(GO) run TestClient.go EXTRA_DIST = \ dontexportrwtest \ diff --git a/lib/go/test/fuzz/Makefile.am b/lib/go/test/fuzz/Makefile.am index a8a810255..56f138a7e 100644 --- a/lib/go/test/fuzz/Makefile.am +++ b/lib/go/test/fuzz/Makefile.am @@ -24,7 +24,7 @@ gopathfuzz: $(THRIFT) fuzz.go touch gopathfuzz check: gopathfuzz - go test -mod=mod -tags gofuzz + go test -tags gofuzz clean-local: $(RM) -r gopathfuzz gen-go diff --git a/lib/go/test/go.mod b/lib/go/test/go.mod new file mode 100644 index 000000000..37814e060 --- /dev/null +++ b/lib/go/test/go.mod @@ -0,0 +1,10 @@ +module github.com/apache/thrift/lib/go/test + +go 1.18 + +require ( + github.com/apache/thrift v0.0.0-00010101000000-000000000000 + github.com/golang/mock v1.6.0 +) + +replace github.com/apache/thrift => ../../../ diff --git a/lib/go/test/go.sum b/lib/go/test/go.sum new file mode 100644 index 000000000..d0671277e --- /dev/null +++ b/lib/go/test/go.sum @@ -0,0 +1,25 @@ +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/lib/go/test/tests/thrifttest_handler.go b/lib/go/test/tests/thrifttest_handler.go index 419a18b44..f46f5495d 100644 --- a/lib/go/test/tests/thrifttest_handler.go +++ b/lib/go/test/tests/thrifttest_handler.go @@ -82,6 +82,10 @@ func (p *ThriftTestHandler) TestBinary(ctx context.Context, thing []byte) (r []b return thing, nil } +func (p *ThriftTestHandler) TestUuid(ctx context.Context, thing thrift.Tuuid) (r thrift.Tuuid, err error) { + return thing, nil +} + func (p *ThriftTestHandler) TestStruct(ctx context.Context, thing *thrifttest.Xtruct) (r *thrifttest.Xtruct, err error) { return thing, nil } diff --git a/test/go/Makefile.am b/test/go/Makefile.am index abed92319..ff7ce683e 100644 --- a/test/go/Makefile.am +++ b/test/go/Makefile.am @@ -19,11 +19,7 @@ BUILT_SOURCES = gopath -if GOVERSION_GE_118 -GOINSTALLEXTRA = -buildvcs=false -else -GOINSTALLEXTRA = -endif +GOBUILDEXTRA = -buildvcs=false THRIFTCMD = $(THRIFT) -out src/gen --gen go:thrift_import=github.com/apache/thrift/lib/go/thrift,package_prefix=github.com/apache/thrift/test/go/src/gen/$(COMPILER_EXTRAFLAG) THRIFTTEST = $(top_srcdir)/test/ThriftTest.thrift @@ -44,13 +40,13 @@ gopath: $(THRIFT) ThriftTest.thrift touch gopath bin/testclient: gopath - GOPATH=`pwd` $(GO) install $(GOINSTALLEXTRA) -mod=mod ./src/bin/testclient + $(GO) build $(GOBUILDEXTRA) -o bin/testclient ./src/bin/testclient bin/testserver: gopath - GOPATH=`pwd` $(GO) install $(GOINSTALLEXTRA) -mod=mod ./src/bin/testserver + $(GO) build $(GOBUILDEXTRA) -o bin/testserver ./src/bin/testserver bin/stress: gopath - GOPATH=`pwd` $(GO) install $(GOINSTALLEXTRA) -mod=mod ./src/bin/stress + $(GO) build $(GOBUILDEXTRA) -o bin/stress ./src/bin/stress clean-local: $(RM) -r src/gen src/github.com/golang src/thrift bin pkg gopath ThriftTest.thrift @@ -58,8 +54,8 @@ clean-local: check_PROGRAMS: bin/testclient bin/testserver bin/stress check: gopath genmock - $(GO) test -mod=mod -v ./src/common/... - $(GO) test -mod=mod -v ./src/gen/... + $(GO) test -v ./src/common/... + $(GO) test -v ./src/gen/... genmock: gopath sh genmock.sh diff --git a/test/go/genmock.sh b/test/go/genmock.sh index 9bd2a3ca7..687ce6142 100644 --- a/test/go/genmock.sh +++ b/test/go/genmock.sh @@ -4,8 +4,8 @@ set -e export GOPATH=$(mktemp -d -t gopath-XXXXXXXXXX) -go install -mod=mod github.com/golang/mock/mockgen +go install github.com/golang/mock/mockgen -`go env GOPATH`/bin/mockgen -build_flags "-mod=mod" -destination=src/common/mock_handler.go -package=common github.com/apache/thrift/test/go/src/gen/thrifttest ThriftTest +`go env GOPATH`/bin/mockgen -destination=src/common/mock_handler.go -package=common github.com/apache/thrift/test/go/src/gen/thrifttest ThriftTest chmod a+w -R $GOPATH && rm -Rf $GOPATH diff --git a/test/go/go.mod b/test/go/go.mod new file mode 100644 index 000000000..841c3291d --- /dev/null +++ b/test/go/go.mod @@ -0,0 +1,17 @@ +module github.com/apache/thrift/test/go + +go 1.18 + +require ( + github.com/apache/thrift v0.0.0-00010101000000-000000000000 + github.com/golang/mock v1.6.0 +) + +require ( + golang.org/x/mod v0.4.2 // indirect + golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect + golang.org/x/tools v0.1.1 // indirect + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect +) + +replace github.com/apache/thrift => ../../ diff --git a/go.sum b/test/go/go.sum index 6904b3efe..6904b3efe 100644 --- a/go.sum +++ b/test/go/go.sum diff --git a/tutorial/go/Makefile.am b/tutorial/go/Makefile.am index e323358fd..b2f70ce12 100644 --- a/tutorial/go/Makefile.am +++ b/tutorial/go/Makefile.am @@ -17,11 +17,7 @@ # under the License. # -if GOVERSION_GE_118 GOBUILDEXTRA = -buildvcs=false -else -GOBUILDEXTRA = -endif gen-go/tutorial/calculator.go gen-go/shared/shared_service.go: $(top_srcdir)/tutorial/tutorial.thrift $(THRIFT) --gen go:thrift_import=github.com/apache/thrift/lib/go/thrift,package_prefix=github.com/apache/thrift/tutorial/go/gen-go/$(COMPILER_EXTRAFLAG) -r $< @@ -29,22 +25,22 @@ gen-go/tutorial/calculator.go gen-go/shared/shared_service.go: $(top_srcdir)/tut all-local: gen-go/tutorial/calculator.go check: thirdparty-dep all - $(GO) build $(GOBUILDEXTRA) -mod=mod -o go-tutorial ./src - $(GO) build $(GOBUILDEXTRA) -mod=mod -o calculator-remote ./gen-go/tutorial/calculator-remote/calculator-remote.go + $(GO) build $(GOBUILDEXTRA) -o go-tutorial ./src + $(GO) build $(GOBUILDEXTRA) -o calculator-remote ./gen-go/tutorial/calculator-remote/calculator-remote.go thirdparty-dep: tutorialserver: all - $(GO) run -mod=mod src/*.go -server=true + $(GO) run src/*.go -server=true tutorialclient: all - $(GO) run -mod=mod src/*.go + $(GO) run src/*.go tutorialsecureserver: all - $(GO) run -mod=mod src/*.go -server=true -secure=true + $(GO) run src/*.go -server=true -secure=true tutorialsecureclient: all - $(GO) run -mod=mod src/*.go -secure=true + $(GO) run src/*.go -secure=true clean-local: $(RM) -r gen-* go-tutorial calculator-remote |