Skip to content

Commit a11b6d6

Browse files
aguspetitusfortner
andauthored
[rb] Add support for beta chrome (#15874)
* [build] allow tests tagged exclusive-if-local to run on rbe * Re-make of the beta-chrome support PR * Update heap size * Double heap size --------- Co-authored-by: titusfortner <titus.fortner@gmail.com>
1 parent d8b02c6 commit a11b6d6

File tree

8 files changed

+179
-60
lines changed

8 files changed

+179
-60
lines changed

MODULE.bazel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,13 +370,17 @@ use_repo(
370370
pin_browsers_extension = use_extension("//common:repositories.bzl", "pin_browsers_extension")
371371
use_repo(
372372
pin_browsers_extension,
373+
"linux_beta_chrome",
374+
"linux_beta_chromedriver",
373375
"linux_beta_firefox",
374376
"linux_chrome",
375377
"linux_chromedriver",
376378
"linux_edge",
377379
"linux_edgedriver",
378380
"linux_firefox",
379381
"linux_geckodriver",
382+
"mac_beta_chrome",
383+
"mac_beta_chromedriver",
380384
"mac_beta_firefox",
381385
"mac_chrome",
382386
"mac_chromedriver",

common/browsers.bzl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,25 @@ firefox_beta_data = select({
8383
],
8484
"//conditions:default": [],
8585
}) + geckodriver_data
86+
87+
chromedriver_beta_data = select({
88+
"@selenium//common:use_pinned_linux_chrome": [
89+
"@linux_beta_chromedriver//:chromedriver",
90+
],
91+
"@selenium//common:use_pinned_macos_chrome": [
92+
"@mac_beta_chromedriver//:chromedriver",
93+
],
94+
"@selenium//common:use_local_chromedriver": ["@selenium//common:chromedriver"],
95+
"//conditions:default": [],
96+
})
97+
98+
chrome_beta_data = select({
99+
"@selenium//common:use_pinned_linux_chrome": [
100+
"@linux_beta_chrome//:files",
101+
"@linux_beta_chrome//:chrome-linux64/chrome",
102+
],
103+
"@selenium//common:use_pinned_macos_chrome": [
104+
"@mac_beta_chrome//:Chrome.app",
105+
],
106+
"//conditions:default": [],
107+
}) + chromedriver_beta_data

common/repositories.bzl

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ js_library(
218218
)
219219
""",
220220
)
221-
222221
http_archive(
223222
name = "mac_chrome",
224223
url = "https://storage.googleapis.com/chrome-for-testing-public/137.0.7151.70/mac-x64/chrome-mac-x64.zip",
@@ -240,7 +239,6 @@ js_library(
240239
)
241240
""",
242241
)
243-
244242
http_archive(
245243
name = "linux_chromedriver",
246244
url = "https://storage.googleapis.com/chrome-for-testing-public/137.0.7151.70/linux64/chromedriver-linux64.zip",
@@ -270,6 +268,84 @@ package(default_visibility = ["//visibility:public"])
270268
271269
exports_files(["chromedriver"])
272270
271+
js_library(
272+
name = "chromedriver-js",
273+
data = ["chromedriver"],
274+
)
275+
""",
276+
)
277+
278+
http_archive(
279+
name = "linux_beta_chrome",
280+
url = "https://storage.googleapis.com/chrome-for-testing-public/138.0.7204.15/linux64/chrome-linux64.zip",
281+
sha256 = "e4bb8769b613eacd7cc40e48f3f63d96de9e9ee642360b4a79bedd502291c544",
282+
build_file_content = """
283+
load("@aspect_rules_js//js:defs.bzl", "js_library")
284+
package(default_visibility = ["//visibility:public"])
285+
286+
filegroup(
287+
name = "files",
288+
srcs = glob(["**/*"]),
289+
)
290+
291+
exports_files(["chrome-linux64/chrome"])
292+
293+
js_library(
294+
name = "chrome-js",
295+
data = [":files"],
296+
)
297+
""",
298+
)
299+
http_archive(
300+
name = "mac_beta_chrome",
301+
url = "https://storage.googleapis.com/chrome-for-testing-public/138.0.7204.15/mac-x64/chrome-mac-x64.zip",
302+
sha256 = "46dbfe39930cd3a2a45bc85a70bb49c291c258fde5be4d3d4deecc8e3181ae2f",
303+
strip_prefix = "chrome-mac-x64",
304+
patch_cmds = [
305+
"mv 'Google Chrome for Testing.app' Chrome.app",
306+
"mv 'Chrome.app/Contents/MacOS/Google Chrome for Testing' Chrome.app/Contents/MacOS/Chrome",
307+
],
308+
build_file_content = """
309+
load("@aspect_rules_js//js:defs.bzl", "js_library")
310+
package(default_visibility = ["//visibility:public"])
311+
312+
exports_files(["Chrome.app"])
313+
314+
js_library(
315+
name = "chrome-js",
316+
data = glob(["Chrome.app/**/*"]),
317+
)
318+
""",
319+
)
320+
http_archive(
321+
name = "linux_beta_chromedriver",
322+
url = "https://storage.googleapis.com/chrome-for-testing-public/138.0.7204.15/linux64/chromedriver-linux64.zip",
323+
sha256 = "b180e7569aa10a10e5b112b2b6cc21d126499122eaba0e90d264713285cc9104",
324+
strip_prefix = "chromedriver-linux64",
325+
build_file_content = """
326+
load("@aspect_rules_js//js:defs.bzl", "js_library")
327+
package(default_visibility = ["//visibility:public"])
328+
329+
exports_files(["chromedriver"])
330+
331+
js_library(
332+
name = "chromedriver-js",
333+
data = ["chromedriver"],
334+
)
335+
""",
336+
)
337+
338+
http_archive(
339+
name = "mac_beta_chromedriver",
340+
url = "https://storage.googleapis.com/chrome-for-testing-public/138.0.7204.15/mac-x64/chromedriver-mac-x64.zip",
341+
sha256 = "fda50dbab46115e2185cae0f3eeb8526c3f95175b0d4f7f7871aaf1e63590d5c",
342+
strip_prefix = "chromedriver-mac-x64",
343+
build_file_content = """
344+
load("@aspect_rules_js//js:defs.bzl", "js_library")
345+
package(default_visibility = ["//visibility:public"])
346+
347+
exports_files(["chromedriver"])
348+
273349
js_library(
274350
name = "chromedriver-js",
275351
data = ["chromedriver"],

rb/spec/integration/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package(default_visibility = ["//rb/spec/integration:__subpackages__"])
22

33
BROWSERS = [
44
"chrome",
5+
"chrome-beta",
56
"edge",
67
"firefox",
78
"ie",

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ load("//rb/spec:tests.bzl", "rb_integration_test")
44
rb_integration_test(
55
name = file[:-8],
66
srcs = [file],
7-
browsers = ["chrome"], # No need to run in other browsers.
7+
# No need to run in other browsers.
8+
browsers = [
9+
"chrome",
10+
"chrome-beta",
11+
],
12+
data = ["//common/extensions"],
813
)
914
for file in glob(["*_spec.rb"])
1015
]

rb/spec/tests.bzl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ load("@rules_ruby//ruby:defs.bzl", "rb_library", "rb_test")
22
load(
33
"//common:browsers.bzl",
44
"COMMON_TAGS",
5+
"chrome_beta_data",
56
"chrome_data",
67
"edge_data",
78
"firefox_beta_data",
@@ -32,6 +33,30 @@ BROWSERS = {
3233
"//conditions:default": {},
3334
}),
3435
},
36+
"chrome-beta": {
37+
"data": chrome_beta_data,
38+
"deps": ["//rb/lib/selenium/webdriver:chrome"],
39+
"tags": [],
40+
"target_compatible_with": [],
41+
"env": {
42+
"WD_REMOTE_BROWSER": "chrome",
43+
"WD_SPEC_DRIVER": "chrome",
44+
"WD_BROWSER_VERSION": "beta",
45+
} | select({
46+
"@selenium//common:use_pinned_linux_chrome": {
47+
"CHROME_BINARY": "$(location @linux_beta_chrome//:chrome-linux64/chrome)",
48+
"CHROMEDRIVER_BINARY": "$(location @linux_beta_chromedriver//:chromedriver)",
49+
},
50+
"@selenium//common:use_pinned_macos_chrome": {
51+
"CHROME_BINARY": "$(location @mac_beta_chrome//:Chrome.app)/Contents/MacOS/Chrome",
52+
"CHROMEDRIVER_BINARY": "$(location @mac_beta_chromedriver//:chromedriver)",
53+
},
54+
"//conditions:default": {},
55+
}) | select({
56+
"@selenium//common:use_headless_browser": {"HEADLESS": "true"},
57+
"//conditions:default": {},
58+
}),
59+
},
3560
"edge": {
3661
"data": edge_data,
3762
"deps": ["//rb/lib/selenium/webdriver:edge"],

scripts/github-actions/ci-build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -eufo pipefail
55
set -x
66

77
# Define heap size for GitHub Actions runner
8-
HEAP_SIZE="-Xmx4g"
8+
HEAP_SIZE="-Xmx8g"
99

1010
# Default to auto if no parameter is provided
1111
CACHE_RESULTS="auto"

scripts/pinned_browsers.py

Lines changed: 42 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python
22

3-
import argparse
43
import hashlib
54
import json
65
import os
@@ -26,14 +25,7 @@ def calculate_hash(url):
2625
return h.hexdigest()
2726

2827

29-
def get_chrome_milestone():
30-
parser = argparse.ArgumentParser()
31-
parser.add_argument(
32-
"--chrome_channel", default="Stable", help="Set the Chrome channel"
33-
)
34-
args = parser.parse_args()
35-
channel = args.chrome_channel
36-
28+
def get_chrome_info_for_channel(channel):
3729
r = http.request(
3830
"GET",
3931
f"https://chromiumdash.appspot.com/fetch_releases?channel={channel}&num=1&platform=Mac,Linux",
@@ -55,20 +47,18 @@ def get_chrome_milestone():
5547
)[-1]
5648

5749

58-
def chromedriver(selected_version):
50+
def chromedriver(selected_version, workspace_prefix=""):
5951
content = ""
6052

6153
drivers = selected_version["downloads"]["chromedriver"]
6254

63-
linux = [d["url"] for d in drivers if d["platform"] == "linux64"][0]
64-
sha = calculate_hash(linux)
55+
url = [d["url"] for d in drivers if d["platform"] == "linux64"][0]
56+
sha = calculate_hash(url)
6557

66-
content = (
67-
content
68-
+ """ http_archive(
69-
name = "linux_chromedriver",
70-
url = "%s",
71-
sha256 = "%s",
58+
content += f""" http_archive(
59+
name = "linux_{workspace_prefix}chromedriver",
60+
url = "{url}",
61+
sha256 = "{sha}",
7262
strip_prefix = "chromedriver-linux64",
7363
build_file_content = \"\"\"
7464
load("@aspect_rules_js//js:defs.bzl", "js_library")
@@ -83,18 +73,15 @@ def chromedriver(selected_version):
8373
\"\"\",
8474
)
8575
"""
86-
% (linux, sha)
87-
)
8876

89-
mac = [d["url"] for d in drivers if d["platform"] == "mac-x64"][0]
90-
sha = calculate_hash(mac)
91-
content = (
92-
content
93-
+ """
77+
url = [d["url"] for d in drivers if d["platform"] == "mac-x64"][0]
78+
sha = calculate_hash(url)
79+
80+
content += f"""
9481
http_archive(
95-
name = "mac_chromedriver",
96-
url = "%s",
97-
sha256 = "%s",
82+
name = "mac_{workspace_prefix}chromedriver",
83+
url = "{url}",
84+
sha256 = "{sha}",
9885
strip_prefix = "chromedriver-mac-x64",
9986
build_file_content = \"\"\"
10087
load("@aspect_rules_js//js:defs.bzl", "js_library")
@@ -109,23 +96,22 @@ def chromedriver(selected_version):
10996
\"\"\",
11097
)
11198
"""
112-
% (mac, sha)
113-
)
11499

115100
return content
116101

117102

118-
def chrome(selected_version):
103+
def chrome(selected_version, workspace_prefix=""):
104+
content = ""
119105
chrome_downloads = selected_version["downloads"]["chrome"]
120106

121-
linux = [d["url"] for d in chrome_downloads if d["platform"] == "linux64"][0]
122-
sha = calculate_hash(linux)
107+
url = [d["url"] for d in chrome_downloads if d["platform"] == "linux64"][0]
108+
sha = calculate_hash(url)
123109

124-
content = """
110+
content += f"""
125111
http_archive(
126-
name = "linux_chrome",
127-
url = "%s",
128-
sha256 = "%s",
112+
name = "linux_{workspace_prefix}chrome",
113+
url = "{url}",
114+
sha256 = "{sha}",
129115
build_file_content = \"\"\"
130116
load("@aspect_rules_js//js:defs.bzl", "js_library")
131117
package(default_visibility = ["//visibility:public"])
@@ -143,19 +129,15 @@ def chrome(selected_version):
143129
)
144130
\"\"\",
145131
)
132+
"""
146133

147-
""" % (
148-
linux,
149-
sha,
150-
)
151-
152-
mac = [d["url"] for d in chrome_downloads if d["platform"] == "mac-x64"][0]
153-
sha = calculate_hash(mac)
134+
url = [d["url"] for d in chrome_downloads if d["platform"] == "mac-x64"][0]
135+
sha = calculate_hash(url) # Calculate SHA for Mac chrome
154136

155-
content += """ http_archive(
156-
name = "mac_chrome",
157-
url = "%s",
158-
sha256 = "%s",
137+
content += f""" http_archive(
138+
name = "mac_{workspace_prefix}chrome",
139+
url = "{url}",
140+
sha256 = "{sha}",
159141
strip_prefix = "chrome-mac-x64",
160142
patch_cmds = [
161143
"mv 'Google Chrome for Testing.app' Chrome.app",
@@ -173,11 +155,7 @@ def chrome(selected_version):
173155
)
174156
\"\"\",
175157
)
176-
177-
""" % (
178-
mac,
179-
sha,
180-
)
158+
"""
181159

182160
return content
183161

@@ -522,9 +500,17 @@ def pin_browsers():
522500
content = content + geckodriver()
523501
content = content + edge()
524502
content = content + edgedriver()
525-
chrome_milestone = get_chrome_milestone()
526-
content = content + chrome(chrome_milestone)
527-
content = content + chromedriver(chrome_milestone)
503+
504+
# Stable Chrome
505+
stable_chrome_info = get_chrome_info_for_channel(channel="Stable")
506+
content = content + chrome(stable_chrome_info, workspace_prefix="")
507+
content = content + chromedriver(stable_chrome_info, workspace_prefix="")
508+
509+
# Beta Chrome
510+
beta_chrome_info = get_chrome_info_for_channel(channel="Beta")
511+
content = content + chrome(beta_chrome_info, workspace_prefix="beta_")
512+
content = content + chromedriver(beta_chrome_info, workspace_prefix="beta_")
513+
528514
content += """
529515
def _pin_browsers_extension_impl(_ctx):
530516
pin_browsers()

0 commit comments

Comments
 (0)