Skip to content

Commit

Permalink
[bazel] Add support for pinning Firefox Dev Edition
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Sep 17, 2023
1 parent 8c21026 commit 828eed0
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 32 deletions.
11 changes: 11 additions & 0 deletions common/browsers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,14 @@ firefox_data = select({
],
"//conditions:default": [],
}) + geckodriver_data

firefox_dev_data = select({
"@selenium//common:use_pinned_linux_firefox": [
"@linux_dev_firefox//:files",
"@linux_dev_firefox//:firefox/firefox",
],
"@selenium//common:use_pinned_macos_firefox": [
"@mac_dev_firefox//:Firefox.app",
],
"//conditions:default": [],
}) + geckodriver_data
62 changes: 43 additions & 19 deletions common/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def pin_browsers():

http_archive(
name = "linux_firefox",
url = "https://ftp.mozilla.org/pub/firefox/releases/117.0/linux-x86_64/en-US/firefox-117.0.tar.bz2",
sha256 = "5acf61aed42bbf43dff8fee90c55fd3bcecb1c710b86cdd2c380b5e4db7f3998",
url = "https://ftp.mozilla.org/pub/firefox/releases/117.0.1/linux-x86_64/en-US/firefox-117.0.1.tar.bz2",
sha256 = "e70b282ed0b8ce42981675ca2bc9a69fbad23f31f71fbd700b52dcf79e57761c",
build_file_content = """
filegroup(
name = "files",
Expand All @@ -27,8 +27,32 @@ exports_files(

dmg_archive(
name = "mac_firefox",
url = "https://ftp.mozilla.org/pub/firefox/releases/117.0/mac/en-US/Firefox%20117.0.dmg",
sha256 = "eb9fcd6a7ea0feb56d64795367c32a1faea93db113d40b7a6b93e178af56e258",
url = "https://ftp.mozilla.org/pub/firefox/releases/117.0.1/mac/en-US/Firefox%20117.0.1.dmg",
sha256 = "11a153fd97d2074d730ecf829c817410aa2901244906332dbf1e36e81ca2f912",
build_file_content = "exports_files([\"Firefox.app\"])",
)

http_archive(
name = "linux_dev_firefox",
url = "https://ftp.mozilla.org/pub/firefox/releases/118.0b9/linux-x86_64/en-US/firefox-118.0b9.tar.bz2",
sha256 = "aabef5f4ad520030de0d7ab47e1b9fab6a90d5deea50829fe7e92feb4a426e56",
build_file_content = """
filegroup(
name = "files",
srcs = glob(["**/*"]),
visibility = ["//visibility:public"],
)
exports_files(
["firefox/firefox"],
)
""",
)

dmg_archive(
name = "mac_dev_firefox",
url = "https://ftp.mozilla.org/pub/firefox/releases/118.0b9/mac/en-US/Firefox%20118.0b9.dmg",
sha256 = "0794dcdace86d8e7ddd7392c191abb15c6ee71cd23a7c99ef857957c5aa36c7d",
build_file_content = "exports_files([\"Firefox.app\"])",
)

Expand All @@ -48,32 +72,32 @@ exports_files(

pkg_archive(
name = "mac_edge",
url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/a989b093-c982-4d31-95d1-2c439f49b7e7/MicrosoftEdge-116.0.1938.76.pkg",
sha256 = "d8676eb179b94be62e3a088367ae4525c96cd7bd79afdf3571b1e560a96c5643",
url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/fcc744c6-52f7-4500-b684-cc1d1ec3e19b/MicrosoftEdge-117.0.2045.31.pkg",
sha256 = "129470b53c4aa13e7769d87118d119607815b3696c6c643380beb521598bf7b4",
move = {
"MicrosoftEdge-116.0.1938.76.pkg/Payload/Microsoft Edge.app": "Edge.app",
"MicrosoftEdge-117.0.2045.31.pkg/Payload/Microsoft Edge.app": "Edge.app",
},
build_file_content = "exports_files([\"Edge.app\"])",
)

http_archive(
name = "linux_edgedriver",
url = "https://msedgedriver.azureedge.net/116.0.1938.76/edgedriver_linux64.zip",
sha256 = "85b06da1719907402e4d78a1467e06539185c38b238019b6efb503000f3f04f8",
url = "https://msedgedriver.azureedge.net/116.0.1938.81/edgedriver_linux64.zip",
sha256 = "32db8caca4fb6b96f6e171ee1f06a0d218b22d69d21e7c3bc8986720ea3450b7",
build_file_content = "exports_files([\"msedgedriver\"])",
)

http_archive(
name = "mac_edgedriver",
url = "https://msedgedriver.azureedge.net/116.0.1938.76/edgedriver_mac64.zip",
sha256 = "3b0b2ba7e7a7e99c78a00a3a830fe72d2c3825d66e592ce3664cff563ddc6828",
url = "https://msedgedriver.azureedge.net/116.0.1938.81/edgedriver_mac64.zip",
sha256 = "469e49476e91189c988c4640a9d399c14677ec033ee24b9dc972f2f54ad286e7",
build_file_content = "exports_files([\"msedgedriver\"])",
)

http_archive(
name = "linux_chrome",
url = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/linux64/chrome-linux64.zip",
sha256 = "5d8ab1f999071b213d85e46ea4505d99df818b6fd0f8449e79710cb5403ba858",
url = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/117.0.5938.88/linux64/chrome-linux64.zip",
sha256 = "79a67f23970f2d21ee2066d8e488ea99868ff4a05da425313e227783d42625cb",
build_file_content = """
filegroup(
name = "files",
Expand All @@ -89,8 +113,8 @@ exports_files(

http_archive(
name = "mac_chrome",
url = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/mac-x64/chrome-mac-x64.zip",
sha256 = "edc8e78f7a4b618037067593b2cb79ff571c16da0b955bc05a500af34b77d2fe",
url = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/117.0.5938.88/mac-x64/chrome-mac-x64.zip",
sha256 = "6aaa5cc25bc950d23a75b5df53e3cb0c0a2b26b16b75c538d516660635b05708",
strip_prefix = "chrome-mac-x64",
patch_cmds = [
"mv 'Google Chrome for Testing.app' Chrome.app",
Expand All @@ -101,16 +125,16 @@ exports_files(

http_archive(
name = "linux_chromedriver",
url = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/linux64/chromedriver-linux64.zip",
sha256 = "17d225af124f9483a5d79a547f28f34253d7a1ef603ab7fb5ee185c0e4c71535",
url = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/117.0.5938.88/linux64/chromedriver-linux64.zip",
sha256 = "70ee5bba99f9711c79c3cff4335a7abff61faada4c81bc0722f7432103644873",
strip_prefix = "chromedriver-linux64",
build_file_content = "exports_files([\"chromedriver\"])",
)

http_archive(
name = "mac_chromedriver",
url = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/mac-x64/chromedriver-mac-x64.zip",
sha256 = "3ec691569dc8e98d803cf206c5fd4627e56836c81a5d1c9b7e5644a4e61ffd3f",
url = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/117.0.5938.88/mac-x64/chromedriver-mac-x64.zip",
sha256 = "a5242b8ff9cfa135b87d7a7ecdb92ea2453728fec5c48687485cf2d32266105e",
strip_prefix = "chromedriver-mac-x64",
build_file_content = "exports_files([\"chromedriver\"])",
)
18 changes: 18 additions & 0 deletions java/browsers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,21 @@ firefox_jvm_flags = select({
],
"//conditions:default": [],
}) + geckodriver_jvm_flags

firefox_dev_jvm_flags = select({
"@selenium//common:use_pinned_linux_firefox": [
"-Dwebdriver.firefox.bin=$(location @linux_dev_firefox//:firefox/firefox)",
],
"@selenium//common:use_pinned_macos_firefox": [
"-Dwebdriver.firefox.bin=$(location @mac_dev_firefox//:Firefox.app)/Contents/MacOS/firefox",
],
"@selenium//common:use_local_geckodriver": [],
"//conditions:default": [
"-Dselenium.skiptest=false",
],
}) + select({
"@selenium//common:use_headless_browser": [
"-Dwebdriver.headless=true",
],
"//conditions:default": [],
}) + geckodriver_jvm_flags
8 changes: 8 additions & 0 deletions java/private/selenium_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ load(
"chrome_data",
"edge_data",
"firefox_data",
"firefox_dev_data",
)
load(
"//java:browsers.bzl",
"chrome_jvm_flags",
"edge_jvm_flags",
"firefox_dev_jvm_flags",
"firefox_jvm_flags",
)

Expand All @@ -34,6 +36,12 @@ BROWSERS = {
"data": firefox_data,
"tags": COMMON_TAGS + ["firefox"],
},
"firefox-dev": {
"deps": ["//java/src/org/openqa/selenium/firefox"],
"jvm_flags": ["-Dselenium.browser=ff"] + firefox_dev_jvm_flags,
"data": firefox_dev_data,
"tags": COMMON_TAGS + ["firefox"],
},
"ie": {
"deps": ["//java/src/org/openqa/selenium/ie"],
"jvm_flags": ["-Dselenium.browser=ie"] +
Expand Down
27 changes: 14 additions & 13 deletions scripts/pinned_browsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,19 +210,19 @@ def geckodriver():
""" % (url, sha)
return content

def firefox():
def firefox(version_key, workspace_name):
r = http.request('GET', 'https://product-details.mozilla.org/1.0/firefox_versions.json')
v = json.loads(r.data)['LATEST_FIREFOX_VERSION']
v = json.loads(r.data)[version_key]

content = ""

linux = "https://ftp.mozilla.org/pub/firefox/releases/%s/linux-x86_64/en-US/firefox-%s.tar.bz2" % (v, v)
sha = calculate_hash(linux)
content = content + """
content = content + f"""
http_archive(
name = "linux_firefox",
url = "%s",
sha256 = "%s",
name = "linux_{workspace_name}firefox",
url = "{linux}",
sha256 = "{sha}",
build_file_content = \"\"\"
filegroup(
name = "files",
Expand All @@ -236,19 +236,19 @@ def firefox():
\"\"\",
)
""" % (linux, sha)
"""

mac = "https://ftp.mozilla.org/pub/firefox/releases/%s/mac/en-US/Firefox%%20%s.dmg" % (v, v)
sha = calculate_hash(mac)
content = content + """
content = content + f"""
dmg_archive(
name = "mac_firefox",
url = "%s",
sha256 = "%s",
name = "mac_{workspace_name}firefox",
url = "{mac}",
sha256 = "{sha}",
build_file_content = "exports_files([\\"Firefox.app\\"])",
)
""" % (mac, sha)
"""

return content

Expand All @@ -264,7 +264,8 @@ def firefox():
def pin_browsers():
local_drivers()
"""
content = content + firefox()
content = content + firefox("LATEST_FIREFOX_VERSION", "")
content = content + firefox("LATEST_FIREFOX_RELEASED_DEVEL_VERSION", "dev_")
content = content + geckodriver()
content = content + edge()
content = content + edgedriver()
Expand Down

0 comments on commit 828eed0

Please sign in to comment.