Skip to content

Commit

Permalink
[bazel] Add Linux Edge to pinned browser
Browse files Browse the repository at this point in the history
  • Loading branch information
p0deje committed Mar 15, 2024
1 parent 4e17575 commit e9bbb29
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 22 deletions.
7 changes: 7 additions & 0 deletions common/browsers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ chrome_data = select({
}) + chromedriver_data

edgedriver_data = select({
"@selenium//common:use_pinned_linux_edge": [
"@linux_edgedriver//:msedgedriver",
],
"@selenium//common:use_pinned_macos_edge": [
"@mac_edgedriver//:msedgedriver",
],
Expand All @@ -38,6 +41,10 @@ edgedriver_data = select({
})

edge_data = select({
"@selenium//common:use_pinned_linux_edge": [
"@linux_edge//:files",
"@linux_edge//:opt/microsoft/msedge/microsoft-edge",
],
"@selenium//common:use_pinned_macos_edge": [
"@mac_edge//:Edge.app",
],
Expand Down
36 changes: 36 additions & 0 deletions common/private/deb_archive.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
def _deb_archive_impl(repository_ctx):
url = repository_ctx.attr.url

attrs = {}
if repository_ctx.attr.sha256:
attrs.update({"sha256": repository_ctx.attr.sha256})

repository_ctx.download_and_extract(
url,
**attrs
)

repository_ctx.extract(
archive = "data.tar.xz",
stripPrefix = repository_ctx.attr.strip_prefix,
output = repository_ctx.attr.output,
)
repository_ctx.delete("data.tar.xz")

repository_ctx.file(
"BUILD.bazel",
repository_ctx.attr.build_file_content,
)

deb_archive = repository_rule(
_deb_archive_impl,
attrs = {
"url": attr.string(
mandatory = True,
),
"sha256": attr.string(),
"strip_prefix": attr.string(),
"output": attr.string(),
"build_file_content": attr.string(),
},
)
40 changes: 29 additions & 11 deletions common/repositories.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This file has been generated using `bazel run scripts:pinned_browsers`

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("//common/private:deb_archive.bzl", "deb_archive")
load("//common/private:dmg_archive.bzl", "dmg_archive")
load("//common/private:drivers.bzl", "local_drivers")
load("//common/private:pkg_archive.bzl", "pkg_archive")
Expand Down Expand Up @@ -96,14 +97,31 @@ exports_files(

pkg_archive(
name = "mac_edge",
url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/9c227984-0429-48e9-bade-ba93774a430a/MicrosoftEdge-122.0.2365.80.pkg",
sha256 = "4fca764d70068e29d1b4657fb4c8b28bfcd8aebc295368bb49e7560f19af0716",
url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/61b13da3-c921-482a-9166-743689310b71/MicrosoftEdge-122.0.2365.92.pkg",
sha256 = "304243a7ef631781b707c0d9cb8fd35e718cebad91c29078e389bb4e813afef9",
move = {
"MicrosoftEdge-122.0.2365.80.pkg/Payload/Microsoft Edge.app": "Edge.app",
"MicrosoftEdge-122.0.2365.92.pkg/Payload/Microsoft Edge.app": "Edge.app",
},
build_file_content = "exports_files([\"Edge.app\"])",
)

deb_archive(
name = "linux_edge",
url = "https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-stable/microsoft-edge-stable_122.0.2365.92-1_amd64.deb",
sha256 = "eab115c454b669dbc42f83b6b9ccc94ec4f2df5a2cf6be762069c75f18f703e8",
build_file_content = """
filegroup(
name = "files",
srcs = glob(["**/*"]),
visibility = ["//visibility:public"],
)
exports_files(
["opt/microsoft/msedge/microsoft-edge"],
)
""",
)

http_archive(
name = "linux_edgedriver",
url = "https://msedgedriver.azureedge.net/122.0.2365.80/edgedriver_linux64.zip",
Expand All @@ -120,8 +138,8 @@ exports_files(

http_archive(
name = "linux_chrome",
url = "https://storage.googleapis.com/chrome-for-testing-public/122.0.6261.111/linux64/chrome-linux64.zip",
sha256 = "b059c80216abd74f25a35c08c6ad601a30dfdb09588af27828a9bc7adde65bd3",
url = "https://storage.googleapis.com/chrome-for-testing-public/122.0.6261.128/linux64/chrome-linux64.zip",
sha256 = "d20be2808665743423536a2ce030ffa8f6092b9dd9a29f72cd8999ef71955700",
build_file_content = """
filegroup(
name = "files",
Expand All @@ -137,8 +155,8 @@ exports_files(

http_archive(
name = "mac_chrome",
url = "https://storage.googleapis.com/chrome-for-testing-public/122.0.6261.111/mac-x64/chrome-mac-x64.zip",
sha256 = "4754c5793fec0080e29c6df1720d09c4052b447a14239a55682948635612c0e8",
url = "https://storage.googleapis.com/chrome-for-testing-public/122.0.6261.128/mac-x64/chrome-mac-x64.zip",
sha256 = "f4efaa5dbe4e02d5d324ac862427be2facbca1bed1c75c5bacaa4c922ab5b643",
strip_prefix = "chrome-mac-x64",
patch_cmds = [
"mv 'Google Chrome for Testing.app' Chrome.app",
Expand All @@ -149,16 +167,16 @@ exports_files(

http_archive(
name = "linux_chromedriver",
url = "https://storage.googleapis.com/chrome-for-testing-public/122.0.6261.111/linux64/chromedriver-linux64.zip",
sha256 = "a73431662c53100171823855de88aea4191c66262c9f61b9829f7ecddc76b754",
url = "https://storage.googleapis.com/chrome-for-testing-public/122.0.6261.128/linux64/chromedriver-linux64.zip",
sha256 = "40aaf6063c9d88fe43dd3e5b79cc101de1662b42ccac81616ecb0310ba921103",
strip_prefix = "chromedriver-linux64",
build_file_content = "exports_files([\"chromedriver\"])",
)

http_archive(
name = "mac_chromedriver",
url = "https://storage.googleapis.com/chrome-for-testing-public/122.0.6261.111/mac-x64/chromedriver-mac-x64.zip",
sha256 = "16d7e9b92808cd8193fb00ded4c805744bfe0f89cbb647b3ddd1450226ec9212",
url = "https://storage.googleapis.com/chrome-for-testing-public/122.0.6261.128/mac-x64/chromedriver-mac-x64.zip",
sha256 = "41d2fd29a9a5b955fa908218e85ef3c4a2f997b72586c13b416196c3861152d3",
strip_prefix = "chromedriver-mac-x64",
build_file_content = "exports_files([\"chromedriver\"])",
)
54 changes: 43 additions & 11 deletions scripts/pinned_browsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,14 @@ def chrome(selected_version):


def edge():
content = ""
r = http.request("GET", "https://edgeupdates.microsoft.com/api/products")
all_data = json.loads(r.data)

edge = None
hash = None
linux = None
linux_hash = None
mac = None
mac_hash = None
version = None

for data in all_data:
Expand All @@ -155,12 +158,17 @@ def edge():
if "MacOS" == release.get("Platform"):
for artifact in release["Artifacts"]:
if "pkg" == artifact["ArtifactName"]:
edge = artifact["Location"]
hash = artifact["Hash"]
version = release["ProductVersion"]
mac = artifact["Location"]
mac_hash = artifact["Hash"]
mac_version = release["ProductVersion"]
elif "Linux" == release.get("Platform"):
for artifact in release["Artifacts"]:
if "deb" == artifact["ArtifactName"]:
linux = artifact["Location"]
linux_hash = artifact["Hash"]

if edge and hash:
return """
if mac and mac_hash:
content += """
pkg_archive(
name = "mac_edge",
url = "%s",
Expand All @@ -171,12 +179,35 @@ def edge():
build_file_content = "exports_files([\\"Edge.app\\"])",
)
""" % (
edge,
hash.lower(),
version,
mac,
mac_hash.lower(),
mac_version,
)

return ""
if linux and linux_hash:
content += """
deb_archive(
name = "linux_edge",
url = "%s",
sha256 = "%s",
build_file_content = \"\"\"
filegroup(
name = "files",
srcs = glob(["**/*"]),
visibility = ["//visibility:public"],
)
exports_files(
["opt/microsoft/msedge/microsoft-edge"],
)
\"\"\",
)
""" % (
linux,
linux_hash.lower()
)

return content


def edgedriver():
Expand Down Expand Up @@ -333,6 +364,7 @@ def print_firefox(version, workspace_name, sha_linux, sha_mac):
content = """# This file has been generated using `bazel run scripts:pinned_browsers`
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("//common/private:deb_archive.bzl", "deb_archive")
load("//common/private:dmg_archive.bzl", "dmg_archive")
load("//common/private:drivers.bzl", "local_drivers")
load("//common/private:pkg_archive.bzl", "pkg_archive")
Expand Down

0 comments on commit e9bbb29

Please sign in to comment.