From eaa3a1d544d8e49fda58c942abda14d73db3a0da Mon Sep 17 00:00:00 2001 From: donoghuc Date: Thu, 15 May 2025 10:33:54 -0700 Subject: [PATCH 1/6] Remove use of deprecated `org.jruby.Ruby.fastGetModule` The `fastGetModule` is deprecated in jruby 9.4 and removed in 10: https://github.com/jruby/jruby/blob/1611c8e4e464164474a0e8c0663e16d67fa5c268/core/src/main/java/org/jruby/Ruby.java#L1373-L1385 This commit uses the getModule method (which should bridge between 9 and 10). Note that it is marked deprecated in 10 but having the 9/10 compatability will be a win in the forseable future. https://github.com/jruby/jruby/blob/02c56b6099582500f86262a1d16d6b0e5cf3fe95/core/src/main/java/org/jruby/Ruby.java#L1339-L1342 --- src/main/org/bson_ruby/NativeService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/org/bson_ruby/NativeService.java b/src/main/org/bson_ruby/NativeService.java index 02eb11896..9938380dd 100644 --- a/src/main/org/bson_ruby/NativeService.java +++ b/src/main/org/bson_ruby/NativeService.java @@ -56,7 +56,7 @@ public class NativeService implements BasicLibraryService { * @since 2.0.0 */ public boolean basicLoad(final Ruby runtime) throws IOException { - RubyModule bson = runtime.fastGetModule(BSON); + RubyModule bson = runtime.getModule(BSON); GeneratorExtension.extend(bson); RubyClass byteBuffer = bson.defineClassUnder("ByteBuffer", runtime.getObject(), new ObjectAllocator() { From 63bdd199bf3efb30dc0417a8ce082c003cf45887 Mon Sep 17 00:00:00 2001 From: donoghuc Date: Thu, 15 May 2025 11:00:47 -0700 Subject: [PATCH 2/6] See if CI will run jruby 10 --- .evergreen/config.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index cff844729..0f3017880 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -296,6 +296,10 @@ axes: display_name: ruby-2.7 variables: RVM_RUBY: ruby-2.7 + - id: jruby-10.0 + display_name: jruby-10.0 + variables: + RVM_RUBY: jruby-10.0 - id: jruby-9.4 display_name: jruby-9.4 variables: @@ -390,13 +394,13 @@ buildvariants: - name: "test" - matrix_name: "special-os" - matrix_spec: { ruby: ["ruby-3.2", "ruby-3.1", "jruby-9.4"], special-os: '*' } + matrix_spec: { ruby: ["ruby-3.2", "ruby-3.1", "jruby-9.4", "jruby-10.0"], special-os: '*' } display_name: "${ruby}, ${special-os}" tasks: - name: "test" - matrix_name: "jruby" - matrix_spec: { ruby: ["jruby-9.4", "jruby-9.3"], all-os: ubuntu2204 } + matrix_spec: { ruby: ["jruby-9.4", "jruby-9.3", "jruby-10.0"], all-os: ubuntu2204 } display_name: "${ruby}, ${all-os}" tasks: - name: "test" From e10525b6ba33171928d1708fbcfc0f6ff3e2c0f6 Mon Sep 17 00:00:00 2001 From: Dmitry Rybakov Date: Thu, 12 Jun 2025 13:08:21 +0200 Subject: [PATCH 3/6] Use latest toolchain --- .evergreen/config.yml | 23 ++++++++++++++--------- .evergreen/config/axes.yml.erb | 19 ++++++++++++------- .evergreen/config/variants.yml.erb | 2 +- .evergreen/run-tests.sh | 5 +++++ .evergreen/update-evergreen-configs | 6 +++--- spec/shared | 2 +- 6 files changed, 36 insertions(+), 21 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 0f3017880..1e8a84878 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -249,10 +249,15 @@ axes: display_name: OS values: - id: debian - display_name: "Debian 11" - run_on: debian11-small + display_name: "Debian 12" + run_on: debian12-small variables: - MACHINE: "debian11" + MACHINE: "debian12" + - id: "ubuntu2404" + display_name: "Ubuntu 24.04" + run_on: ubuntu2404-small + variables: + MACHINE: "ubuntu2204" - id: "ubuntu2204" display_name: "Ubuntu 22.04" run_on: ubuntu2204-small @@ -267,11 +272,11 @@ axes: - id: "special-os" display_name: OS values: - - id: "ubuntu2204-arm64" - display_name: "Ubuntu 22.04 ARM64" - run_on: ubuntu2204-arm64-small + - id: "ubuntu2404-arm64" + display_name: "Ubuntu 24.04 ARM64" + run_on: ubuntu2404-arm64-small variables: - MACHINE: ubuntu2204-arm64 + MACHINE: ubuntu2404-arm64 - id: ruby display_name: Ruby Version @@ -394,13 +399,13 @@ buildvariants: - name: "test" - matrix_name: "special-os" - matrix_spec: { ruby: ["ruby-3.2", "ruby-3.1", "jruby-9.4", "jruby-10.0"], special-os: '*' } + matrix_spec: { ruby: ["ruby-3.2", "ruby-3.1"], special-os: '*' } display_name: "${ruby}, ${special-os}" tasks: - name: "test" - matrix_name: "jruby" - matrix_spec: { ruby: ["jruby-9.4", "jruby-9.3", "jruby-10.0"], all-os: ubuntu2204 } + matrix_spec: { ruby: ["jruby-10.0", "jruby-9.4", "jruby-9.3"], all-os: ubuntu2204 } display_name: "${ruby}, ${all-os}" tasks: - name: "test" diff --git a/.evergreen/config/axes.yml.erb b/.evergreen/config/axes.yml.erb index 99b691d0c..05949dde0 100644 --- a/.evergreen/config/axes.yml.erb +++ b/.evergreen/config/axes.yml.erb @@ -3,10 +3,15 @@ axes: display_name: OS values: - id: debian - display_name: "Debian 11" - run_on: debian11-small + display_name: "Debian 12" + run_on: debian12-small variables: - MACHINE: "debian11" + MACHINE: "debian12" + - id: "ubuntu2404" + display_name: "Ubuntu 24.04" + run_on: ubuntu2404-small + variables: + MACHINE: "ubuntu2204" - id: "ubuntu2204" display_name: "Ubuntu 22.04" run_on: ubuntu2204-small @@ -21,11 +26,11 @@ axes: - id: "special-os" display_name: OS values: - - id: "ubuntu2204-arm64" - display_name: "Ubuntu 22.04 ARM64" - run_on: ubuntu2204-arm64-small + - id: "ubuntu2404-arm64" + display_name: "Ubuntu 24.04 ARM64" + run_on: ubuntu2404-arm64-small variables: - MACHINE: ubuntu2204-arm64 + MACHINE: ubuntu2404-arm64 - id: ruby display_name: Ruby Version diff --git a/.evergreen/config/variants.yml.erb b/.evergreen/config/variants.yml.erb index 40f27e921..d4a61541a 100644 --- a/.evergreen/config/variants.yml.erb +++ b/.evergreen/config/variants.yml.erb @@ -39,7 +39,7 @@ buildvariants: - name: "test" - matrix_name: "special-os" - matrix_spec: { ruby: <%= recent_rubies %>, special-os: '*' } + matrix_spec: { ruby: <%= recent_rubies - %w[ jruby-10.0 ] %>, special-os: '*' } display_name: "${ruby}, ${special-os}" tasks: - name: "test" diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh index 770ee2c28..a45af88ad 100644 --- a/.evergreen/run-tests.sh +++ b/.evergreen/run-tests.sh @@ -17,6 +17,11 @@ set_env_ruby install_deps +# TODO: move this to shared/shlib/set_env.sh +export JAVA_HOME="/opt/java/jdk21" +export SOURCE_VERSION=21 +export TARGET_VERSION=21 +# END TODO echo "Running specs" bundle exec rake spec test_status=$? diff --git a/.evergreen/update-evergreen-configs b/.evergreen/update-evergreen-configs index 6c0fc5d3e..cddc1e3eb 100755 --- a/.evergreen/update-evergreen-configs +++ b/.evergreen/update-evergreen-configs @@ -75,7 +75,7 @@ module ConfigProcessor # these are used for testing against a few recent ruby versions def recent_rubies - @recent_rubies ||= %w[ ruby-3.2 ruby-3.1 jruby-9.4 ] + @recent_rubies ||= %w[ ruby-3.2 ruby-3.1 jruby-10.0 ] end # the most recently released, stable version of Ruby (make sure this @@ -96,7 +96,7 @@ module ConfigProcessor # as above, but including the most recent JRuby release def sample_rubies - @sample_rubies ||= sample_mri_rubies + %w[ jruby-9.4 ] + @sample_rubies ||= sample_mri_rubies + %w[ jruby-10.0 ] end # older Ruby versions provided by 10gen/mongo-ruby-toolchain @@ -106,7 +106,7 @@ module ConfigProcessor # all supported JRuby versions provided by 10gen/mongo-ruby-toolchain def jrubies - @jrubies ||= %w[ jruby-9.4 jruby-9.3 ] + @jrubies ||= %w[ jruby-10.0 jruby-9.4 jruby-9.3 ] end # all supported MRI ruby versions diff --git a/spec/shared b/spec/shared index 2fe5724b0..51e2b4550 160000 --- a/spec/shared +++ b/spec/shared @@ -1 +1 @@ -Subproject commit 2fe5724b0a586fbeac602f15f7d43ccc7bbe531b +Subproject commit 51e2b455044a9af844784e3c3a6a8a1ff354508a From 41b4c8502cda5764aee2f4de63c0c761da04fb5f Mon Sep 17 00:00:00 2001 From: donoghuc Date: Tue, 14 Oct 2025 10:21:43 -0700 Subject: [PATCH 4/6] Jruby 10 compat: replace getLongValue The getLongValue method is deprecated. Use RubyNumeric#num2long instead. this should be compatible with both jruby 9 and 10. --- src/main/org/bson_ruby/ByteBuf.java | 2 +- src/main/org/bson_ruby/GeneratorExtension.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/org/bson_ruby/ByteBuf.java b/src/main/org/bson_ruby/ByteBuf.java index 06f1e8e0d..9cdc31e64 100644 --- a/src/main/org/bson_ruby/ByteBuf.java +++ b/src/main/org/bson_ruby/ByteBuf.java @@ -564,7 +564,7 @@ public ByteBuf putInt64(ThreadContext context, IRubyObject value) { value = ((RubyFloat) value).truncate(context); } ensureBsonWrite(8); - this.buffer.putLong(((RubyInteger) value).getLongValue()); + this.buffer.putLong(RubyNumeric.num2long(value)); this.writePosition += 8; return this; } diff --git a/src/main/org/bson_ruby/GeneratorExtension.java b/src/main/org/bson_ruby/GeneratorExtension.java index 0f82c1e44..50558ecc2 100644 --- a/src/main/org/bson_ruby/GeneratorExtension.java +++ b/src/main/org/bson_ruby/GeneratorExtension.java @@ -25,6 +25,7 @@ import org.jruby.Ruby; import org.jruby.RubyClass; import org.jruby.RubyInteger; +import org.jruby.RubyNumeric; import org.jruby.RubyModule; import org.jruby.RubyString; import org.jruby.anno.JRubyMethod; @@ -102,8 +103,7 @@ public static void extend(final RubyModule bson) { public static IRubyObject next(final IRubyObject generator) { RubyModule bson = generator.getRuntime().getModule(BSON); RubyClass objectId = bson.getClass(OBJECT_ID); - RubyInteger time = (RubyInteger) objectId.callMethod("timestamp"); - return nextObjectId(generator, (int) time.getLongValue()); + return nextObjectId(generator, (int) RubyNumeric.num2long(objectId.callMethod("timestamp"))); } /** @@ -118,7 +118,7 @@ public static IRubyObject next(final IRubyObject generator) { */ @JRubyMethod(name = { "next", "next_object_id" }) public static IRubyObject next(final IRubyObject generator, final IRubyObject time) { - return nextObjectId(generator, (int) ((RubyInteger) time).getLongValue() / 1000); + return nextObjectId(generator, (int) (RubyNumeric.num2long(time) / 1000)); } /** @@ -145,7 +145,7 @@ public static IRubyObject resetCounter(final IRubyObject generator) { */ @JRubyMethod(name = { "reset_counter" }) public static IRubyObject resetCounter(final IRubyObject generator, final IRubyObject value) { - counter.set((int) ((RubyInteger) value).getLongValue()); + counter.set((int) RubyNumeric.num2long(value)); return generator; } From 6ed82450dcaba578407b8ec11ca9cba54a332775 Mon Sep 17 00:00:00 2001 From: Dmitry Rybakov Date: Mon, 13 Oct 2025 15:49:48 +0200 Subject: [PATCH 5/6] Skip some tests on 10 --- spec/bson/int64_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/bson/int64_spec.rb b/spec/bson/int64_spec.rb index efda1023d..7d741949d 100644 --- a/spec/bson/int64_spec.rb +++ b/spec/bson/int64_spec.rb @@ -100,7 +100,7 @@ BSON::ByteBuffer.new(BSON::Int64.new(integer).to_bson.to_s) end - context "when on JRuby", if: BSON::Environment.jruby? do + context "when on JRuby", if: BSON::Environment.jruby? && RUBY_VERSION < '3.0.0' do it "deserializes to a Fixnum object" do expect(described_class.from_bson(bson).class).to be(Fixnum) @@ -120,7 +120,7 @@ BSON::ByteBuffer.new(integer.to_bson.to_s) end - context "when on JRuby", if: BSON::Environment.jruby? do + context "when on JRuby", if: BSON::Environment.jruby? && RUBY_VERSION < '3.0.0' do it "deserializes to a Fixnum object" do expect(described_class.from_bson(bson).class).to be(Fixnum) From 40a842a92cec6d02513b94b7ebe60877e3b99e8b Mon Sep 17 00:00:00 2001 From: Dmitry Rybakov Date: Wed, 15 Oct 2025 08:35:02 +0200 Subject: [PATCH 6/6] Prettify test output on CI --- .evergreen/config.yml | 2 +- .evergreen/config/functions.yml.erb | 2 +- .evergreen/run-tests.sh | 1 + .rspec | 10 ++++++++-- Gemfile | 1 + 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 1e8a84878..f352e9495 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -148,7 +148,7 @@ functions: "upload test results": - command: attach.xunit_results params: - file: ./src/*/build/test-results/TEST-*.xml + file: ./src/tmp/rspec.xml "run tests": - command: shell.exec diff --git a/.evergreen/config/functions.yml.erb b/.evergreen/config/functions.yml.erb index ba0ecc68f..5629d2a54 100644 --- a/.evergreen/config/functions.yml.erb +++ b/.evergreen/config/functions.yml.erb @@ -113,7 +113,7 @@ functions: "upload test results": - command: attach.xunit_results params: - file: ./src/*/build/test-results/TEST-*.xml + file: ./src/tmp/rspec.xml "run tests": - command: shell.exec diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh index a45af88ad..fac2776c2 100644 --- a/.evergreen/run-tests.sh +++ b/.evergreen/run-tests.sh @@ -22,6 +22,7 @@ export JAVA_HOME="/opt/java/jdk21" export SOURCE_VERSION=21 export TARGET_VERSION=21 # END TODO +export CI=1 echo "Running specs" bundle exec rake spec test_status=$? diff --git a/.rspec b/.rspec index aa6a1f446..2e2bcb135 100644 --- a/.rspec +++ b/.rspec @@ -1,3 +1,9 @@ ---color ---format <%= ENV["CI"] ? 'Rfc::Riff' : 'Fuubar'%> --tty +--colour +<% if %w(1 true yes).include?(ENV['CI']&.downcase) %> +--format RspecJunitFormatter +--out tmp/rspec.xml +--format 'Rfc::Riff' +<% else %> +--format Fuubar +<% end %> diff --git a/Gemfile b/Gemfile index 6c66dae46..f88e124da 100644 --- a/Gemfile +++ b/Gemfile @@ -38,4 +38,5 @@ end group :test do gem 'fuubar' gem 'rfc' + gem "rspec_junit_formatter" end