diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-10-27 07:34:56 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-11-03 10:06:55 +0300 |
commit | d17621d70f30b5a8efe1dc635d4a50642b59a035 (patch) | |
tree | 8e086682ef1465e3bbc63d9aa80302b1609d7095 | |
parent | b29f8633097c7e2f7c50cfc2e33bcc645e943636 (diff) |
ruby: Move scripts that generate Proto sources into tools directory
We've got multiple scripts that are required to generate Ruby code from
our Protobuf definitions in the `_support` directory. This has multiple
smells:
- It's out-of-line with all the other tools, which nowadays are
located in the `tools` directory.
- It's hard to discover and find out which parts logically form a
unit.
- We are reusing the Gemfile of the Ruby sidecar to pin the
`grpc-tools` dependency to a specific version.
Move the tooling into its own `tools/protogem` directory that's got its
own Gemfile to fix these points. This also allows us to auto-update
dependencies via the Renovate bot like we do for our other tools.
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | doc/PROCESS.md | 4 | ||||
-rw-r--r-- | ruby/Gemfile | 2 | ||||
-rw-r--r-- | ruby/Gemfile.lock | 2 | ||||
-rw-r--r-- | tools/protogem/Gemfile | 3 | ||||
-rw-r--r-- | tools/protogem/Gemfile.lock | 13 | ||||
-rwxr-xr-x | tools/protogem/generate-proto-ruby (renamed from _support/generate-proto-ruby) | 6 | ||||
-rwxr-xr-x | tools/protogem/publish-gem (renamed from _support/publish-gem) | 0 | ||||
-rw-r--r-- | tools/protogem/run.rb (renamed from _support/run.rb) | 0 |
9 files changed, 22 insertions, 10 deletions
@@ -487,7 +487,7 @@ proto: ${PROTOC} ${PROTOC_GEN_GO} ${PROTOC_GEN_GO_GRPC} ${PROTOC_GEN_GITALY_PROT ${Q}mkdir -p ${SOURCE_DIR}/proto/go/gitalypb ${Q}rm -f ${SOURCE_DIR}/proto/go/gitalypb/*.pb.go ${PROTOC} ${SHARED_PROTOC_OPTS} -I ${SOURCE_DIR}/proto -I ${PROTOC_INSTALL_DIR}/include --go_out=${SOURCE_DIR}/proto/go/gitalypb --gitaly-protolist_out=proto_dir=${SOURCE_DIR}/proto,gitalypb_dir=${SOURCE_DIR}/proto/go/gitalypb:${SOURCE_DIR} --go-grpc_out=${SOURCE_DIR}/proto/go/gitalypb ${SOURCE_DIR}/proto/*.proto - ${SOURCE_DIR}/_support/generate-proto-ruby + ${SOURCE_DIR}/tools/protogem/generate-proto-ruby @ # this part is related to the generation of sources from testing proto files ${PROTOC} ${SHARED_PROTOC_OPTS} -I ${SOURCE_DIR}/proto -I ${SOURCE_DIR}/internal -I ${PROTOC_INSTALL_DIR}/include --go_out=${SOURCE_DIR}/internal --go-grpc_out=${SOURCE_DIR}/internal \ ${SOURCE_DIR}/internal/praefect/mock/mock.proto \ diff --git a/doc/PROCESS.md b/doc/PROCESS.md index d893dbf3b..c01b05338 100644 --- a/doc/PROCESS.md +++ b/doc/PROCESS.md @@ -455,12 +455,12 @@ tagging a RC is a good way to make sure the gitlab feature branch has the proper ### Publishing the ruby gem -If an updated version of the ruby proto gem is needed, it can be published to rubygems.org with the `_support/publish-gem` script. +If an updated version of the ruby proto gem is needed, it can be published to rubygems.org with the `tools/protogen/publish-gem` script. If the changes needed are not yet released, [create a release candidate](#creating-a-release-candidate) first. - Checkout the tag to publish (vX.Y.Z) -- run `_support/publish-gem X.Y.Z` +- run `tools/protogen/publish-gem X.Y.Z` ### Publishing the go module diff --git a/ruby/Gemfile b/ruby/Gemfile index c0c965c71..612728242 100644 --- a/ruby/Gemfile +++ b/ruby/Gemfile @@ -33,8 +33,6 @@ group :development, :test do gem 'timecop', require: false gem 'factory_bot', require: false gem 'pry', '~> 0.12.2', require: false - - gem 'grpc-tools', '~> 1.42.0' end # Gems required in omnibus-gitlab pipeline diff --git a/ruby/Gemfile.lock b/ruby/Gemfile.lock index 061614c79..82177dbb1 100644 --- a/ruby/Gemfile.lock +++ b/ruby/Gemfile.lock @@ -87,7 +87,6 @@ GEM grpc (1.42.0) google-protobuf (~> 3.18) googleapis-common-protos-types (~> 1.0) - grpc-tools (1.42.0) i18n (1.12.0) concurrent-ruby (~> 1.0) ice_nine (0.11.2) @@ -236,7 +235,6 @@ DEPENDENCIES gitlab-markup (~> 1.7.1) google-protobuf (~> 3.21.7) grpc (~> 1.42.0) - grpc-tools (~> 1.42.0) licensee (~> 9.15) pry (~> 0.12.2) rbtrace diff --git a/tools/protogem/Gemfile b/tools/protogem/Gemfile new file mode 100644 index 000000000..9cafb7578 --- /dev/null +++ b/tools/protogem/Gemfile @@ -0,0 +1,3 @@ +source 'https://rubygems.org' + +gem 'grpc-tools', '~> 1.42.0' diff --git a/tools/protogem/Gemfile.lock b/tools/protogem/Gemfile.lock new file mode 100644 index 000000000..57b2bf6f9 --- /dev/null +++ b/tools/protogem/Gemfile.lock @@ -0,0 +1,13 @@ +GEM + remote: https://rubygems.org/ + specs: + grpc-tools (1.42.0) + +PLATFORMS + ruby + +DEPENDENCIES + grpc-tools (~> 1.42.0) + +BUNDLED WITH + 2.3.24 diff --git a/_support/generate-proto-ruby b/tools/protogem/generate-proto-ruby index 6ddb15cbb..544da294f 100755 --- a/_support/generate-proto-ruby +++ b/tools/protogem/generate-proto-ruby @@ -15,12 +15,12 @@ def main FileUtils.rm(Dir[File.join(ruby_lib_gitaly, '**/*_pb.rb')]) FileUtils.mkdir_p(ruby_lib_gitaly) - Dir.chdir(File.join(Dir.pwd, 'ruby')) do + Dir.chdir(File.join(Dir.pwd, 'tools', 'protogem')) do # Using an absolute path make sure the prefixes match, or the passed in file # locations. `protoc` requires this. - proto_include_abs = File.absolute_path(File.join('..', PROTO_INCLUDE)) + proto_include_abs = File.absolute_path(File.join('..', '..', PROTO_INCLUDE)) - run!(%W[bundle exec grpc_tools_ruby_protoc -I #{proto_include_abs} --ruby_out=../#{ruby_lib_gitaly} --grpc_out=../#{ruby_lib_gitaly}] + PROTO_FILES) + run!(%W[bundle exec grpc_tools_ruby_protoc -I #{proto_include_abs} --ruby_out=../../#{ruby_lib_gitaly} --grpc_out=../../#{ruby_lib_gitaly}] + PROTO_FILES) end write_ruby_requires diff --git a/_support/publish-gem b/tools/protogem/publish-gem index f0a1b138e..f0a1b138e 100755 --- a/_support/publish-gem +++ b/tools/protogem/publish-gem diff --git a/_support/run.rb b/tools/protogem/run.rb index e7d29a1e8..e7d29a1e8 100644 --- a/_support/run.rb +++ b/tools/protogem/run.rb |