Skip to content

Commit 06519c9

Browse files
authored
[rb] Update rules_ruby to the latest version (#13235)
Notably, it now allows to read version from `.ruby-version` file and use a more convenient `run_binary()` rule instead of a `genrule()`. The commit also bumps supported Ruby versions on CI.
1 parent cc508fe commit 06519c9

File tree

10 files changed

+40
-40
lines changed

10 files changed

+40
-40
lines changed

.github/workflows/bazel.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ jobs:
7070
- name: Remove driver directories Non-Windows
7171
if: inputs.os != 'windows'
7272
run: |
73-
sudo rm -rf $CHROMEWEBDRIVER $EDGEWEBDRIVER $GECKOWEBDRIVER
73+
sudo rm -rf "$CHROMEWEBDRIVER" "$EDGEWEBDRIVER" "$GECKOWEBDRIVER"
7474
- name: Set Ruby version
7575
if: inputs.ruby-version != ''
76-
run: echo 'RUBY_VERSION = "${{ inputs.ruby-version }}"' > rb/ruby_version.bzl
76+
run: echo '${{ inputs.ruby-version }}' > rb/.ruby-version
7777
- name: Setup Java
7878
if: inputs.java-version != ''
7979
uses: actions/setup-java@v3
@@ -84,6 +84,7 @@ jobs:
8484
uses: p0deje/[email protected]
8585
with:
8686
bazelisk-cache: true
87+
bazelrc: common --color=yes
8788
disk-cache: ${{ inputs.cache-key }}
8889
external-cache: |
8990
name: ${{ inputs.cache-key }}
@@ -99,7 +100,7 @@ jobs:
99100
sudo apt-get -y install fluxbox
100101
Xvfb :99 &
101102
fluxbox -display :99 &
102-
echo "DISPLAY=:99" >> $GITHUB_ENV
103+
echo "DISPLAY=:99" >> "$GITHUB_ENV"
103104
- name: Set resolution
104105
if: inputs.os == 'windows' && inputs.browser != ''
105106
run: Set-DisplayResolution -Width 1920 -Height 1080 -Force

.github/workflows/ci-ruby.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ jobs:
4343
os: ubuntu
4444
- ruby-version: 3.0.6
4545
os: windows
46-
- ruby-version: 3.2.0
47-
os: ubuntu
48-
- ruby-version: 3.2.0
46+
- ruby-version: 3.0.6
4947
os: macos
50-
- ruby-version: jruby-9.4.3.0
48+
- ruby-version: 3.2.2
49+
os: ubuntu
50+
- ruby-version: jruby-9.4.5.0
5151
os: ubuntu
52-
- ruby-version: truffleruby-22.3.0
52+
- ruby-version: truffleruby-23.1.1
5353
os: ubuntu
5454
with:
5555
name: Unit Tests (${{ matrix.ruby-version }}, ${{ matrix.os }})

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ ipch/
9999
geckodriver.log
100100
ghostdriver.log
101101
.tags
102-
.ruby-version
103102
GPATH
104103
GRTAGS
105104
GSYMS

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,10 @@ Supported environment variables:
260260
- `EDGE_BINARY` - path to test specific Edge browser
261261
- `FIREFOX_BINARY` - path to test specific Firefox browser
262262

263-
To run with a specific version of Ruby you can change the version in `rb/ruby_version.bzl` or from command line:
263+
To run with a specific version of Ruby you can change the version in `rb/.ruby-version` or from command line:
264+
264265
```sh
265-
echo 'RUBY_VERSION = "<X.Y.Z>"' > rb/ruby_version.bzl
266+
echo '<X.Y.Z>' > rb/.ruby-version
266267
```
267268

268269
If you want to debug code in tests, you can do it via [`debug`](https://github.com/ruby/debug) gem:

WORKSPACE

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,19 +327,18 @@ pin_browsers()
327327

328328
http_archive(
329329
name = "rules_ruby",
330-
sha256 = "92055f29f94963cd3cf7be1da15503c3306879e2e8545b2b5f9e5bb37d6713d3",
331-
strip_prefix = "rules_ruby-0.2.0",
332-
url = "https://github.com/p0deje/rules_ruby/releases/download/v0.2.0/rules_ruby-v0.2.0.tar.gz",
330+
sha256 = "e3495d0129222572654cc5dd5c72c6c997513d65fb8649f43a860ab15334a1c2",
331+
strip_prefix = "rules_ruby-0.4.1",
332+
url = "https://github.com/bazel-contrib/rules_ruby/releases/download/v0.4.1/rules_ruby-v0.4.1.tar.gz",
333333
)
334334

335335
load(
336336
"@rules_ruby//ruby:deps.bzl",
337337
"rb_bundle",
338338
"rb_register_toolchains",
339339
)
340-
load("//rb:ruby_version.bzl", "RUBY_VERSION")
341340

342-
rb_register_toolchains(version = RUBY_VERSION)
341+
rb_register_toolchains(version_file = "//:rb/.ruby-version")
343342

344343
rb_bundle(
345344
name = "bundle",

rb/.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.0.6

rb/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ package(default_visibility = ["//:__subpackages__"])
1212

1313
GITHUB_PACKAGES_HOST = "https://rubygems.pkg.github.com/SeleniumHQ"
1414

15-
exports_files(["ruby_version.bzl"])
16-
1715
copy_file(
1816
name = "manager-linux",
1917
src = "//common/manager:selenium-manager-linux",

rb/Gemfile.lock

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,9 @@ GEM
4545
i18n (1.14.1)
4646
concurrent-ruby (~> 1.0)
4747
io-console (0.6.0)
48-
io-console (0.6.0-java)
4948
irb (1.9.0)
5049
rdoc
5150
reline (>= 0.3.8)
52-
jar-dependencies (0.4.1)
5351
json (2.6.3)
5452
json (2.6.3-java)
5553
language_server-protocol (3.17.0.3)
@@ -65,8 +63,6 @@ GEM
6563
racc
6664
psych (5.1.1.1)
6765
stringio
68-
psych (5.1.1.1-java)
69-
jar-dependencies (>= 0.1.7)
7066
public_suffix (5.0.4)
7167
racc (1.7.3)
7268
racc (1.7.3-java)

rb/lib/selenium/devtools/BUILD.bazel

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
load("@rules_ruby//ruby:defs.bzl", "rb_library")
1+
load("@bazel_skylib//rules:run_binary.bzl", "run_binary")
2+
load("@rules_ruby//ruby:defs.bzl", "rb_binary", "rb_library")
23

34
package(default_visibility = ["//rb:__subpackages__"])
45

@@ -20,30 +21,35 @@ rb_library(
2021
srcs = ["version.rb"],
2122
)
2223

23-
rb_library(
24+
rb_binary(
2425
name = "cdp-generate",
2526
srcs = ["support/cdp_client_generator.rb"],
26-
)
27-
28-
filegroup(
29-
name = "cdp-generate-file",
30-
srcs = ["support/cdp_client_generator.rb"],
27+
data = [
28+
"support/cdp/domain.rb.erb",
29+
"support/cdp/loader.rb.erb",
30+
],
31+
main = "support/cdp_client_generator.rb",
3132
)
3233

3334
[
34-
genrule(
35-
name = "cdp-" + n,
35+
run_binary(
36+
name = "cdp-" + version,
3637
srcs = [
37-
"//common/devtools/chromium/" + n + ":browser_protocol",
38-
"//common/devtools/chromium/" + n + ":js_protocol",
39-
":cdp-generate-file",
38+
"//common/devtools/chromium/" + version + ":browser_protocol",
39+
"//common/devtools/chromium/" + version + ":js_protocol",
4040
],
4141
outs = [
42-
n,
43-
n + ".rb",
42+
version,
43+
version + ".rb",
44+
],
45+
args = [
46+
"$(location //common/devtools/chromium/" + version + ":browser_protocol)",
47+
"$(location //common/devtools/chromium/" + version + ":js_protocol)",
48+
"$(location :" + version + ")/",
49+
"$(location :" + version + ".rb)",
50+
version,
4451
],
45-
cmd = "$(location @rules_ruby_dist//:ruby) $(location :cdp-generate-file) $(location //common/devtools/chromium/" + n + ":browser_protocol) $(location //common/devtools/chromium/" + n + ":js_protocol) $(OUTS) " + n,
46-
tools = ["@rules_ruby_dist//:ruby"],
52+
tool = ":cdp-generate",
4753
)
48-
for n in CDP_VERSIONS
54+
for version in CDP_VERSIONS
4955
]

rb/ruby_version.bzl

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)