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 19, 2023
1 parent fbfaab5 commit 5f6c635
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 13 deletions.
22 changes: 22 additions & 0 deletions common/browsers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,25 @@ firefox_data = select({
],
"//conditions:default": [],
}) + geckodriver_data

firefox_beta_data = select({
"@selenium//common:use_pinned_linux_firefox": [
"@linux_beta_firefox//:files",
"@linux_beta_firefox//:firefox/firefox",
],
"@selenium//common:use_pinned_macos_firefox": [
"@mac_beta_firefox//:Firefox.app",
],
"//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
48 changes: 48 additions & 0 deletions common/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,54 @@ exports_files(
build_file_content = "exports_files([\"Firefox.app\"])",
)

http_archive(
name = "linux_beta_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_beta_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\"])",
)

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\"])",
)

http_archive(
name = "linux_geckodriver",
url = "https://github.com/mozilla/geckodriver/releases/download/v0.33.0/geckodriver-v0.33.0-linux64.tar.gz",
Expand Down
36 changes: 36 additions & 0 deletions java/browsers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,39 @@ firefox_jvm_flags = select({
],
"//conditions:default": [],
}) + geckodriver_jvm_flags

firefox_beta_jvm_flags = select({
"@selenium//common:use_pinned_linux_firefox": [
"-Dwebdriver.firefox.bin=$(location @linux_beta_firefox//:firefox/firefox)",
],
"@selenium//common:use_pinned_macos_firefox": [
"-Dwebdriver.firefox.bin=$(location @mac_beta_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

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
16 changes: 16 additions & 0 deletions java/private/selenium_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ load(
"COMMON_TAGS",
"chrome_data",
"edge_data",
"firefox_beta_data",
"firefox_data",
"firefox_dev_data",
)
load(
"//java:browsers.bzl",
"chrome_jvm_flags",
"edge_jvm_flags",
"firefox_beta_jvm_flags",
"firefox_dev_jvm_flags",
"firefox_jvm_flags",
)

Expand All @@ -34,6 +38,18 @@ BROWSERS = {
"data": firefox_data,
"tags": COMMON_TAGS + ["firefox"],
},
"firefox-beta": {
"deps": ["//java/src/org/openqa/selenium/firefox"],
"jvm_flags": ["-Dselenium.browser=ff"] + firefox_beta_jvm_flags,
"data": firefox_beta_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
28 changes: 15 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,9 @@ def firefox():
def pin_browsers():
local_drivers()
"""
content = content + firefox()
content = content + firefox("LATEST_FIREFOX_VERSION", "")
content = content + firefox("LATEST_FIREFOX_RELEASED_DEVEL_VERSION", "beta_")
content = content + firefox("FIREFOX_DEVEDITION", "dev_")
content = content + geckodriver()
content = content + edge()
content = content + edgedriver()
Expand Down

0 comments on commit 5f6c635

Please sign in to comment.