diff --git a/.github/workflows/ci-ruby.yml b/.github/workflows/ci-ruby.yml index deb56b656f4c0..653034f947f45 100644 --- a/.github/workflows/ci-ruby.yml +++ b/.github/workflows/ci-ruby.yml @@ -87,11 +87,6 @@ jobs: os: ubuntu - browser: safari os: windows - # TODO: Investigate why they are timing out - - browser: chrome - os: windows - - browser: edge - os: windows with: name: Local Tests (${{ matrix.browser }}, ${{ matrix.os }}) browser: ${{ matrix.browser }} diff --git a/MODULE.bazel b/MODULE.bazel index 2e2bfbda40af5..d8249a99f7121 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -12,7 +12,7 @@ bazel_dep(name = "contrib_rules_jvm", version = "0.24.0") bazel_dep(name = "platforms", version = "0.0.8") bazel_dep(name = "rules_dotnet", version = "0.14.0") bazel_dep(name = "rules_java", version = "7.4.0") -bazel_dep(name = "rules_jvm_external", version = "6.0") +bazel_dep(name = "rules_jvm_external", version = "6.1") bazel_dep(name = "rules_nodejs", version = "6.0.5") bazel_dep(name = "rules_oci", version = "1.0.0") bazel_dep(name = "rules_pkg", version = "0.9.1") @@ -124,16 +124,6 @@ use_repo(pip, "py_dev_requirements") register_toolchains("@pythons_hub//:all") -# https://github.com/bazelbuild/rules_jvm_external/pull/1079 -archive_override( - module_name = "rules_jvm_external", - integrity = "sha256-yS8Qes1PLbYbe10b1WSgl0Auqn/1Wlxg8O3wSr7a/Sg=", - patch_strip = 1, - patches = ["//java:rules_jvm_external_javadoc.patch"], - strip_prefix = "rules_jvm_external-f572a26116c7ef71d8842dd056c2605782f7be8d", - urls = ["https://github.com/bazelbuild/rules_jvm_external/archive/f572a26116c7ef71d8842dd056c2605782f7be8d.tar.gz"], -) - java_toolchains = use_extension("@rules_java//java:extensions.bzl", "toolchains") use_repo( java_toolchains, diff --git a/README.md b/README.md index d2b905c8108f9..6ebfda3fbf20f 100644 --- a/README.md +++ b/README.md @@ -370,7 +370,6 @@ Supported browsers: * `safari-preview` In addition to the [Common Options Examples](#common-options-examples), here are some additional Ruby specific ones: -* `--test_arg "-tfocus"` - test only [focused specs](https://relishapp.com/rspec/rspec-core/v/3-12/docs/filtering/inclusion-filters) * `--test_arg "-eTimeouts"` - test only specs which name include "Timeouts" * `--test_arg ""` - pass any extra RSpec arguments (see `bazel run @bundle//bin:rspec -- --help`) diff --git a/rb/lib/selenium/server.rb b/rb/lib/selenium/server.rb index 560bc4e851c16..7d031f26af07d 100644 --- a/rb/lib/selenium/server.rb +++ b/rb/lib/selenium/server.rb @@ -183,6 +183,7 @@ def download_server(uri, destination) def initialize(jar, opts = {}) raise Errno::ENOENT, jar unless File.exist?(jar) + @java = opts.fetch(:java, 'java') @jar = jar @host = '127.0.0.1' @role = opts.fetch(:role, 'standalone') @@ -241,7 +242,7 @@ def process # extract any additional_args that start with -D as options properties = @additional_args.dup - @additional_args.delete_if { |arg| arg[/^-D/] } args = ['-jar', @jar, @role, '--port', @port.to_s] - server_command = ['java'] + properties + args + @additional_args + server_command = [@java] + properties + args + @additional_args cp = WebDriver::ChildProcess.build(*server_command) if @log.is_a?(String) diff --git a/rb/spec/BUILD.bazel b/rb/spec/BUILD.bazel index 57d8b4fecaa72..b2e2f82f1d024 100644 --- a/rb/spec/BUILD.bazel +++ b/rb/spec/BUILD.bazel @@ -117,3 +117,12 @@ rb_library( "//rb/spec/unit/selenium/webdriver/support:select", ], ) + +genrule( + name = "java-location", + srcs = [], + outs = ["java-location"], + cmd = "echo $(JAVA) > $@", + toolchains = ["@bazel_tools//tools/jdk:current_java_runtime"], + visibility = ["//rb/spec:__subpackages__"], +) diff --git a/rb/spec/integration/selenium/webdriver/spec_helper.rb b/rb/spec/integration/selenium/webdriver/spec_helper.rb index 013bd8c65c791..bf0a507577ef1 100644 --- a/rb/spec/integration/selenium/webdriver/spec_helper.rb +++ b/rb/spec/integration/selenium/webdriver/spec_helper.rb @@ -45,7 +45,9 @@ GlobalTestEnv.quit_driver end - c.filter_run focus: true if ENV['focus'] + c.filter_run_when_matching :focus + c.run_all_when_everything_filtered = true + c.default_formatter = c.files_to_run.count > 1 ? 'progress' : 'doc' c.before do |example| guards = WebDriver::Support::Guards.new(example, bug_tracker: 'https://github.com/SeleniumHQ/selenium/issues') diff --git a/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb b/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb index 49c29177b0d1b..f1864b587dfa3 100644 --- a/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb +++ b/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb @@ -87,6 +87,7 @@ def app_server def remote_server @remote_server ||= Selenium::Server.new( remote_server_jar, + java: bazel_java, port: random_port, log_level: WebDriver.logger.debug? && 'FINE', background: true, @@ -95,6 +96,12 @@ def remote_server ) end + def bazel_java + return unless ENV.key?('WD_BAZEL_JAVA_LOCATION') + + File.expand_path(File.read(File.expand_path(ENV.fetch('WD_BAZEL_JAVA_LOCATION'))).chomp) + end + def reset_remote_server @remote_server&.stop @remote_server = nil @@ -243,7 +250,6 @@ def safari_preview_driver(**opts) def chrome_options(args: [], **opts) opts[:binary] ||= ENV['CHROME_BINARY'] if ENV.key?('CHROME_BINARY') args << '--headless=chrome' if ENV['HEADLESS'] - args << '--no-sandbox' args << '--disable-gpu' WebDriver::Options.chrome(browser_version: 'stable', args: args, **opts) end @@ -251,7 +257,6 @@ def chrome_options(args: [], **opts) def edge_options(args: [], **opts) opts[:binary] ||= ENV['EDGE_BINARY'] if ENV.key?('EDGE_BINARY') args << '--headless=chrome' if ENV['HEADLESS'] - args << '--no-sandbox' args << '--disable-gpu' WebDriver::Options.edge(browser_version: 'stable', args: args, **opts) end diff --git a/rb/spec/integration/selenium/webdriver/window_spec.rb b/rb/spec/integration/selenium/webdriver/window_spec.rb index 3b820f801be75..5d01db255da4a 100644 --- a/rb/spec/integration/selenium/webdriver/window_spec.rb +++ b/rb/spec/integration/selenium/webdriver/window_spec.rb @@ -124,8 +124,7 @@ module WebDriver expect(new_size.height).to be > old_size.height end - it 'can minimize the window', except: [{browser: %i[chrome edge], headless: true}, - {browser: :safari, ci: :github}], + it 'can minimize the window', except: [{browser: %i[chrome edge], headless: true}], flaky: {browser: :chrome, platform: %i[macosx linux], ci: :github} do window.minimize expect { diff --git a/rb/spec/tests.bzl b/rb/spec/tests.bzl index 809d62c714fd2..44b477c74d275 100644 --- a/rb/spec/tests.bzl +++ b/rb/spec/tests.bzl @@ -174,8 +174,13 @@ def rb_integration_test(name, srcs, deps = [], data = [], browsers = BROWSERS.ke data = BROWSERS[browser]["data"] + data + [ "//common/src/web", "//java/src/org/openqa/selenium/grid:selenium_server_deploy.jar", + "//rb/spec:java-location", + "@bazel_tools//tools/jdk:current_java_runtime", ], - env = BROWSERS[browser]["env"] | {"WD_SPEC_DRIVER": "remote"}, + env = BROWSERS[browser]["env"] | { + "WD_SPEC_DRIVER": "remote", + "WD_BAZEL_JAVA_LOCATION": "$(rootpath //rb/spec:java-location)", + }, main = "@bundle//bin:rspec", tags = COMMON_TAGS + BROWSERS[browser]["tags"] + tags + [ "{}-remote".format(browser), diff --git a/rb/spec/unit/selenium/webdriver/spec_helper.rb b/rb/spec/unit/selenium/webdriver/spec_helper.rb index 94badd92264e5..cb6cf23d9b00d 100644 --- a/rb/spec/unit/selenium/webdriver/spec_helper.rb +++ b/rb/spec/unit/selenium/webdriver/spec_helper.rb @@ -58,7 +58,9 @@ def with_env(hash) c.include Selenium::WebDriver::UnitSpecHelper - c.filter_run focus: true if ENV['focus'] + c.filter_run_when_matching :focus + c.run_all_when_everything_filtered = true + c.default_formatter = c.files_to_run.count > 1 ? 'progress' : 'doc' c.before do # https://github.com/ruby/debug/issues/797