Commit 4dd97248 authored by Bob Van Landuyt's avatar Bob Van Landuyt 💬
Browse files

Merge branch 'sh-support-google-protobuf-v4' into 'master'

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

See merge request !205

Merged-by: Bob Van Landuyt's avatarBob Van Landuyt <bob@gitlab.com>
Approved-by: Bob Van Landuyt's avatarBob Van Landuyt <bob@gitlab.com>
Co-authored-by: default avatarStan Hu <stanhu@gmail.com>
parents 952b9643 720aea20
Loading
Loading
Loading
Loading
Loading
+54 −15
Original line number Diff line number Diff line
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2025-05-05 15:54:30 UTC using RuboCop version 1.68.0.
# on 2025-11-17 07:59:08 UTC using RuboCop version 1.71.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
@@ -25,7 +25,7 @@ Fips/SHA1:
  Exclude:
    - 'spec/labkit/fips_spec.rb'

# Offense count: 8
# Offense count: 10
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Include.
# Include: **/*.gemspec
@@ -56,11 +56,26 @@ Layout/ClassStructure:
  Exclude:
    - 'lib/labkit/tracing/rack_middleware.rb'

# Offense count: 1
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Layout/EmptyLineAfterMagicComment:
  Exclude:
    - 'lib/labkit/logging/json_logger.rb'
    - 'spec/support/grpc_service/test_pb.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Layout/EmptyLines:
  Exclude:
    - 'spec/support/grpc_service/test_pb.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only
Layout/EmptyLinesAroundClassBody:
  Exclude:
    - 'spec/support/grpc_service/test_services_pb.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
@@ -144,7 +159,8 @@ Lint/UnexpectedBlockArity:

# Offense count: 41
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions.
# NotImplementedExceptions: NotImplementedError
Lint/UnusedMethodArgument:
  Exclude:
    - 'lib/labkit/correlation/grpc/client_interceptor.rb'
@@ -254,7 +270,7 @@ RSpec/LetBeforeExamples:
  Exclude:
    - 'spec/labkit/tracing_spec.rb'

# Offense count: 20
# Offense count: 31
# Configuration parameters: AllowSubject.
RSpec/MultipleMemoizedHelpers:
  Max: 8
@@ -326,7 +342,7 @@ Rails/NegateInclude:
  Exclude:
    - 'spec/labkit/correlation/grpc/client_interceptor_spec.rb'

# Offense count: 1
# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Include.
# Include: **/Rakefile, **/*.rake
@@ -361,6 +377,14 @@ Style/AsciiComments:
  Exclude:
    - 'spec/support/grpc_service/test_service_impl.rb'

# Offense count: 7
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: allow_single_line, allow_always, disallow
Style/EndlessMethod:
  Exclude:
    - 'lib/labkit/user_experience_sli/null.rb'

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowedVars.
@@ -369,6 +393,15 @@ Style/FetchEnvVar:
    - 'lib/labkit/tracing.rb'
    - 'spec/helpers/stub_env.rb'

# Offense count: 5
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/FileNull:
  Exclude:
    - 'spec/labkit/logging/json_logger_spec.rb'
    - 'spec/labkit/middleware/sidekiq/user_experience_sli/client_spec.rb'
    - 'spec/labkit/middleware/sidekiq/user_experience_sli/server_spec.rb'
    - 'spec/spec_helper.rb'

# Offense count: 8
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
@@ -381,7 +414,7 @@ Style/FrozenStringLiteralComment:
    - 'spec/labkit/tracing/rails/active_support/cache_generate_instrumenter_spec.rb'
    - 'spec/labkit/tracing/rails/active_support/cache_read_instrumenter_spec.rb'
    - 'spec/labkit/tracing/rails/active_support/cache_write_instrumenter_spec.rb'
    - 'spec/support/grpc_service/test_pb.rb'
    - 'spec/support/grpc_service/test_services_pb.rb'
    - 'tools/update-changelog.rb'

# Offense count: 2
@@ -397,7 +430,7 @@ Style/GuardClause:
  Exclude:
    - 'lib/labkit/logging/json_logger.rb'

# Offense count: 34
# Offense count: 33
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
@@ -408,7 +441,6 @@ Style/HashSyntax:
    - 'lib/labkit/tracing/tracing_utils.rb'
    - 'spec/labkit/tracing/rack_middleware_spec.rb'
    - 'spec/labkit/tracing/redis/redis_interceptor_helper_spec.rb'
    - 'spec/support/grpc_service/test_pb.rb'
    - 'spec/support/tracing/shared_examples.rb'

# Offense count: 1
@@ -459,11 +491,12 @@ Style/RedundantBegin:
  Exclude:
    - 'spec/labkit/net_http_publisher_spec.rb'

# Offense count: 3
# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantConstantBase:
  Exclude:
    - 'spec/labkit/logging/grpc/server_interceptor_spec.rb'
    - 'spec/support/grpc_service/test_pb.rb'

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
@@ -491,6 +524,12 @@ Style/RedundantReturn:
  Exclude:
    - 'lib/labkit/tracing/jaeger_factory.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantStringEscape:
  Exclude:
    - 'spec/support/grpc_service/test_pb.rb'

# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Mode.
@@ -519,7 +558,7 @@ Style/SymbolLiteral:
    - 'lib/labkit/tracing/tracing_utils.rb'
    - 'spec/support/tracing/shared_examples.rb'

# Offense count: 39
# Offense count: 42
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
@@ -545,16 +584,16 @@ Style/TrailingCommaInArrayLiteral:
    - 'spec/labkit/tracing/rails/active_support/cache_generate_instrumenter_spec.rb'
    - 'spec/labkit/tracing/rails/active_support/cache_write_instrumenter_spec.rb'

# Offense count: 84
# Offense count: 85
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInHashLiteral:
  Enabled: false

# Offense count: 68
# Offense count: 75
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
# URISchemes: http, https
Layout/LineLength:
  Max: 294
  Max: 567
+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"]
+2 −2
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"
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
  spec.add_development_dependency "excon", "~> 0.78.1"
  spec.add_development_dependency "faraday", "~> 1.10.3"
  spec.add_development_dependency "gitlab-dangerfiles", "~> 2.11.0"
  spec.add_development_dependency "gitlab-styles", "~> 13.0.2"
  spec.add_development_dependency "gitlab-styles", "~> 13.1"
  spec.add_development_dependency "grpc-tools", ">= 1.75"
  spec.add_development_dependency "httparty", "~> 0.22.0"
  spec.add_development_dependency "httpclient", "~> 2.9.0"
+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)