Skip to content

Commit 67490a3

Browse files
committed
[rb] Update rules_ruby and run unit tests on RBE
This commit upgrades Ruby ruleset for Bazel to the most recent version, which notably provides a hermetic Bundle installation and allows to use JRuby with RBE environment. Right now not all tests can be used with RBE, so more commits are to land adding them one-by-one.
1 parent 6127b5f commit 67490a3

File tree

32 files changed

+203
-54
lines changed

32 files changed

+203
-54
lines changed

.bazelrc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ test --test_env=PYTHON_VERSION
6262

6363
test --test_env=RUBYOPT="-Irb/lib -w"
6464

65+
# Speed up JRuby startup.
66+
# https://github.com/jruby/jruby/wiki/Improving-startup-time
67+
68+
build --action_env=JRUBY_OPTS="--dev"
69+
test --test_env=JRUBY_OPTS="--dev"
70+
6571
# JRuby/TruffleRuby: https://github.com/jruby/jruby/issues/5661
6672

6773
build --action_env=HOME
@@ -76,7 +82,7 @@ test:windows --test_env=PROGRAMFILES(X86)="C:\\Program Files (x86)"
7682
test --test_timeout=1800
7783

7884
test:node_debug --test_output=streamed --test_strategy=exclusive --test_timeout=9999 --nocache_test_results
79-
test:ruby_debug --test_output=streamed --test_env=RUBY_DEBUG_FORK_MODE=parent --run_under="@bundle//:bin/rdbg --nonstop --open --command"
85+
test:ruby_debug --test_output=streamed --test_env=RUBY_DEBUG_FORK_MODE=parent --run_under="@bundle//bin:rdbg --nonstop --open --command"
8086

8187
# The RBE to use
8288
build:remote --bes_results_url=https://gypsum.cluster.engflow.com/invocation

.github/workflows/bazel.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ jobs:
9393
crates: rust/Cargo.Bazel.lock
9494
npm: package-lock.json
9595
pypi__pip: py/requirements_lock.txt
96-
rules_ruby_dist: rb/ruby_version.bzl
96+
ruby: rb/.ruby_version
9797
repository-cache: true
9898
- name: Setup Fluxbox and Xvfb
9999
if: inputs.os == 'ubuntu' && inputs.browser != ''

.github/workflows/ci-rbe.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ jobs:
1414
with:
1515
name: Check format script run
1616
cache-key: rbe
17-
ruby-version: jruby-9.4.2.0
17+
ruby-version: jruby-9.4.5.0
1818
run: ./scripts/github-actions/check-format.sh
19+
1920
test:
2021
name: Test
2122
uses: ./.github/workflows/bazel.yml
2223
with:
2324
# TODO: experiment with turning off caches
2425
name: All RBE tests
2526
cache-key: rbe
26-
ruby-version: jruby-9.4.2.0
27+
ruby-version: jruby-9.4.5.0
2728
run: ./scripts/github-actions/ci-build.sh

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ Useful command line options:
362362
In addition to the [Common Options Examples](#common-options-examples), here are some additional Ruby specific ones:
363363
* `--test_arg "-tfocus"` - test only [focused specs](https://relishapp.com/rspec/rspec-core/v/3-12/docs/filtering/inclusion-filters)
364364
* `--test_arg "-eTimeouts"` - test only specs which name include "Timeouts"
365-
* `--test_arg "<any other RSpec argument>"` - pass any extra RSpec arguments (see `bazel run @bundle//:bin/rspec -- --help`)
365+
* `--test_arg "<any other RSpec argument>"` - pass any extra RSpec arguments (see `bazel run @bundle//bin:rspec -- --help`)
366366

367367
Supported environment variables for use with `--test_env`:
368368

WORKSPACE

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,20 +331,22 @@ pin_browsers()
331331

332332
http_archive(
333333
name = "rules_ruby",
334-
sha256 = "e3495d0129222572654cc5dd5c72c6c997513d65fb8649f43a860ab15334a1c2",
335-
strip_prefix = "rules_ruby-0.4.1",
336-
url = "https://github.com/bazel-contrib/rules_ruby/releases/download/v0.4.1/rules_ruby-v0.4.1.tar.gz",
334+
sha256 = "9bfab76e1272dae72355c65cc858ede68b659716381485baa4c8e7a70ddc38a6",
335+
strip_prefix = "rules_ruby-0.5.0",
336+
url = "https://github.com/bazel-contrib/rules_ruby/releases/download/v0.5.0/rules_ruby-v0.5.0.tar.gz",
337337
)
338338

339339
load(
340340
"@rules_ruby//ruby:deps.bzl",
341-
"rb_bundle",
341+
"rb_bundle_fetch",
342342
"rb_register_toolchains",
343343
)
344344

345-
rb_register_toolchains(version_file = "//:rb/.ruby-version")
345+
rb_register_toolchains(
346+
version_file = "//:rb/.ruby-version",
347+
)
346348

347-
rb_bundle(
349+
rb_bundle_fetch(
348350
name = "bundle",
349351
srcs = [
350352
"//:rb/lib/selenium/devtools/version.rb",
@@ -353,6 +355,7 @@ rb_bundle(
353355
"//:rb/selenium-webdriver.gemspec",
354356
],
355357
gemfile = "//:rb/Gemfile",
358+
gemfile_lock = "//:rb/Gemfile.lock",
356359
)
357360

358361
http_archive(

rb/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ rb_binary(
163163
"--readme=rb/README.md",
164164
"rb/",
165165
],
166-
main = "@bundle//:bin/yard",
166+
main = "@bundle//bin:yard",
167167
deps = [
168168
":selenium-devtools",
169169
":selenium-webdriver",
@@ -180,7 +180,7 @@ rb_test(
180180
"rb/",
181181
],
182182
data = [".rubocop.yml"],
183-
main = "@bundle//:bin/rubocop",
183+
main = "@bundle//bin:rubocop",
184184
tags = ["no-sandbox"],
185185
deps = [
186186
":selenium-devtools",
@@ -199,7 +199,7 @@ rb_binary(
199199
"-rselenium/devtools",
200200
"-Irb/lib",
201201
],
202-
main = "@bundle//:bin/irb",
202+
main = "@bundle//bin:irb",
203203
deps = [
204204
":selenium-devtools",
205205
":selenium-webdriver",

rb/selenium-devtools.gemspec

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# frozen_string_literal: true
22

33
root = File.realpath(File.dirname(__FILE__))
4-
raise "cwd must be #{root} when reading gemspec" if root != Dir.pwd
5-
64
$LOAD_PATH.push(File.expand_path('lib', root))
75
require 'selenium/devtools/version'
86

rb/selenium-webdriver.gemspec

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# frozen_string_literal: true
22

33
root = File.expand_path(File.dirname(__FILE__))
4-
raise "cwd must be #{root} when reading gemspec" if root != Dir.pwd
5-
64
$LOAD_PATH.push(File.expand_path('lib', root))
75
require 'selenium/webdriver/version'
86

rb/spec/BUILD.bazel

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
load("@rules_ruby//ruby:defs.bzl", "rb_library")
22

3+
rb_library(
4+
name = "rspec_matchers",
5+
testonly = True,
6+
srcs = ["rspec_matchers.rb"],
7+
visibility = ["//rb/spec:__subpackages__"],
8+
)
9+
310
# List of dependencies can be gathered by running:
411
# bazel query 'kind("rb_.* rule", //rb/spec/...) except //rb/spec:spec' | xargs -I{} echo '"{}",'
512

613
rb_library(
714
name = "spec",
815
testonly = True,
9-
srcs = ["rspec_matchers.rb"],
1016
visibility = ["//rb:__pkg__"],
1117
deps = [
18+
":rspec_matchers",
1219
"//rb/spec/integration/selenium/webdriver:action_builder",
1320
"//rb/spec/integration/selenium/webdriver:bidi",
1421
"//rb/spec/integration/selenium/webdriver:devtools",

rb/spec/integration/selenium/webdriver/BUILD.bazel

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ package(default_visibility = ["//rb:__subpackages__"])
66
rb_library(
77
name = "spec_helper",
88
testonly = True,
9-
srcs = glob([
9+
srcs = [
1010
"spec_helper.rb",
1111
"spec_support.rb",
12-
"spec_support/**/*",
13-
]),
12+
] + glob(["spec_support/**/*"]),
1413
data = [
1514
"//rb:manager-linux",
1615
"//rb:manager-macos",
@@ -19,7 +18,24 @@ rb_library(
1918
"//rb/spec/integration:remote": ["//java/src/org/openqa/selenium/grid:selenium_server_deploy.jar"],
2019
"//conditions:default": [],
2120
}),
22-
deps = ["@bundle"],
21+
deps = [
22+
"//rb/lib:selenium-webdriver",
23+
"//rb/lib/selenium:devtools",
24+
"//rb/lib/selenium:server",
25+
"//rb/lib/selenium:webdriver",
26+
"//rb/lib/selenium/webdriver:atoms",
27+
"//rb/lib/selenium/webdriver:common",
28+
"//rb/lib/selenium/webdriver:remote",
29+
"//rb/spec:rspec_matchers",
30+
"@bundle",
31+
] + select({
32+
"//rb/spec/integration:edge": ["//rb/lib/selenium/webdriver:edge"],
33+
"//rb/spec/integration:firefox": ["//rb/lib/selenium/webdriver:firefox"],
34+
"//rb/spec/integration:ie": ["//rb/lib/selenium/webdriver:ie"],
35+
"//rb/spec/integration:safari": ["//rb/lib/selenium/webdriver:safari"],
36+
"//rb/spec/integration:safari-preview": ["//rb/lib/selenium/webdriver:safari"],
37+
"//conditions:default": ["//rb/lib/selenium/webdriver:chrome"],
38+
}),
2339
)
2440

2541
[
@@ -29,7 +45,7 @@ rb_library(
2945
srcs = [file],
3046
args = ["rb/spec/"],
3147
env = ENV,
32-
main = "@bundle//:bin/rspec",
48+
main = "@bundle//bin:rspec",
3349
tags = TAGS,
3450
deps = [
3551
":spec_helper",
@@ -53,7 +69,7 @@ rb_test(
5369
srcs = ["bidi_spec.rb"],
5470
args = ["rb/spec/"],
5571
env = ENV,
56-
main = "@bundle//:bin/rspec",
72+
main = "@bundle//bin:rspec",
5773
tags = TAGS + ["exclusive-if-local"],
5874
deps = [
5975
":spec_helper",
@@ -68,7 +84,7 @@ rb_test(
6884
srcs = ["devtools_spec.rb"],
6985
args = ["rb/spec/"],
7086
env = ENV,
71-
main = "@bundle//:bin/rspec",
87+
main = "@bundle//bin:rspec",
7288
tags = TAGS + ["exclusive-if-local"],
7389
deps = [
7490
":spec_helper",
@@ -83,7 +99,7 @@ rb_test(
8399
srcs = ["driver_spec.rb"],
84100
args = ["rb/spec/"],
85101
env = ENV,
86-
main = "@bundle//:bin/rspec",
102+
main = "@bundle//bin:rspec",
87103
tags = TAGS,
88104
deps = [
89105
":spec_helper",
@@ -102,7 +118,7 @@ rb_test(
102118
srcs = ["element_spec.rb"],
103119
args = ["rb/spec/"],
104120
env = ENV,
105-
main = "@bundle//:bin/rspec",
121+
main = "@bundle//bin:rspec",
106122
tags = TAGS,
107123
deps = [
108124
":spec_helper",

rb/spec/integration/selenium/webdriver/bidi/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ package(default_visibility = ["//rb:__subpackages__"])
1010
srcs = [file],
1111
args = ["rb/spec/"],
1212
env = ENV,
13-
main = "@bundle//:bin/rspec",
13+
main = "@bundle//bin:rspec",
1414
tags = TAGS + ["exclusive-if-local"],
1515
deps = [
1616
"//rb/lib/selenium/devtools",

rb/spec/integration/selenium/webdriver/chrome/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ package(default_visibility = ["//rb:__subpackages__"])
1010
srcs = [file],
1111
args = ["rb/spec/"],
1212
env = ENV,
13-
main = "@bundle//:bin/rspec",
13+
main = "@bundle//bin:rspec",
1414
tags = TAGS,
1515
deps = [
1616
"//rb/lib/selenium/webdriver:chrome",

rb/spec/integration/selenium/webdriver/edge/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ package(default_visibility = ["//rb:__subpackages__"])
1010
srcs = [file],
1111
args = ["rb/spec/"],
1212
env = ENV,
13-
main = "@bundle//:bin/rspec",
13+
main = "@bundle//bin:rspec",
1414
tags = TAGS,
1515
deps = [
1616
"//rb/lib/selenium/webdriver:edge",

rb/spec/integration/selenium/webdriver/firefox/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ package(default_visibility = ["//rb:__subpackages__"])
1010
srcs = [file],
1111
args = ["rb/spec/"],
1212
env = ENV,
13-
main = "@bundle//:bin/rspec",
13+
main = "@bundle//bin:rspec",
1414
tags = TAGS,
1515
deps = [
1616
"//rb/lib/selenium/webdriver:firefox",

rb/spec/integration/selenium/webdriver/remote/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ package(default_visibility = ["//rb:__subpackages__"])
1010
srcs = [file],
1111
args = ["rb/spec/"],
1212
env = ENV,
13-
main = "@bundle//:bin/rspec",
13+
main = "@bundle//bin:rspec",
1414
tags = TAGS,
1515
deps = [
1616
"//rb/lib/selenium/webdriver:remote",

rb/spec/integration/selenium/webdriver/safari/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ package(default_visibility = ["//rb:__subpackages__"])
1010
srcs = [file],
1111
args = ["rb/spec/"],
1212
env = ENV,
13-
main = "@bundle//:bin/rspec",
13+
main = "@bundle//bin:rspec",
1414
tags = TAGS,
1515
deps = [
1616
"//rb/lib/selenium/webdriver:safari",

rb/spec/unit/selenium/BUILD.bazel

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ rb_test(
77
size = "small",
88
srcs = ["devtools_spec.rb"],
99
args = ["rb/spec/"],
10-
main = "@bundle//:bin/rspec",
10+
main = "@bundle//bin:rspec",
1111
tags = ["no-sandbox"],
1212
deps = [
13+
"//rb/lib:selenium-webdriver",
1314
"//rb/lib/selenium:devtools",
15+
"//rb/lib/selenium:webdriver",
16+
"//rb/lib/selenium/webdriver:atoms",
17+
"//rb/lib/selenium/webdriver:common",
1418
"@bundle",
1519
],
1620
)
@@ -20,10 +24,15 @@ rb_test(
2024
size = "small",
2125
srcs = ["server_spec.rb"],
2226
args = ["rb/spec/"],
23-
main = "@bundle//:bin/rspec",
27+
main = "@bundle//bin:rspec",
2428
tags = ["no-sandbox"],
2529
deps = [
30+
"//rb/lib:selenium-webdriver",
31+
"//rb/lib/selenium:devtools",
2632
"//rb/lib/selenium:server",
33+
"//rb/lib/selenium:webdriver",
34+
"//rb/lib/selenium/webdriver:atoms",
35+
"//rb/lib/selenium/webdriver:common",
2736
"@bundle",
2837
],
2938
)

rb/spec/unit/selenium/devtools/BUILD.bazel

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ rb_test(
77
size = "small",
88
srcs = ["cdp_client_generator_spec.rb"],
99
args = ["rb/spec/"],
10-
main = "@bundle//:bin/rspec",
10+
main = "@bundle//bin:rspec",
1111
tags = ["no-sandbox"],
1212
deps = [
13+
"//rb/lib:selenium-webdriver",
14+
"//rb/lib/selenium:webdriver",
1315
"//rb/lib/selenium/devtools:cdp-generate",
16+
"//rb/lib/selenium/webdriver:atoms",
17+
"//rb/lib/selenium/webdriver:common",
1418
"@bundle",
1519
],
1620
)

rb/spec/unit/selenium/webdriver/BUILD.bazel

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,27 @@ rb_library(
66
name = "spec_helper",
77
testonly = True,
88
srcs = ["spec_helper.rb"],
9-
deps = ["@bundle"],
9+
deps = [
10+
"//rb/lib:selenium-webdriver",
11+
"//rb/lib/selenium:webdriver",
12+
"//rb/lib/selenium/webdriver:atoms",
13+
"//rb/spec:rspec_matchers",
14+
"@bundle",
15+
],
16+
)
17+
18+
rb_test(
19+
name = "search_context",
20+
size = "small",
21+
srcs = ["search_context_spec.rb"],
22+
args = ["rb/spec/"],
23+
main = "@bundle//bin:rspec",
24+
tags = ["no-sandbox"],
25+
deps = [
26+
":spec_helper",
27+
"//rb/lib/selenium/webdriver:common",
28+
"//rb/lib/selenium/webdriver:remote",
29+
],
1030
)
1131

1232
[
@@ -15,12 +35,15 @@ rb_library(
1535
size = "small",
1636
srcs = [file],
1737
args = ["rb/spec/"],
18-
main = "@bundle//:bin/rspec",
38+
main = "@bundle//bin:rspec",
1939
tags = ["no-sandbox"],
2040
deps = [
2141
":spec_helper",
2242
"//rb/lib/selenium/webdriver:common",
2343
],
2444
)
25-
for file in glob(["*_spec.rb"])
45+
for file in glob(
46+
["*_spec.rb"],
47+
exclude = ["search_context_spec.rb"],
48+
)
2649
]

0 commit comments

Comments
 (0)