diff --git a/go.mod b/go.mod index b08656bef566eec37520e41a196a2d30dc1463f1..cfae7b55e0c25c8743ccba0dd50441eb7e5ef88b 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,8 @@ require ( github.com/Masterminds/semver v1.5.0 github.com/golang/protobuf v1.4.1 github.com/google/go-github/v30 v30.1.0 + github.com/hashicorp/go-hclog v0.9.2 + github.com/hashicorp/go-plugin v1.3.0 github.com/shuheiktgw/go-travis v0.2.4 github.com/stretchr/testify v1.5.1 github.com/urfave/cli/v2 v2.2.0 diff --git a/go.sum b/go.sum index 7667e1620ae65c3c0abd41dad6ba868d321592b0..1c8ad235ed20fd5260c51cb30fd199b4e9aadc38 100644 --- a/go.sum +++ b/go.sum @@ -12,14 +12,17 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= @@ -39,10 +42,21 @@ github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASu github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI= github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= +github.com/hashicorp/go-plugin v1.3.0 h1:4d/wJojzvHV1I4i/rrjVaeuyxWrLzDE1mDCyDy8fXS8= +github.com/hashicorp/go-plugin v1.3.0/go.mod h1:F9eH4LrE/ZsRdbwhfjs9k9HoDUwAHnYtXdgmf1AVNs0= github.com/hashicorp/go-retryablehttp v0.6.4 h1:BbgctKO892xEyOXnGiaAwIoSq1QZ/SS4AhjoAh9DnfY= github.com/hashicorp/go-retryablehttp v0.6.4/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= +github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS4/qyk21ZsHyb6Mxv/jykxvNTkU4M= +github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= +github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= +github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= +github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 h1:7GoSOOW2jpsfkntVKaS2rAr1TJqfcxotyaUcuxoZSzg= +github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= +github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -55,6 +69,7 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= @@ -69,6 +84,7 @@ golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181108082009-03003ca0c849/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -101,12 +117,15 @@ google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9Ywl google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.31.0 h1:T7P4R73V3SSDPhH7WW7ATbfViLtmamH0DKrP3f9AuDI= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= diff --git a/pkg/analyzer/commit/commit_analyzer.pb.go b/pkg/analyzer/commit/commit_analyzer.pb.go new file mode 100644 index 0000000000000000000000000000000000000000..37cecc1716db9059eb8aa5c29820e417e390108d --- /dev/null +++ b/pkg/analyzer/commit/commit_analyzer.pb.go @@ -0,0 +1,231 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.12.3 +// source: pkg/analyzer/commit/commit_analyzer.proto + +package commit + +import ( + semrel "github.com/go-semantic-release/semantic-release/pkg/semrel" + proto "github.com/golang/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +type CommitAnalyzerRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RawCommits []*semrel.RawCommit `protobuf:"bytes,1,rep,name=RawCommits,proto3" json:"RawCommits,omitempty"` +} + +func (x *CommitAnalyzerRequest) Reset() { + *x = CommitAnalyzerRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_analyzer_commit_commit_analyzer_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CommitAnalyzerRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CommitAnalyzerRequest) ProtoMessage() {} + +func (x *CommitAnalyzerRequest) ProtoReflect() protoreflect.Message { + mi := &file_pkg_analyzer_commit_commit_analyzer_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CommitAnalyzerRequest.ProtoReflect.Descriptor instead. +func (*CommitAnalyzerRequest) Descriptor() ([]byte, []int) { + return file_pkg_analyzer_commit_commit_analyzer_proto_rawDescGZIP(), []int{0} +} + +func (x *CommitAnalyzerRequest) GetRawCommits() []*semrel.RawCommit { + if x != nil { + return x.RawCommits + } + return nil +} + +type CommitAnalyzerResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Commits []*semrel.Commit `protobuf:"bytes,1,rep,name=Commits,proto3" json:"Commits,omitempty"` +} + +func (x *CommitAnalyzerResponse) Reset() { + *x = CommitAnalyzerResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_analyzer_commit_commit_analyzer_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CommitAnalyzerResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CommitAnalyzerResponse) ProtoMessage() {} + +func (x *CommitAnalyzerResponse) ProtoReflect() protoreflect.Message { + mi := &file_pkg_analyzer_commit_commit_analyzer_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CommitAnalyzerResponse.ProtoReflect.Descriptor instead. +func (*CommitAnalyzerResponse) Descriptor() ([]byte, []int) { + return file_pkg_analyzer_commit_commit_analyzer_proto_rawDescGZIP(), []int{1} +} + +func (x *CommitAnalyzerResponse) GetCommits() []*semrel.Commit { + if x != nil { + return x.Commits + } + return nil +} + +var File_pkg_analyzer_commit_commit_analyzer_proto protoreflect.FileDescriptor + +var file_pkg_analyzer_commit_commit_analyzer_proto_rawDesc = []byte{ + 0x0a, 0x29, 0x70, 0x6b, 0x67, 0x2f, 0x61, 0x6e, 0x61, 0x6c, 0x79, 0x7a, 0x65, 0x72, 0x2f, 0x63, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x61, 0x6e, 0x61, + 0x6c, 0x79, 0x7a, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, 0x70, 0x6b, 0x67, + 0x2f, 0x73, 0x65, 0x6d, 0x72, 0x65, 0x6c, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x73, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x43, 0x0a, 0x15, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x41, + 0x6e, 0x61, 0x6c, 0x79, 0x7a, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, + 0x0a, 0x0a, 0x52, 0x61, 0x77, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x52, 0x61, 0x77, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x52, 0x0a, + 0x52, 0x61, 0x77, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x22, 0x3b, 0x0a, 0x16, 0x43, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x41, 0x6e, 0x61, 0x6c, 0x79, 0x7a, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x52, 0x07, + 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x32, 0x52, 0x0a, 0x14, 0x43, 0x6f, 0x6d, 0x6d, 0x69, + 0x74, 0x41, 0x6e, 0x61, 0x6c, 0x79, 0x7a, 0x65, 0x72, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, + 0x3a, 0x0a, 0x07, 0x41, 0x6e, 0x61, 0x6c, 0x79, 0x7a, 0x65, 0x12, 0x16, 0x2e, 0x43, 0x6f, 0x6d, + 0x6d, 0x69, 0x74, 0x41, 0x6e, 0x61, 0x6c, 0x79, 0x7a, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x41, 0x6e, 0x61, 0x6c, 0x79, + 0x7a, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x45, 0x5a, 0x43, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x2d, 0x73, 0x65, 0x6d, + 0x61, 0x6e, 0x74, 0x69, 0x63, 0x2d, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2f, 0x73, 0x65, + 0x6d, 0x61, 0x6e, 0x74, 0x69, 0x63, 0x2d, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2f, 0x70, + 0x6b, 0x67, 0x2f, 0x61, 0x6e, 0x61, 0x6c, 0x79, 0x7a, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_pkg_analyzer_commit_commit_analyzer_proto_rawDescOnce sync.Once + file_pkg_analyzer_commit_commit_analyzer_proto_rawDescData = file_pkg_analyzer_commit_commit_analyzer_proto_rawDesc +) + +func file_pkg_analyzer_commit_commit_analyzer_proto_rawDescGZIP() []byte { + file_pkg_analyzer_commit_commit_analyzer_proto_rawDescOnce.Do(func() { + file_pkg_analyzer_commit_commit_analyzer_proto_rawDescData = protoimpl.X.CompressGZIP(file_pkg_analyzer_commit_commit_analyzer_proto_rawDescData) + }) + return file_pkg_analyzer_commit_commit_analyzer_proto_rawDescData +} + +var file_pkg_analyzer_commit_commit_analyzer_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_pkg_analyzer_commit_commit_analyzer_proto_goTypes = []interface{}{ + (*CommitAnalyzerRequest)(nil), // 0: CommitAnalyzerRequest + (*CommitAnalyzerResponse)(nil), // 1: CommitAnalyzerResponse + (*semrel.RawCommit)(nil), // 2: RawCommit + (*semrel.Commit)(nil), // 3: Commit +} +var file_pkg_analyzer_commit_commit_analyzer_proto_depIdxs = []int32{ + 2, // 0: CommitAnalyzerRequest.RawCommits:type_name -> RawCommit + 3, // 1: CommitAnalyzerResponse.Commits:type_name -> Commit + 0, // 2: CommitAnalyzerPlugin.Analyze:input_type -> CommitAnalyzerRequest + 1, // 3: CommitAnalyzerPlugin.Analyze:output_type -> CommitAnalyzerResponse + 3, // [3:4] is the sub-list for method output_type + 2, // [2:3] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_pkg_analyzer_commit_commit_analyzer_proto_init() } +func file_pkg_analyzer_commit_commit_analyzer_proto_init() { + if File_pkg_analyzer_commit_commit_analyzer_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_pkg_analyzer_commit_commit_analyzer_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CommitAnalyzerRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_analyzer_commit_commit_analyzer_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CommitAnalyzerResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_pkg_analyzer_commit_commit_analyzer_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_pkg_analyzer_commit_commit_analyzer_proto_goTypes, + DependencyIndexes: file_pkg_analyzer_commit_commit_analyzer_proto_depIdxs, + MessageInfos: file_pkg_analyzer_commit_commit_analyzer_proto_msgTypes, + }.Build() + File_pkg_analyzer_commit_commit_analyzer_proto = out.File + file_pkg_analyzer_commit_commit_analyzer_proto_rawDesc = nil + file_pkg_analyzer_commit_commit_analyzer_proto_goTypes = nil + file_pkg_analyzer_commit_commit_analyzer_proto_depIdxs = nil +} diff --git a/pkg/analyzer/commit/commit_analyzer.proto b/pkg/analyzer/commit/commit_analyzer.proto new file mode 100644 index 0000000000000000000000000000000000000000..6d444b9e0c3843ec052d1c86a310216cbb68f055 --- /dev/null +++ b/pkg/analyzer/commit/commit_analyzer.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +option go_package = "github.com/go-semantic-release/semantic-release/pkg/analyzer/commit"; + +import "pkg/semrel/structs.proto"; + +message CommitAnalyzerRequest { + repeated RawCommit RawCommits = 1; +} + +message CommitAnalyzerResponse { + repeated Commit Commits = 1; +} + +service CommitAnalyzerPlugin { + rpc Analyze(CommitAnalyzerRequest) returns (CommitAnalyzerResponse); +} diff --git a/pkg/analyzer/commit/commit_analyzer_grpc.pb.go b/pkg/analyzer/commit/commit_analyzer_grpc.pb.go new file mode 100644 index 0000000000000000000000000000000000000000..4118fbded61e83ab18ff384588c9d9cf5b6fb88e --- /dev/null +++ b/pkg/analyzer/commit/commit_analyzer_grpc.pb.go @@ -0,0 +1,90 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package commit + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion6 + +// CommitAnalyzerPluginClient is the client API for CommitAnalyzerPlugin service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type CommitAnalyzerPluginClient interface { + Analyze(ctx context.Context, in *CommitAnalyzerRequest, opts ...grpc.CallOption) (*CommitAnalyzerResponse, error) +} + +type commitAnalyzerPluginClient struct { + cc grpc.ClientConnInterface +} + +func NewCommitAnalyzerPluginClient(cc grpc.ClientConnInterface) CommitAnalyzerPluginClient { + return &commitAnalyzerPluginClient{cc} +} + +func (c *commitAnalyzerPluginClient) Analyze(ctx context.Context, in *CommitAnalyzerRequest, opts ...grpc.CallOption) (*CommitAnalyzerResponse, error) { + out := new(CommitAnalyzerResponse) + err := c.cc.Invoke(ctx, "/CommitAnalyzerPlugin/Analyze", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// CommitAnalyzerPluginServer is the server API for CommitAnalyzerPlugin service. +// All implementations must embed UnimplementedCommitAnalyzerPluginServer +// for forward compatibility +type CommitAnalyzerPluginServer interface { + Analyze(context.Context, *CommitAnalyzerRequest) (*CommitAnalyzerResponse, error) + mustEmbedUnimplementedCommitAnalyzerPluginServer() +} + +// UnimplementedCommitAnalyzerPluginServer must be embedded to have forward compatible implementations. +type UnimplementedCommitAnalyzerPluginServer struct { +} + +func (*UnimplementedCommitAnalyzerPluginServer) Analyze(context.Context, *CommitAnalyzerRequest) (*CommitAnalyzerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Analyze not implemented") +} +func (*UnimplementedCommitAnalyzerPluginServer) mustEmbedUnimplementedCommitAnalyzerPluginServer() {} + +func RegisterCommitAnalyzerPluginServer(s *grpc.Server, srv CommitAnalyzerPluginServer) { + s.RegisterService(&_CommitAnalyzerPlugin_serviceDesc, srv) +} + +func _CommitAnalyzerPlugin_Analyze_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CommitAnalyzerRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CommitAnalyzerPluginServer).Analyze(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/CommitAnalyzerPlugin/Analyze", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CommitAnalyzerPluginServer).Analyze(ctx, req.(*CommitAnalyzerRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _CommitAnalyzerPlugin_serviceDesc = grpc.ServiceDesc{ + ServiceName: "CommitAnalyzerPlugin", + HandlerType: (*CommitAnalyzerPluginServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Analyze", + Handler: _CommitAnalyzerPlugin_Analyze_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "pkg/analyzer/commit/commit_analyzer.proto", +} diff --git a/pkg/analyzer/commit/plugin/plugin.go b/pkg/analyzer/commit/plugin/plugin.go new file mode 100644 index 0000000000000000000000000000000000000000..7075044b6bf7ea4d598d8e24435610a06befe91e --- /dev/null +++ b/pkg/analyzer/commit/plugin/plugin.go @@ -0,0 +1,16 @@ +package plugin + +import ( + "github.com/go-semantic-release/semantic-release/pkg/analyzer/commit" + "github.com/go-semantic-release/semantic-release/pkg/plugin" + "github.com/urfave/cli/v2" +) + +func DefaultMain(c *cli.Context) error { + plugin.Serve(&plugin.ServeOpts{ + CommitAnalyzer: func() commit.Analyzer { + return &commit.DefaultAnalyzer{} + }, + }) + return nil +} diff --git a/pkg/plugin/client.go b/pkg/plugin/client.go new file mode 100644 index 0000000000000000000000000000000000000000..f0a9bcebbe3a082c93700e22342c6a8ef67ac881 --- /dev/null +++ b/pkg/plugin/client.go @@ -0,0 +1,64 @@ +package plugin + +import ( + "os/exec" + "sync" + + "github.com/go-semantic-release/semantic-release/pkg/analyzer/commit" + "github.com/go-semantic-release/semantic-release/pkg/plugin/wrapper" + "github.com/hashicorp/go-hclog" + "github.com/hashicorp/go-plugin" +) + +type PluginOpts struct { + Type string + Cmd *exec.Cmd +} + +var runningClientsMx sync.Mutex +var runningClients = make([]*plugin.Client, 0) + +func KillAllPlugins() { + for _, c := range runningClients { + c.Kill() + } +} + +func startPlugin(opts *PluginOpts) (interface{}, error) { + runningClientsMx.Lock() + defer runningClientsMx.Unlock() + client := plugin.NewClient(&plugin.ClientConfig{ + HandshakeConfig: Handshake, + VersionedPlugins: map[int]plugin.PluginSet{ + 1: { + opts.Type: &wrapper.GRPC{ + Type: opts.Type, + }, + }, + }, + Cmd: opts.Cmd, + AllowedProtocols: []plugin.Protocol{plugin.ProtocolGRPC}, + Logger: hclog.NewNullLogger(), + }) + + rpcClient, err := client.Client() + if err != nil { + client.Kill() + panic(err) + } + raw, err := rpcClient.Dispense(opts.Type) + if err != nil { + client.Kill() + return nil, err + } + runningClients = append(runningClients, client) + return raw, nil +} + +func StartCommitAnalyzerPlugin(opts *PluginOpts) (commit.Analyzer, error) { + raw, err := startPlugin(opts) + if err != nil { + return nil, err + } + return raw.(commit.Analyzer), nil +} diff --git a/pkg/plugin/serve.go b/pkg/plugin/serve.go new file mode 100644 index 0000000000000000000000000000000000000000..254cb9a46883a461912acf536419c67341c221db --- /dev/null +++ b/pkg/plugin/serve.go @@ -0,0 +1,41 @@ +package plugin + +import ( + "github.com/go-semantic-release/semantic-release/pkg/analyzer/commit" + "github.com/go-semantic-release/semantic-release/pkg/plugin/wrapper" + "github.com/hashicorp/go-plugin" +) + +var Handshake = plugin.HandshakeConfig{ + MagicCookieKey: "GO_SEMANTIC_RELEASE_MAGIC_COOKIE", + MagicCookieValue: "beepboop", +} + +type CommitAnalyzerFunc func() commit.Analyzer + +//type ChangelogGeneratorFunc func() changelog.Generator + +type ServeOpts struct { + CommitAnalyzer CommitAnalyzerFunc + //ChangelogGenerator ChangelogGeneratorFunc +} + +func Serve(opts *ServeOpts) { + pluginSet := make(plugin.PluginSet) + + switch { + case opts.CommitAnalyzer != nil: + pluginSet[wrapper.TypeCommitAnalyzer] = &wrapper.GRPC{ + Type: wrapper.TypeCommitAnalyzer, + Impl: opts.CommitAnalyzer(), + } + } + + plugin.Serve(&plugin.ServeConfig{ + HandshakeConfig: Handshake, + VersionedPlugins: map[int]plugin.PluginSet{ + 1: pluginSet, + }, + GRPCServer: plugin.DefaultGRPCServer, + }) +} diff --git a/pkg/plugin/wrapper/commit_analyzer.go b/pkg/plugin/wrapper/commit_analyzer.go new file mode 100644 index 0000000000000000000000000000000000000000..1691e88c511197c63b0cdc69b575611e77b7435c --- /dev/null +++ b/pkg/plugin/wrapper/commit_analyzer.go @@ -0,0 +1,33 @@ +package wrapper + +import ( + "context" + + "github.com/go-semantic-release/semantic-release/pkg/analyzer/commit" + "github.com/go-semantic-release/semantic-release/pkg/semrel" +) + +const TypeCommitAnalyzer = "commit_analyzer" + +type CommitAnalyzerServer struct { + Impl commit.Analyzer + commit.UnimplementedCommitAnalyzerPluginServer +} + +func (c *CommitAnalyzerServer) Analyze(ctx context.Context, in *commit.CommitAnalyzerRequest) (*commit.CommitAnalyzerResponse, error) { + return &commit.CommitAnalyzerResponse{ + Commits: c.Impl.Analyze(in.RawCommits), + }, nil +} + +type CommitAnalyzerClient struct { + Impl commit.CommitAnalyzerPluginClient +} + +func (c *CommitAnalyzerClient) Analyze(commits []*semrel.RawCommit) []*semrel.Commit { + res, err := c.Impl.Analyze(context.Background(), &commit.CommitAnalyzerRequest{RawCommits: commits}) + if err != nil { + panic(err) + } + return res.Commits +} diff --git a/pkg/plugin/wrapper/grpc.go b/pkg/plugin/wrapper/grpc.go new file mode 100644 index 0000000000000000000000000000000000000000..3f828db55501930c5b599174fdd95834dfdc4e29 --- /dev/null +++ b/pkg/plugin/wrapper/grpc.go @@ -0,0 +1,36 @@ +package wrapper + +import ( + "context" + "errors" + + "github.com/go-semantic-release/semantic-release/pkg/analyzer/commit" + "github.com/hashicorp/go-plugin" + "google.golang.org/grpc" +) + +type GRPC struct { + Type string + Impl interface{} + plugin.NetRPCUnsupportedPlugin +} + +func (p *GRPC) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error { + switch p.Type { + case TypeCommitAnalyzer: + commit.RegisterCommitAnalyzerPluginServer(s, &CommitAnalyzerServer{ + Impl: p.Impl.(commit.Analyzer), + }) + } + return nil +} + +func (p *GRPC) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) { + switch p.Type { + case TypeCommitAnalyzer: + return &CommitAnalyzerClient{ + Impl: commit.NewCommitAnalyzerPluginClient(c), + }, nil + } + return nil, errors.New("unknown plugin type") +}