diff --git a/MODULE.bazel b/MODULE.bazel index cd743a57bccdc..219317fd13acb 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -370,6 +370,8 @@ 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", @@ -377,6 +379,8 @@ use_repo( "linux_edgedriver", "linux_firefox", "linux_geckodriver", + "mac_beta_chrome", + "mac_beta_chromedriver", "mac_beta_firefox", "mac_chrome", "mac_chromedriver", diff --git a/common/browsers.bzl b/common/browsers.bzl index 7be9d79fbf267..0617a80c934d4 100644 --- a/common/browsers.bzl +++ b/common/browsers.bzl @@ -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 diff --git a/common/repositories.bzl b/common/repositories.bzl index 08661949492d1..d36c861ad60de 100644 --- a/common/repositories.bzl +++ b/common/repositories.bzl @@ -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", @@ -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", @@ -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"], diff --git a/rb/spec/integration/BUILD.bazel b/rb/spec/integration/BUILD.bazel index 80c827aecc236..c13fa56313f5c 100644 --- a/rb/spec/integration/BUILD.bazel +++ b/rb/spec/integration/BUILD.bazel @@ -2,6 +2,7 @@ package(default_visibility = ["//rb/spec/integration:__subpackages__"]) BROWSERS = [ "chrome", + "chrome-beta", "edge", "firefox", "ie", diff --git a/rb/spec/integration/selenium/webdriver/chrome/BUILD.bazel b/rb/spec/integration/selenium/webdriver/chrome/BUILD.bazel index bd2441d4b2e56..a86ffd7d547ad 100644 --- a/rb/spec/integration/selenium/webdriver/chrome/BUILD.bazel +++ b/rb/spec/integration/selenium/webdriver/chrome/BUILD.bazel @@ -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"]) ] diff --git a/rb/spec/tests.bzl b/rb/spec/tests.bzl index 7004d184b2494..85b7cb9b1d3ea 100644 --- a/rb/spec/tests.bzl +++ b/rb/spec/tests.bzl @@ -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", @@ -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"], diff --git a/scripts/github-actions/ci-build.sh b/scripts/github-actions/ci-build.sh index e1bf8c1e9f24a..4335f27e99ca4 100755 --- a/scripts/github-actions/ci-build.sh +++ b/scripts/github-actions/ci-build.sh @@ -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" diff --git a/scripts/pinned_browsers.py b/scripts/pinned_browsers.py index c4e4771f9453a..05082779a0568 100755 --- a/scripts/pinned_browsers.py +++ b/scripts/pinned_browsers.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import argparse import hashlib import json import os @@ -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", @@ -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") @@ -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") @@ -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"]) @@ -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", @@ -173,11 +155,7 @@ def chrome(selected_version): ) \"\"\", ) - -""" % ( - mac, - sha, - ) +""" return content @@ -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()