Verified Commit 9e69c7a1 authored by Stan Hu's avatar Stan Hu
Browse files

chore(deps): add support for google-protobuf v4

As mentioned in https://protobuf.dev/support/version-support/,
google-protobuf v3 reached end of support on 2025-03-31.

Relax the dependencies to allow for google-protobuf v4 and
regenerate the Protobuf to work with v4.

Relates to gitlab-org/gitlab#550942
parent 952b9643
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -18,7 +18,13 @@ end
desc "Generate test protobuf stubs"
task :gen_test_proto do
  system "grpc_tools_ruby_protoc --ruby_out=. --grpc_out=. spec/support/grpc_service/test.proto"
  Rufo::Command.run(["spec/support/grpc_service/test_pb.rb", "spec/support/grpc_service/test_services_pb.rb"])

  # Fix require statement to use require_relative for test environment.
  # This is a workaround for https://github.com/grpc/grpc/issues/29027.
  services_file = "spec/support/grpc_service/test_services_pb.rb"
  content = File.read(services_file)
  content.gsub!(%r{^require ['"]spec/support/grpc_service/test_pb['"]$}, "require_relative 'test_pb'")
  File.write(services_file, content)
end

task :fix => ["rubocop:autocorrect"]
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
  spec.add_runtime_dependency "actionpack", ">= 5.0.0", "< 8.1.0"
  spec.add_runtime_dependency "activesupport", ">= 5.0.0", "< 8.1.0"
  spec.add_runtime_dependency "grpc", ">= 1.75" # Be sure to update the "grpc-tools" dev_dependency too
  spec.add_runtime_dependency "google-protobuf", "~> 3" # Keep the major version to 3 until we update the `grpc` gem
  spec.add_runtime_dependency "google-protobuf", ">= 3.25", "< 5.0"
  spec.add_runtime_dependency "jaeger-client", "~> 1.1.0"
  spec.add_runtime_dependency 'json-schema', '~> 5.1'
  spec.add_runtime_dependency "opentracing", "~> 0.4"
+7 −9
Original line number Diff line number Diff line
# frozen_string_literal: true
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: spec/support/grpc_service/test.proto

require "google/protobuf"
require 'google/protobuf'

Google::Protobuf::DescriptorPool.generated_pool.build do
  add_file("spec/support/grpc_service/test.proto", :syntax => :proto3) do
    add_message "labkit_test.Msg" do
      optional :name, :string, 1
      optional :error_code, :int32, 2
    end
  end
end

descriptor_data = "\n$spec/support/grpc_service/test.proto\x12\x0blabkit_test\"\'\n\x03Msg\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x12\n\nerror_code\x18\x02 \x01(\x05\x32\xfd\x01\n\x0bTestService\x12\x34\n\x0cReqResMethod\x12\x10.labkit_test.Msg\x1a\x10.labkit_test.Msg\"\x00\x12<\n\x12ServerStreamMethod\x12\x10.labkit_test.Msg\x1a\x10.labkit_test.Msg\"\x00\x30\x01\x12<\n\x12\x43lientStreamMethod\x12\x10.labkit_test.Msg\x1a\x10.labkit_test.Msg\"\x00(\x01\x12<\n\x10\x42idiStreamMethod\x12\x10.labkit_test.Msg\x1a\x10.labkit_test.Msg\"\x00(\x01\x30\x01\x62\x06proto3"

pool = ::Google::Protobuf::DescriptorPool.generated_pool
pool.add_serialized_file(descriptor_data)

module LabkitTest
  Msg = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("labkit_test.Msg").msgclass
+5 −5
Original line number Diff line number Diff line
# frozen_string_literal: true

# Generated by the protocol buffer compiler.  DO NOT EDIT!
# Source: spec/support/grpc_service/test.proto for package 'labkit_test'

require "grpc"
require 'grpc'
require_relative 'test_pb'

module LabkitTest
  module TestService
    class Service
      include GRPC::GenericService

      include ::GRPC::GenericService

      self.marshal_class_method = :encode
      self.unmarshal_class_method = :decode
      self.service_name = "labkit_test.TestService"
      self.service_name = 'labkit_test.TestService'

      rpc :ReqResMethod, ::LabkitTest::Msg, ::LabkitTest::Msg
      rpc :ServerStreamMethod, ::LabkitTest::Msg, stream(::LabkitTest::Msg)