Skip to content

Commit 05fe130

Browse files
committed
[bazel] Pin chrome for testing instead of chromium
1 parent cd20deb commit 05fe130

File tree

7 files changed

+68
-61
lines changed

7 files changed

+68
-61
lines changed

common/browsers.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ chromedriver_data = select({
1818
chrome_data = select({
1919
"@selenium//common:use_pinned_linux_chrome": [
2020
"@linux_chrome//:files",
21-
"@linux_chrome//:chrome-linux/chrome",
21+
"@linux_chrome//:chrome-linux64/chrome",
2222
],
2323
"@selenium//common:use_pinned_macos_chrome": [
24-
"@mac_chrome//:Chromium.app",
24+
"@mac_chrome//:Chrome.app",
2525
],
2626
"//conditions:default": [],
2727
}) + chromedriver_data

common/repositories.bzl

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ def pin_browsers():
1010

1111
http_archive(
1212
name = "linux_firefox",
13-
url = "https://ftp.mozilla.org/pub/firefox/releases/113.0.2/linux-x86_64/en-US/firefox-113.0.2.tar.bz2",
14-
sha256 = "5a4b4fc537d5d358c0fe416fff91692bae9b62264dabd557cf99fb6cbda91acf",
13+
url = "https://ftp.mozilla.org/pub/firefox/releases/115.0.3/linux-x86_64/en-US/firefox-115.0.3.tar.bz2",
14+
sha256 = "ee8980afe907fa552b52d573073e298b7878558faff8e8d5a4a7444f4f2d2cca",
1515
build_file_content = """
1616
filegroup(
1717
name = "files",
@@ -27,8 +27,8 @@ exports_files(
2727

2828
dmg_archive(
2929
name = "mac_firefox",
30-
url = "https://ftp.mozilla.org/pub/firefox/releases/113.0.2/mac/en-US/Firefox%20113.0.2.dmg",
31-
sha256 = "48749d747b6814e90f643d401a6edf65807551902c8f2fba11de89dc728fa824",
30+
url = "https://ftp.mozilla.org/pub/firefox/releases/115.0.3/mac/en-US/Firefox%20115.0.3.dmg",
31+
sha256 = "96b2616d0f95352caad756a200e0b13d20ee300be1d02fdfd3bab17ed6e73fa3",
3232
build_file_content = "exports_files([\"Firefox.app\"])",
3333
)
3434

@@ -48,32 +48,32 @@ exports_files(
4848

4949
pkg_archive(
5050
name = "mac_edge",
51-
url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/5a7ac9fb-6410-4438-a5d1-24a16ab24157/MicrosoftEdge-113.0.1774.57.pkg",
52-
sha256 = "08a84d425db829e378b558dcc0a3df41a60aa7b25ca999d8afd5ebb3c86382e5",
51+
url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/1a586fcf-50fb-4714-9994-bef23c695628/MicrosoftEdge-115.0.1901.188.pkg",
52+
sha256 = "c1bd8ab7e5d8972918ef089027515de14c892fb371a5b2c0322acadb46d29be8",
5353
move = {
54-
"MicrosoftEdge-113.0.1774.57.pkg/Payload/Microsoft Edge.app": "Edge.app",
54+
"MicrosoftEdge-115.0.1901.188.pkg/Payload/Microsoft Edge.app": "Edge.app",
5555
},
5656
build_file_content = "exports_files([\"Edge.app\"])",
5757
)
5858

5959
http_archive(
6060
name = "linux_edgedriver",
61-
url = "https://msedgedriver.azureedge.net/113.0.1774.57/edgedriver_linux64.zip",
62-
sha256 = "d6992f54c711c1042256b2ab10a0b1054e30222e01484fc068857bee72329adb",
61+
url = "https://msedgedriver.azureedge.net/115.0.1901.188/edgedriver_linux64.zip",
62+
sha256 = "8a5d10f0d6c43ecf1c6c503a301defcf648a46440c32437862add99839bc4446",
6363
build_file_content = "exports_files([\"msedgedriver\"])",
6464
)
6565

6666
http_archive(
6767
name = "mac_edgedriver",
68-
url = "https://msedgedriver.azureedge.net/113.0.1774.57/edgedriver_mac64.zip",
69-
sha256 = "299b53816807c70498020d05fe18e442627a40a0f987df87702b3089eb93d6af",
68+
url = "https://msedgedriver.azureedge.net/115.0.1901.188/edgedriver_mac64.zip",
69+
sha256 = "934fdf4f620cba11ba039e8e7dc40a7e23d0a49b5896e5ba53f3be1fe7b4e6ef",
7070
build_file_content = "exports_files([\"msedgedriver\"])",
7171
)
7272

7373
http_archive(
7474
name = "linux_chrome",
75-
url = "https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/1135542/chrome-linux.zip",
76-
sha256 = "2f81ebe4389d7ca6f4e0b9b4065b87e163a94f710a12cef77033c4cb90b8be94",
75+
url = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/115.0.5790.102/linux64/chrome-linux64.zip",
76+
sha256 = "aebaecf70965f152a743935a95d0013de3e9d96e194106eb13dfc1b9b1c7892c",
7777
build_file_content = """
7878
filegroup(
7979
name = "files",
@@ -82,17 +82,21 @@ filegroup(
8282
)
8383
8484
exports_files(
85-
["chrome-linux/chrome"],
85+
["chrome-linux64/chrome"],
8686
)
8787
""",
8888
)
8989

9090
http_archive(
9191
name = "mac_chrome",
92-
url = "https://storage.googleapis.com/chromium-browser-snapshots/Mac/1135542/chrome-mac.zip",
93-
sha256 = "9a3b8c4d26028bb0bfaea5176703c093a812d36f93dd2c5b795d5addc6c4ce2d",
94-
strip_prefix = "chrome-mac",
95-
build_file_content = "exports_files([\"Chromium.app\"])",
92+
url = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/115.0.5790.102/mac-x64/chrome-mac-x64.zip",
93+
sha256 = "76e2fbb782e195259e7e7873ffca0e7270d52066af79a0d401c92d66382420ec",
94+
strip_prefix = "chrome-mac-x64",
95+
patch_cmds = [
96+
"mv 'Google Chrome for Testing.app' Chrome.app",
97+
"mv 'Chrome.app/Contents/MacOS/Google Chrome for Testing' Chrome.app/Contents/MacOS/Chrome",
98+
],
99+
build_file_content = "exports_files([\"Chrome.app\"])",
96100
)
97101

98102
http_archive(

java/browsers.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ chromedriver_jvm_flags = select({
1010

1111
chrome_jvm_flags = select({
1212
"@selenium//common:use_pinned_linux_chrome": [
13-
"-Dwebdriver.chrome.binary=$(location @linux_chrome//:chrome-linux/chrome)",
13+
"-Dwebdriver.chrome.binary=$(location @linux_chrome//:chrome-linux64/chrome)",
1414
],
1515
"@selenium//common:use_pinned_macos_chrome": [
16-
"-Dwebdriver.chrome.binary=$(location @mac_chrome//:Chromium.app)/Contents/MacOS/Chromium",
16+
"-Dwebdriver.chrome.binary=$(location @mac_chrome//:Chrome.app)/Contents/MacOS/Chrome",
1717
],
1818
"@selenium//common:use_local_chromedriver": [],
1919
"//conditions:default": [

java/src/org/openqa/selenium/grid/BUILD.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ java_binary(
3232
name = "pinned-grid",
3333
data = select({
3434
"//common:linux": [
35-
"@linux_chrome//:chrome-linux/chrome",
35+
"@linux_chrome//:chrome-linux64/chrome",
3636
"@linux_chromedriver//:chromedriver",
3737
"@linux_firefox//:firefox/firefox",
3838
"@linux_geckodriver//:geckodriver",
3939
],
4040
"//common:macos": [
41-
"@mac_chrome//:Chromium.app",
41+
"@mac_chrome//:Chrome.app",
4242
"@mac_chromedriver//:chromedriver",
4343
"@mac_firefox//:Firefox.app",
4444
"@mac_geckodriver//:geckodriver",
@@ -48,13 +48,13 @@ java_binary(
4848
jvm_flags = select({
4949
"//common:linux": [
5050
"-Dwebdriver.chrome.driver=$(location @linux_chromedriver//:chromedriver)",
51-
"-Dwebdriver.chrome.binary=$(location @linux_chrome//:chrome-linux/chrome)",
51+
"-Dwebdriver.chrome.binary=$(location @linux_chrome//:chrome-linux64/chrome)",
5252
"-Dwebdriver.gecko.driver=$(location @linux_geckodriver//:geckodriver)",
5353
"-Dwebdriver.firefox.bin=$(location @linux_firefox//:firefox/firefox)",
5454
],
5555
"//common:macos": [
5656
"-Dwebdriver.chrome.driver=$(location @mac_chromedriver//:chromedriver)",
57-
"-Dwebdriver.chrome.binary=$(location @mac_chrome//:Chromium.app)/Contents/MacOS/Chromium",
57+
"-Dwebdriver.chrome.binary=$(location @mac_chrome//:Chrome.app)/Contents/MacOS/Chrome",
5858
"-Dwebdriver.gecko.driver=$(location @mac_geckodriver//:geckodriver)",
5959
"-Dwebdriver.firefox.bin=$(location @mac_firefox//:Firefox.app)/Contents/MacOS/firefox",
6060
],

py/private/browsers.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ headless_args = select({
1616
chrome_args = select({
1717
"@selenium//common:use_pinned_linux_chrome": [
1818
"--driver-binary=$(location @linux_chromedriver//:chromedriver)",
19-
"--browser-binary=$(location @linux_chrome//:chrome-linux/chrome)",
19+
"--browser-binary=$(location @linux_chrome//:chrome-linux64/chrome)",
2020
"--browser-args=--disable-dev-shm-usage",
2121
"--browser-args=--no-sandbox",
2222
],
2323
"@selenium//common:use_pinned_macos_chrome": [
2424
"--driver-binary=$(location @mac_chromedriver//:chromedriver)",
25-
"--browser-binary=$(location @mac_chrome//:Chromium.app)/Contents/MacOS/Chromium",
25+
"--browser-binary=$(location @mac_chrome//:Chrome.app)/Contents/MacOS/Chrome",
2626
],
2727
"@selenium//common:use_local_chromedriver": [
2828
"--driver-binary=$(location @selenium//common:chromedriver)",

scripts/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ py_binary(
55
name = "pinned_browsers",
66
srcs = ["pinned_browsers.py"],
77
deps = [
8+
requirement("packaging"),
89
requirement("urllib3"),
910
],
1011
)

scripts/pinned_browsers.py

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import json
55
import urllib3
66

7+
from packaging.version import LegacyVersion
8+
79
# Find the current stable versions of each browser we
810
# support and the sha256 of these. That's useful for
911
# updating `//common:repositories.bzl`
@@ -47,31 +49,24 @@ def chromedriver():
4749
return content
4850

4951
def chrome():
50-
# Find the current latest stable revision
51-
r = http.request('GET', 'https://omahaproxy.appspot.com/all.json?channel=stable&os=linux')
52-
max_version = int(json.loads(r.data)[0]['versions'][0]['branch_base_position'])
53-
min_version = max_version - 1500
54-
55-
# count down from most recent to a version which has something for everyone
56-
for v in range(max_version, min_version, -1):
57-
r = http.request(
58-
'HEAD',
59-
'https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/%s/chrome-linux.zip' % v)
60-
if r.status != 200:
61-
continue
52+
channel = "Stable"
53+
r = http.request('GET', f'https://chromiumdash.appspot.com/fetch_releases?channel={channel}&num=1&platform=Win32,Windows,Mac,Linux')
54+
milestone = json.loads(r.data)[0]["milestone"]
6255

63-
r = http.request(
64-
'HEAD',
65-
'https://storage.googleapis.com/chromium-browser-snapshots/Mac/%s/chrome-mac.zip' % v)
66-
if r.status != 200:
67-
continue
56+
r = http.request('GET', 'https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json')
57+
versions = json.loads(r.data)["versions"]
58+
59+
selected_version = sorted(
60+
filter(lambda v: v['version'].split('.')[0] == str(milestone), versions),
61+
key=lambda v: LegacyVersion(v['version'])
62+
)[-1]
6863

69-
content = ""
64+
downloads = selected_version["downloads"]["chrome"]
7065

71-
linux = 'https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/%s/chrome-linux.zip' % v
72-
sha = calculate_hash(linux)
66+
linux = [d["url"] for d in downloads if d["platform"] == "linux64"][0]
67+
sha = calculate_hash(linux)
7368

74-
content = content + """
69+
content = """
7570
http_archive(
7671
name = "linux_chrome",
7772
url = "%s",
@@ -84,27 +79,32 @@ def chrome():
8479
)
8580
8681
exports_files(
87-
["chrome-linux/chrome"],
82+
["chrome-linux64/chrome"],
8883
)
8984
\"\"\",
9085
)
91-
""" % (linux, sha)
9286
93-
mac = 'https://storage.googleapis.com/chromium-browser-snapshots/Mac/%s/chrome-mac.zip' % v
94-
sha = calculate_hash(mac)
87+
""" % (linux, sha)
88+
89+
mac = [d["url"] for d in downloads if d["platform"] == "mac-x64"][0]
90+
sha = calculate_hash(mac)
9591

96-
content = content + """
92+
content += """
9793
http_archive(
9894
name = "mac_chrome",
9995
url = "%s",
10096
sha256 = "%s",
101-
strip_prefix = "chrome-mac",
102-
build_file_content = "exports_files([\\"Chromium.app\\"])",
97+
strip_prefix = "chrome-mac-x64",
98+
patch_cmds = [
99+
"mv 'Google Chrome for Testing.app' Chrome.app",
100+
"mv 'Chrome.app/Contents/MacOS/Google Chrome for Testing' Chrome.app/Contents/MacOS/Chrome",
101+
],
102+
build_file_content = "exports_files([\\"Google Chrome for Testing.app\\"])",
103103
)
104-
""" % (mac, sha)
105104
106-
return content
107-
raise RuntimeError("Cannot find stable chrome")
105+
""" % (mac, sha)
106+
107+
return content
108108

109109
def edge():
110110
r = http.request('GET', 'https://edgeupdates.microsoft.com/api/products')
@@ -226,7 +226,8 @@ def firefox():
226226
)
227227
\"\"\",
228228
)
229-
""" % (linux, sha)
229+
230+
""" % (linux, sha)
230231

231232
mac = "https://ftp.mozilla.org/pub/firefox/releases/%s/mac/en-US/Firefox%%20%s.dmg" % (v, v)
232233
sha = calculate_hash(mac)
@@ -237,7 +238,8 @@ def firefox():
237238
sha256 = "%s",
238239
build_file_content = "exports_files([\\"Firefox.app\\"])",
239240
)
240-
""" % (mac, sha)
241+
242+
""" % (mac, sha)
241243

242244
return content
243245

0 commit comments

Comments
 (0)