Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -370,13 +370,17 @@ use_repo(
pin_browsers_extension = use_extension("//common:repositories.bzl", "pin_browsers_extension")
use_repo(
pin_browsers_extension,
"linux_beta_chrome",
"linux_beta_chromedriver",
"linux_beta_firefox",
"linux_chrome",
"linux_chromedriver",
"linux_edge",
"linux_edgedriver",
"linux_firefox",
"linux_geckodriver",
"mac_beta_chrome",
"mac_beta_chromedriver",
"mac_beta_firefox",
"mac_chrome",
"mac_chromedriver",
Expand Down
22 changes: 22 additions & 0 deletions common/browsers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,25 @@ firefox_beta_data = select({
],
"//conditions:default": [],
}) + geckodriver_data

chromedriver_beta_data = select({
"@selenium//common:use_pinned_linux_chrome": [
"@linux_beta_chromedriver//:chromedriver",
],
"@selenium//common:use_pinned_macos_chrome": [
"@mac_beta_chromedriver//:chromedriver",
],
"@selenium//common:use_local_chromedriver": ["@selenium//common:chromedriver"],
"//conditions:default": [],
})

chrome_beta_data = select({
"@selenium//common:use_pinned_linux_chrome": [
"@linux_beta_chrome//:files",
"@linux_beta_chrome//:chrome-linux64/chrome",
],
"@selenium//common:use_pinned_macos_chrome": [
"@mac_beta_chrome//:Chrome.app",
],
"//conditions:default": [],
}) + chromedriver_beta_data
80 changes: 78 additions & 2 deletions common/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ js_library(
)
""",
)

http_archive(
name = "mac_chrome",
url = "https://storage.googleapis.com/chrome-for-testing-public/137.0.7151.70/mac-x64/chrome-mac-x64.zip",
Expand All @@ -240,7 +239,6 @@ js_library(
)
""",
)

http_archive(
name = "linux_chromedriver",
url = "https://storage.googleapis.com/chrome-for-testing-public/137.0.7151.70/linux64/chromedriver-linux64.zip",
Expand Down Expand Up @@ -270,6 +268,84 @@ package(default_visibility = ["//visibility:public"])

exports_files(["chromedriver"])

js_library(
name = "chromedriver-js",
data = ["chromedriver"],
)
""",
)

http_archive(
name = "linux_beta_chrome",
url = "https://storage.googleapis.com/chrome-for-testing-public/138.0.7204.15/linux64/chrome-linux64.zip",
sha256 = "e4bb8769b613eacd7cc40e48f3f63d96de9e9ee642360b4a79bedd502291c544",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])

filegroup(
name = "files",
srcs = glob(["**/*"]),
)

exports_files(["chrome-linux64/chrome"])

js_library(
name = "chrome-js",
data = [":files"],
)
""",
)
http_archive(
name = "mac_beta_chrome",
url = "https://storage.googleapis.com/chrome-for-testing-public/138.0.7204.15/mac-x64/chrome-mac-x64.zip",
sha256 = "46dbfe39930cd3a2a45bc85a70bb49c291c258fde5be4d3d4deecc8e3181ae2f",
strip_prefix = "chrome-mac-x64",
patch_cmds = [
"mv 'Google Chrome for Testing.app' Chrome.app",
"mv 'Chrome.app/Contents/MacOS/Google Chrome for Testing' Chrome.app/Contents/MacOS/Chrome",
],
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])

exports_files(["Chrome.app"])

js_library(
name = "chrome-js",
data = glob(["Chrome.app/**/*"]),
)
""",
)
http_archive(
name = "linux_beta_chromedriver",
url = "https://storage.googleapis.com/chrome-for-testing-public/138.0.7204.15/linux64/chromedriver-linux64.zip",
sha256 = "b180e7569aa10a10e5b112b2b6cc21d126499122eaba0e90d264713285cc9104",
strip_prefix = "chromedriver-linux64",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])

exports_files(["chromedriver"])

js_library(
name = "chromedriver-js",
data = ["chromedriver"],
)
""",
)

http_archive(
name = "mac_beta_chromedriver",
url = "https://storage.googleapis.com/chrome-for-testing-public/138.0.7204.15/mac-x64/chromedriver-mac-x64.zip",
sha256 = "fda50dbab46115e2185cae0f3eeb8526c3f95175b0d4f7f7871aaf1e63590d5c",
strip_prefix = "chromedriver-mac-x64",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])

exports_files(["chromedriver"])

js_library(
name = "chromedriver-js",
data = ["chromedriver"],
Expand Down
1 change: 1 addition & 0 deletions rb/spec/integration/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package(default_visibility = ["//rb/spec/integration:__subpackages__"])

BROWSERS = [
"chrome",
"chrome-beta",
"edge",
"firefox",
"ie",
Expand Down
7 changes: 6 additions & 1 deletion rb/spec/integration/selenium/webdriver/chrome/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ load("//rb/spec:tests.bzl", "rb_integration_test")
rb_integration_test(
name = file[:-8],
srcs = [file],
browsers = ["chrome"], # No need to run in other browsers.
# No need to run in other browsers.
browsers = [
"chrome",
"chrome-beta",
],
data = ["//common/extensions"],
)
for file in glob(["*_spec.rb"])
]
25 changes: 25 additions & 0 deletions rb/spec/tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ load("@rules_ruby//ruby:defs.bzl", "rb_library", "rb_test")
load(
"//common:browsers.bzl",
"COMMON_TAGS",
"chrome_beta_data",
"chrome_data",
"edge_data",
"firefox_beta_data",
Expand Down Expand Up @@ -32,6 +33,30 @@ BROWSERS = {
"//conditions:default": {},
}),
},
"chrome-beta": {
"data": chrome_beta_data,
"deps": ["//rb/lib/selenium/webdriver:chrome"],
"tags": [],
"target_compatible_with": [],
"env": {
"WD_REMOTE_BROWSER": "chrome",
"WD_SPEC_DRIVER": "chrome",
"WD_BROWSER_VERSION": "beta",
} | select({
"@selenium//common:use_pinned_linux_chrome": {
"CHROME_BINARY": "$(location @linux_beta_chrome//:chrome-linux64/chrome)",
"CHROMEDRIVER_BINARY": "$(location @linux_beta_chromedriver//:chromedriver)",
},
"@selenium//common:use_pinned_macos_chrome": {
"CHROME_BINARY": "$(location @mac_beta_chrome//:Chrome.app)/Contents/MacOS/Chrome",
"CHROMEDRIVER_BINARY": "$(location @mac_beta_chromedriver//:chromedriver)",
},
"//conditions:default": {},
}) | select({
"@selenium//common:use_headless_browser": {"HEADLESS": "true"},
"//conditions:default": {},
}),
},
"edge": {
"data": edge_data,
"deps": ["//rb/lib/selenium/webdriver:edge"],
Expand Down
2 changes: 1 addition & 1 deletion scripts/github-actions/ci-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -eufo pipefail
set -x

# Define heap size for GitHub Actions runner
HEAP_SIZE="-Xmx4g"
HEAP_SIZE="-Xmx8g"

# Default to auto if no parameter is provided
CACHE_RESULTS="auto"
Expand Down
98 changes: 42 additions & 56 deletions scripts/pinned_browsers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python

import argparse
import hashlib
import json
import os
Expand All @@ -26,14 +25,7 @@ def calculate_hash(url):
return h.hexdigest()


def get_chrome_milestone():
parser = argparse.ArgumentParser()
parser.add_argument(
"--chrome_channel", default="Stable", help="Set the Chrome channel"
)
args = parser.parse_args()
channel = args.chrome_channel

def get_chrome_info_for_channel(channel):
r = http.request(
"GET",
f"https://chromiumdash.appspot.com/fetch_releases?channel={channel}&num=1&platform=Mac,Linux",
Expand All @@ -55,20 +47,18 @@ def get_chrome_milestone():
)[-1]


def chromedriver(selected_version):
def chromedriver(selected_version, workspace_prefix=""):
content = ""

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

linux = [d["url"] for d in drivers if d["platform"] == "linux64"][0]
sha = calculate_hash(linux)
url = [d["url"] for d in drivers if d["platform"] == "linux64"][0]
sha = calculate_hash(url)

content = (
content
+ """ http_archive(
name = "linux_chromedriver",
url = "%s",
sha256 = "%s",
content += f""" http_archive(
name = "linux_{workspace_prefix}chromedriver",
url = "{url}",
sha256 = "{sha}",
strip_prefix = "chromedriver-linux64",
build_file_content = \"\"\"
load("@aspect_rules_js//js:defs.bzl", "js_library")
Expand All @@ -83,18 +73,15 @@ def chromedriver(selected_version):
\"\"\",
)
"""
% (linux, sha)
)

mac = [d["url"] for d in drivers if d["platform"] == "mac-x64"][0]
sha = calculate_hash(mac)
content = (
content
+ """
url = [d["url"] for d in drivers if d["platform"] == "mac-x64"][0]
sha = calculate_hash(url)

content += f"""
http_archive(
name = "mac_chromedriver",
url = "%s",
sha256 = "%s",
name = "mac_{workspace_prefix}chromedriver",
url = "{url}",
sha256 = "{sha}",
strip_prefix = "chromedriver-mac-x64",
build_file_content = \"\"\"
load("@aspect_rules_js//js:defs.bzl", "js_library")
Expand All @@ -109,23 +96,22 @@ def chromedriver(selected_version):
\"\"\",
)
"""
% (mac, sha)
)

return content


def chrome(selected_version):
def chrome(selected_version, workspace_prefix=""):
content = ""
chrome_downloads = selected_version["downloads"]["chrome"]

linux = [d["url"] for d in chrome_downloads if d["platform"] == "linux64"][0]
sha = calculate_hash(linux)
url = [d["url"] for d in chrome_downloads if d["platform"] == "linux64"][0]
sha = calculate_hash(url)

content = """
content += f"""
http_archive(
name = "linux_chrome",
url = "%s",
sha256 = "%s",
name = "linux_{workspace_prefix}chrome",
url = "{url}",
sha256 = "{sha}",
build_file_content = \"\"\"
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
Expand All @@ -143,19 +129,15 @@ def chrome(selected_version):
)
\"\"\",
)
"""

""" % (
linux,
sha,
)

mac = [d["url"] for d in chrome_downloads if d["platform"] == "mac-x64"][0]
sha = calculate_hash(mac)
url = [d["url"] for d in chrome_downloads if d["platform"] == "mac-x64"][0]
sha = calculate_hash(url) # Calculate SHA for Mac chrome

content += """ http_archive(
name = "mac_chrome",
url = "%s",
sha256 = "%s",
content += f""" http_archive(
name = "mac_{workspace_prefix}chrome",
url = "{url}",
sha256 = "{sha}",
strip_prefix = "chrome-mac-x64",
patch_cmds = [
"mv 'Google Chrome for Testing.app' Chrome.app",
Expand All @@ -173,11 +155,7 @@ def chrome(selected_version):
)
\"\"\",
)

""" % (
mac,
sha,
)
"""

return content

Expand Down Expand Up @@ -522,9 +500,17 @@ def pin_browsers():
content = content + geckodriver()
content = content + edge()
content = content + edgedriver()
chrome_milestone = get_chrome_milestone()
content = content + chrome(chrome_milestone)
content = content + chromedriver(chrome_milestone)

# Stable Chrome
stable_chrome_info = get_chrome_info_for_channel(channel="Stable")
content = content + chrome(stable_chrome_info, workspace_prefix="")
content = content + chromedriver(stable_chrome_info, workspace_prefix="")

# Beta Chrome
beta_chrome_info = get_chrome_info_for_channel(channel="Beta")
content = content + chrome(beta_chrome_info, workspace_prefix="beta_")
content = content + chromedriver(beta_chrome_info, workspace_prefix="beta_")

content += """
def _pin_browsers_extension_impl(_ctx):
pin_browsers()
Expand Down