From 362de0b8130e4a8bf159fdd4f4b9add8a9825240 Mon Sep 17 00:00:00 2001 From: kares Date: Mon, 21 Feb 2022 16:32:37 +0100 Subject: [PATCH 1/4] CI: let's roll tests with JRuby --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 94cc9eb673..e0a5139cac 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: matrix: # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0' # TODO: Add jruby if something like allow_failures will be implemented on Actions. - ruby: [2.6, 2.7, '3.0', 3.1] + ruby: [2.6, 2.7, '3.0', 3.1, 'jruby-9.3'] steps: - uses: actions/checkout@v2 - uses: ruby/setup-ruby@v1 From fab11ea7e5178792134951ff2732a7addaee865c Mon Sep 17 00:00:00 2001 From: kares Date: Mon, 21 Feb 2022 16:33:01 +0100 Subject: [PATCH 2/4] avoid threaded setup for test server --- test/integration_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration_helper.rb b/test/integration_helper.rb index 68a40c7ac2..0e81e65db2 100644 --- a/test/integration_helper.rb +++ b/test/integration_helper.rb @@ -154,7 +154,7 @@ def kill @thread = nil end end - Server = JRubyServer + Server = BaseServer else Server = BaseServer end From 14f17390fc4301e3ed6cf91e621a4cb55b9022f4 Mon Sep 17 00:00:00 2001 From: kares Date: Mon, 21 Feb 2022 16:40:59 +0100 Subject: [PATCH 3/4] Test: house-keeping - remove JRubyServer --- test/integration_helper.rb | 54 +------------------------------------- 1 file changed, 1 insertion(+), 53 deletions(-) diff --git a/test/integration_helper.rb b/test/integration_helper.rb index 0e81e65db2..5bdaa5d385 100644 --- a/test/integration_helper.rb +++ b/test/integration_helper.rb @@ -105,59 +105,7 @@ def run_test(target, &block) end end - if RUBY_ENGINE == "jruby" - class JRubyServer < BaseServer - def start_vm - require 'java' - # Create a new container, set load paths and env - # SINGLETHREAD means create a new runtime - vm = org.jruby.embed.ScriptingContainer.new(org.jruby.embed.LocalContextScope::SINGLETHREAD) - vm.load_paths = [File.expand_path('../lib', __dir__)] - vm.environment = ENV.merge('APP_ENV' => environment.to_s) - - # This ensures processing of RUBYOPT which activates Bundler - vm.provider.ruby_instance_config.process_arguments [] - vm.argv = ['-s', server.to_s, '-o', '127.0.0.1', '-p', port.to_s, '-e', environment.to_s] - - # Set stdout/stderr so we can retrieve log - @pipe = java.io.ByteArrayOutputStream.new - vm.output = java.io.PrintStream.new(@pipe) - vm.error = java.io.PrintStream.new(@pipe) - - Thread.new do - # Hack to ensure that Kernel#caller has the same info as - # when run from command-line, for Sinatra::Application.app_file. - # Also, line numbers are zero-based in JRuby's parser - vm.provider.runtime.current_context.set_file_and_line(app_file, 0) - # Run the app - vm.run_scriptlet org.jruby.embed.PathType::ABSOLUTE, app_file - # terminate launches at_exit hooks which start server - vm.terminate - end - end - - def run - return unless installed? - kill - @thread = start_vm - @started = Time.now - warn "#{server} up and running on port #{port}" if ping - at_exit { kill } - end - - def log - String.from_java_bytes @pipe.to_byte_array - end - - def kill - @thread.kill if @thread - @thread = nil - end - end - Server = BaseServer - else - Server = BaseServer - end + Server = BaseServer def it(message, &block) Server.each do |server| From de98d5065a1413cfbda3ea97843d0005707040e2 Mon Sep 17 00:00:00 2001 From: kares Date: Mon, 21 Feb 2022 16:43:30 +0100 Subject: [PATCH 4/4] TODOed! :yay: --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e0a5139cac..0283e19295 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,6 @@ jobs: fail-fast: false matrix: # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0' - # TODO: Add jruby if something like allow_failures will be implemented on Actions. ruby: [2.6, 2.7, '3.0', 3.1, 'jruby-9.3'] steps: - uses: actions/checkout@v2