Skip to content

Commit 4a92a1c

Browse files
JasonLunncopybara-github
authored andcommitted
Support ruby 3.4 (#19752)
#test-continuous Closes #19752 COPYBARA_INTEGRATE_REVIEW=#19752 from protocolbuffers:support_ruby_3.4 d326fc2 PiperOrigin-RevId: 715037231
1 parent bfbed2a commit 4a92a1c

File tree

5 files changed

+37
-30
lines changed

5 files changed

+37
-30
lines changed

.github/workflows/test_ruby.yml

+27-24
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,16 @@ jobs:
2929
matrix:
3030
include:
3131
# Test both FFI and Native implementations on the highest and lowest
32-
# Ruby versions for CRuby and JRuby, but only on Bazel 5.x.
33-
- { name: Ruby 3.0, ruby: ruby-3.0.2, ffi: NATIVE }
34-
- { name: Ruby 3.0, ruby: ruby-3.0.2, ffi: FFI, continuous-only: true }
35-
- { name: Ruby 3.1, ruby: ruby-3.1.0, continuous-only: true }
36-
- { name: Ruby 3.2, ruby: ruby-3.2.0, continuous-only: true }
37-
- { name: Ruby 3.3, ruby: ruby-3.3.0, ffi: NATIVE }
38-
- { name: Ruby 3.3, ruby: ruby-3.3.0, ffi: FFI }
39-
- { name: JRuby 9.4, ruby: jruby-9.4.6.0, ffi: NATIVE }
40-
- { name: JRuby 9.4, ruby: jruby-9.4.6.0, ffi: FFI }
32+
# Ruby versions for CRuby and JRuby
33+
- { 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' }
34+
- { 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' }
35+
- { name: Ruby 3.1, ruby: ruby-3.1.6, continuous-only: true }
36+
- { name: Ruby 3.2, ruby: ruby-3.2.6, continuous-only: true }
37+
- { name: Ruby 3.3, ruby: ruby-3.3.6, continuous-only: true }
38+
- { name: Ruby 3.4, ruby: ruby-3.4.1, ffi: NATIVE }
39+
- { name: Ruby 3.4, ruby: ruby-3.4.1, ffi: FFI }
40+
- { name: JRuby 9.4, ruby: jruby-9.4.9.0, ffi: NATIVE }
41+
- { name: JRuby 9.4, ruby: jruby-9.4.9.0, ffi: FFI }
4142

4243
name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} Linux ${{ matrix.name }} ${{ matrix.ffi == 'FFI' && ' FFI' || '' }}
4344
runs-on: ubuntu-latest
@@ -51,7 +52,7 @@ jobs:
5152
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
5253
uses: protocolbuffers/protobuf-ci/bazel-docker@v4
5354
with:
54-
image: ${{ matrix.image || format('us-docker.pkg.dev/protobuf-build/containers/test/linux/ruby:7.1.2-{0}-d9624f2aa83cba3eaf906f751d75b36aacb9aa82', matrix.ruby) }}
55+
image: ${{ matrix.image || format('us-docker.pkg.dev/protobuf-build/containers/test/linux/ruby:7.1.2-{0}-90d207f4e749b54c8792bbe974dfc70323b6566e', matrix.ruby) }}
5556
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
5657
bazel-cache: ruby_linux/${{ matrix.ruby }}
5758
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:
132133
matrix:
133134
include:
134135
# Test both FFI and Native implementations on the highest and lowest
135-
# Ruby versions for CRuby, but only on Bazel 5.x.
136+
# Ruby versions for CRuby.
136137
# Quote versions numbers otherwise 3.0 will render as 3
137138
- { version: "3.0", ffi: NATIVE }
138139
- { version: "3.0", ffi: FFI, continuous-only: true }
139140
- { version: "3.1", continuous-only: true }
140141
- { version: "3.2", continuous-only: true }
141-
- { version: "3.3", ffi: NATIVE }
142-
- { version: "3.3", ffi: FFI }
142+
- { version: "3.3", continuous-only: true }
143+
- { version: "3.4", ffi: NATIVE }
144+
- { version: "3.4", ffi: FFI }
143145

144146
name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} MacOS Ruby ${{ matrix.version }}${{ matrix.ffi == 'FFI' && ' FFI' || '' }}
145147
runs-on: macos-13
@@ -152,7 +154,7 @@ jobs:
152154

153155
- name: Pin Ruby version
154156
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
155-
uses: ruby/setup-ruby@961f85197f92e4842e3cb92a4f97bd8e010cdbaf # v1.165.0
157+
uses: ruby/setup-ruby@4a9ddd6f338a97768b8006bf671dfbad383215f4 # v1.207.0
156158
with:
157159
ruby-version: ${{ matrix.version }}
158160

@@ -176,15 +178,16 @@ jobs:
176178
matrix:
177179
include:
178180
# Test both FFI and Native implementations on the highest and lowest
179-
# Ruby versions for CRuby and JRuby, but only on Bazel 5.x.
180-
- { name: Ruby 3.0, ruby: ruby-3.0.2, ffi: NATIVE}
181-
- { name: Ruby 3.0, ruby: ruby-3.0.2, ffi: FFI}
182-
- { name: Ruby 3.1, ruby: ruby-3.1.0}
183-
- { name: Ruby 3.2, ruby: ruby-3.2.0}
184-
- { name: Ruby 3.3, ruby: ruby-3.3.0, ffi: NATIVE }
185-
- { name: Ruby 3.3, ruby: ruby-3.3.0, ffi: FFI }
186-
- { name: JRuby 9.4, ruby: jruby-9.4.6.0, ffi: NATIVE }
187-
- { name: JRuby 9.4, ruby: jruby-9.4.6.0, ffi: FFI }
181+
# Ruby versions for CRuby and JRuby.
182+
- { 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'}
183+
- { 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'}
184+
- { name: Ruby 3.1, ruby: ruby-3.1.6}
185+
- { name: Ruby 3.2, ruby: ruby-3.2.6}
186+
- { name: Ruby 3.3, ruby: ruby-3.3.6}
187+
- { name: Ruby 3.4, ruby: ruby-3.4.1, ffi: NATIVE }
188+
- { name: Ruby 3.4, ruby: ruby-3.4.1, ffi: FFI }
189+
- { name: JRuby 9.4, ruby: jruby-9.4.9.0, ffi: NATIVE }
190+
- { name: JRuby 9.4, ruby: jruby-9.4.9.0, ffi: FFI }
188191
name: ${{ inputs.continuous-prefix }} Install ${{ matrix.name }}${{ matrix.ffi == 'FFI' && ' FFI' || '' }}
189192
runs-on: ubuntu-latest
190193
steps:
@@ -197,7 +200,7 @@ jobs:
197200
if: ${{ inputs.continuous-run }}
198201
uses: protocolbuffers/protobuf-ci/bazel-docker@v4
199202
with:
200-
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/ruby:7.1.2-${{ matrix.ruby }}-d9624f2aa83cba3eaf906f751d75b36aacb9aa82
203+
image: ${{ matrix.image || format('us-docker.pkg.dev/protobuf-build/containers/test/linux/ruby:7.1.2-{0}-90d207f4e749b54c8792bbe974dfc70323b6566e', matrix.ruby) }}
201204
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
202205
bazel-cache: ruby_install/${{ matrix.ruby }}_${{ matrix.bazel }}
203206
bash: >

WORKSPACE

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ load("@system_ruby//:bundle.bzl", "ruby_bundle")
152152
ruby_bundle(
153153
name = "protobuf_bundle",
154154
srcs = ["//ruby:google-protobuf.gemspec"],
155+
bundler_version = "2.4.22",
155156
gemfile = "//ruby:Gemfile",
156157
)
157158

ruby/Gemfile.lock

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ GEM
1111
specs:
1212
bigdecimal (3.1.8)
1313
bigdecimal (3.1.8-java)
14-
ffi (1.17.0)
14+
ffi (1.17.1)
15+
ffi (1.17.1-java)
1516
ffi-compiler (1.3.2)
1617
ffi (>= 1.15.5)
1718
rake

ruby/google-protobuf.gemspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Gem::Specification.new do |s|
3232
s.add_development_dependency "rake-compiler-dock", "= 1.2.1"
3333
end
3434
s.required_ruby_version = '>= 3.0'
35+
# bigdecimal must be used as a non-built in gem as of ruby-3.4
36+
s.add_dependency "bigdecimal"
3537
# TODO: evaluate removing Rakefile and moving logic to extconf.rb, so that we
3638
# can remove this runtime dependency on rake. See the discussion here for
3739
# more details:
@@ -41,6 +43,4 @@ Gem::Specification.new do |s|
4143
s.add_development_dependency "ffi-compiler", "~>1"
4244
s.add_development_dependency "rake-compiler", "~> 1.1.0"
4345
s.add_development_dependency "test-unit", '~> 3.0', '>= 3.0.9'
44-
# bigdecimal must be used as a non-built in gem as of ruby-3.4
45-
s.add_development_dependency "bigdecimal"
4646
end

ruby/tests/repeated_field_test.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@ def test_acts_like_enumerator
1818
def test_acts_like_an_array
1919
m = TestMessage.new
2020
arr_methods = ([].methods - TestMessage.new.repeated_string.methods)
21-
# jRuby additions to the Array class that we can ignore
21+
# JRuby additions to the Array class that we ignore
2222
arr_methods -= [ :indices, :iter_for_each, :iter_for_each_index,
2323
:iter_for_each_with_index, :dimensions, :copy_data, :copy_data_simple,
2424
:nitems, :iter_for_reverse_each, :indexes, :append, :prepend]
2525
arr_methods -= [:filter!]
26-
# ruby 2.7 methods we can ignore
26+
# ruby 2.7 methods we ignore
2727
arr_methods -= [:deconstruct, :resolve_feature_path]
28-
# ruby 3.1 methods we can ignore
28+
# ruby 3.1 methods we ignore
2929
arr_methods -= [:intersect?]
30+
# ruby 3.4 methods we ignore
31+
arr_methods -= [:fetch_values]
3032
arr_methods.each do |method_name|
3133
assert_respond_to m.repeated_string, method_name
3234
end

0 commit comments

Comments
 (0)