From 4a92a1c9bffa4ee8d77ec25364d914c47662565c Mon Sep 17 00:00:00 2001 From: Jason Lunn Date: Mon, 13 Jan 2025 11:05:34 -0800 Subject: [PATCH] Support ruby 3.4 (#19752) #test-continuous Closes #19752 COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/19752 from protocolbuffers:support_ruby_3.4 d326fc2a6fda6a150e86f258fd5f8a46b0d84ada PiperOrigin-RevId: 715037231 --- .github/workflows/test_ruby.yml | 51 ++++++++++++++++--------------- WORKSPACE | 1 + ruby/Gemfile.lock | 3 +- ruby/google-protobuf.gemspec | 4 +-- ruby/tests/repeated_field_test.rb | 8 +++-- 5 files changed, 37 insertions(+), 30 deletions(-) diff --git a/.github/workflows/test_ruby.yml b/.github/workflows/test_ruby.yml index d7ab5fe187160..addb183c3531c 100644 --- a/.github/workflows/test_ruby.yml +++ b/.github/workflows/test_ruby.yml @@ -29,15 +29,16 @@ jobs: matrix: include: # Test both FFI and Native implementations on the highest and lowest - # Ruby versions for CRuby and JRuby, but only on Bazel 5.x. - - { name: Ruby 3.0, ruby: ruby-3.0.2, ffi: NATIVE } - - { name: Ruby 3.0, ruby: ruby-3.0.2, ffi: FFI, continuous-only: true } - - { name: Ruby 3.1, ruby: ruby-3.1.0, continuous-only: true } - - { name: Ruby 3.2, ruby: ruby-3.2.0, continuous-only: true } - - { name: Ruby 3.3, ruby: ruby-3.3.0, ffi: NATIVE } - - { name: Ruby 3.3, ruby: ruby-3.3.0, ffi: FFI } - - { name: JRuby 9.4, ruby: jruby-9.4.6.0, ffi: NATIVE } - - { name: JRuby 9.4, ruby: jruby-9.4.6.0, ffi: FFI } + # Ruby versions for CRuby and JRuby + - { name: Ruby 3.0, ruby: ruby-3.0.2, ffi: NATIVE, image: 'us-docker.pkg.dev/protobuf-build/containers/test/linux/ruby:7.1.2-ruby-3.0.2-d9624f2aa83cba3eaf906f751d75b36aacb9aa82' } + - { name: Ruby 3.0, ruby: ruby-3.0.2, ffi: FFI, continuous-only: true, image: 'us-docker.pkg.dev/protobuf-build/containers/test/linux/ruby:7.1.2-ruby-3.0.2-d9624f2aa83cba3eaf906f751d75b36aacb9aa82' } + - { name: Ruby 3.1, ruby: ruby-3.1.6, continuous-only: true } + - { name: Ruby 3.2, ruby: ruby-3.2.6, continuous-only: true } + - { name: Ruby 3.3, ruby: ruby-3.3.6, continuous-only: true } + - { name: Ruby 3.4, ruby: ruby-3.4.1, ffi: NATIVE } + - { name: Ruby 3.4, ruby: ruby-3.4.1, ffi: FFI } + - { name: JRuby 9.4, ruby: jruby-9.4.9.0, ffi: NATIVE } + - { name: JRuby 9.4, ruby: jruby-9.4.9.0, ffi: FFI } name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} Linux ${{ matrix.name }} ${{ matrix.ffi == 'FFI' && ' FFI' || '' }} runs-on: ubuntu-latest @@ -51,7 +52,7 @@ jobs: if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/bazel-docker@v4 with: - image: ${{ matrix.image || format('us-docker.pkg.dev/protobuf-build/containers/test/linux/ruby:7.1.2-{0}-d9624f2aa83cba3eaf906f751d75b36aacb9aa82', matrix.ruby) }} + image: ${{ matrix.image || format('us-docker.pkg.dev/protobuf-build/containers/test/linux/ruby:7.1.2-{0}-90d207f4e749b54c8792bbe974dfc70323b6566e', matrix.ruby) }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: ruby_linux/${{ matrix.ruby }} bazel: test //ruby/... //ruby/tests:ruby_version --test_env=KOKORO_RUBY_VERSION --test_env=BAZEL=true ${{ matrix.ffi == 'FFI' && '--//ruby:ffi=enabled --test_env=PROTOCOL_BUFFERS_RUBY_IMPLEMENTATION=FFI' || '' }} @@ -132,14 +133,15 @@ jobs: matrix: include: # Test both FFI and Native implementations on the highest and lowest - # Ruby versions for CRuby, but only on Bazel 5.x. + # Ruby versions for CRuby. # Quote versions numbers otherwise 3.0 will render as 3 - { version: "3.0", ffi: NATIVE } - { version: "3.0", ffi: FFI, continuous-only: true } - { version: "3.1", continuous-only: true } - { version: "3.2", continuous-only: true } - - { version: "3.3", ffi: NATIVE } - - { version: "3.3", ffi: FFI } + - { version: "3.3", continuous-only: true } + - { version: "3.4", ffi: NATIVE } + - { version: "3.4", ffi: FFI } name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} MacOS Ruby ${{ matrix.version }}${{ matrix.ffi == 'FFI' && ' FFI' || '' }} runs-on: macos-13 @@ -152,7 +154,7 @@ jobs: - name: Pin Ruby version if: ${{ !matrix.continuous-only || inputs.continuous-run }} - uses: ruby/setup-ruby@961f85197f92e4842e3cb92a4f97bd8e010cdbaf # v1.165.0 + uses: ruby/setup-ruby@4a9ddd6f338a97768b8006bf671dfbad383215f4 # v1.207.0 with: ruby-version: ${{ matrix.version }} @@ -176,15 +178,16 @@ jobs: matrix: include: # Test both FFI and Native implementations on the highest and lowest - # Ruby versions for CRuby and JRuby, but only on Bazel 5.x. - - { name: Ruby 3.0, ruby: ruby-3.0.2, ffi: NATIVE} - - { name: Ruby 3.0, ruby: ruby-3.0.2, ffi: FFI} - - { name: Ruby 3.1, ruby: ruby-3.1.0} - - { name: Ruby 3.2, ruby: ruby-3.2.0} - - { name: Ruby 3.3, ruby: ruby-3.3.0, ffi: NATIVE } - - { name: Ruby 3.3, ruby: ruby-3.3.0, ffi: FFI } - - { name: JRuby 9.4, ruby: jruby-9.4.6.0, ffi: NATIVE } - - { name: JRuby 9.4, ruby: jruby-9.4.6.0, ffi: FFI } + # Ruby versions for CRuby and JRuby. + - { name: Ruby 3.0, ruby: ruby-3.0.2, ffi: NATIVE, image: 'us-docker.pkg.dev/protobuf-build/containers/test/linux/ruby:7.1.2-ruby-3.0.2-d9624f2aa83cba3eaf906f751d75b36aacb9aa82'} + - { name: Ruby 3.0, ruby: ruby-3.0.2, ffi: FFI, image: 'us-docker.pkg.dev/protobuf-build/containers/test/linux/ruby:7.1.2-ruby-3.0.2-d9624f2aa83cba3eaf906f751d75b36aacb9aa82'} + - { name: Ruby 3.1, ruby: ruby-3.1.6} + - { name: Ruby 3.2, ruby: ruby-3.2.6} + - { name: Ruby 3.3, ruby: ruby-3.3.6} + - { name: Ruby 3.4, ruby: ruby-3.4.1, ffi: NATIVE } + - { name: Ruby 3.4, ruby: ruby-3.4.1, ffi: FFI } + - { name: JRuby 9.4, ruby: jruby-9.4.9.0, ffi: NATIVE } + - { name: JRuby 9.4, ruby: jruby-9.4.9.0, ffi: FFI } name: ${{ inputs.continuous-prefix }} Install ${{ matrix.name }}${{ matrix.ffi == 'FFI' && ' FFI' || '' }} runs-on: ubuntu-latest steps: @@ -197,7 +200,7 @@ jobs: if: ${{ inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/bazel-docker@v4 with: - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/ruby:7.1.2-${{ matrix.ruby }}-d9624f2aa83cba3eaf906f751d75b36aacb9aa82 + image: ${{ matrix.image || format('us-docker.pkg.dev/protobuf-build/containers/test/linux/ruby:7.1.2-{0}-90d207f4e749b54c8792bbe974dfc70323b6566e', matrix.ruby) }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: ruby_install/${{ matrix.ruby }}_${{ matrix.bazel }} bash: > diff --git a/WORKSPACE b/WORKSPACE index c49abcf5329fc..e5599f4d9ecc2 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -152,6 +152,7 @@ load("@system_ruby//:bundle.bzl", "ruby_bundle") ruby_bundle( name = "protobuf_bundle", srcs = ["//ruby:google-protobuf.gemspec"], + bundler_version = "2.4.22", gemfile = "//ruby:Gemfile", ) diff --git a/ruby/Gemfile.lock b/ruby/Gemfile.lock index 0665182f33f04..3a3b8fb843188 100644 --- a/ruby/Gemfile.lock +++ b/ruby/Gemfile.lock @@ -11,7 +11,8 @@ GEM specs: bigdecimal (3.1.8) bigdecimal (3.1.8-java) - ffi (1.17.0) + ffi (1.17.1) + ffi (1.17.1-java) ffi-compiler (1.3.2) ffi (>= 1.15.5) rake diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec index c6d82f904cd5d..257b3a495db8a 100644 --- a/ruby/google-protobuf.gemspec +++ b/ruby/google-protobuf.gemspec @@ -32,6 +32,8 @@ Gem::Specification.new do |s| s.add_development_dependency "rake-compiler-dock", "= 1.2.1" end s.required_ruby_version = '>= 3.0' + # bigdecimal must be used as a non-built in gem as of ruby-3.4 + s.add_dependency "bigdecimal" # TODO: evaluate removing Rakefile and moving logic to extconf.rb, so that we # can remove this runtime dependency on rake. See the discussion here for # more details: @@ -41,6 +43,4 @@ Gem::Specification.new do |s| s.add_development_dependency "ffi-compiler", "~>1" s.add_development_dependency "rake-compiler", "~> 1.1.0" s.add_development_dependency "test-unit", '~> 3.0', '>= 3.0.9' - # bigdecimal must be used as a non-built in gem as of ruby-3.4 - s.add_development_dependency "bigdecimal" end diff --git a/ruby/tests/repeated_field_test.rb b/ruby/tests/repeated_field_test.rb index 143a9ead06a5b..e4983a566f2cc 100755 --- a/ruby/tests/repeated_field_test.rb +++ b/ruby/tests/repeated_field_test.rb @@ -18,15 +18,17 @@ def test_acts_like_enumerator def test_acts_like_an_array m = TestMessage.new arr_methods = ([].methods - TestMessage.new.repeated_string.methods) - # jRuby additions to the Array class that we can ignore + # JRuby additions to the Array class that we ignore arr_methods -= [ :indices, :iter_for_each, :iter_for_each_index, :iter_for_each_with_index, :dimensions, :copy_data, :copy_data_simple, :nitems, :iter_for_reverse_each, :indexes, :append, :prepend] arr_methods -= [:filter!] - # ruby 2.7 methods we can ignore + # ruby 2.7 methods we ignore arr_methods -= [:deconstruct, :resolve_feature_path] - # ruby 3.1 methods we can ignore + # ruby 3.1 methods we ignore arr_methods -= [:intersect?] + # ruby 3.4 methods we ignore + arr_methods -= [:fetch_values] arr_methods.each do |method_name| assert_respond_to m.repeated_string, method_name end