Skip to content

Commit

Permalink
feat(bazel): support browsers for m1 platform
Browse files Browse the repository at this point in the history
  • Loading branch information
devversion committed Sep 3, 2021
1 parent 3c4e3ea commit 0ffac18
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 53 deletions.
1 change: 1 addition & 0 deletions bazel/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ filegroup(
"//bazel/api-golden:files",
"//bazel/benchmark:files",
"//bazel/browsers:files",
"//bazel/constraints:files",
"//bazel/remote-execution:files",
],
visibility = ["//:npm"],
Expand Down
18 changes: 11 additions & 7 deletions bazel/browsers/chromium/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ browser(
deps = [
"@io_bazel_rules_webtesting//go/wsl",
] + select({
"@io_bazel_rules_webtesting//common/conditions:linux": [
"@org_chromium_chromedriver_amd64//:metadata",
"@org_chromium_chromium_amd64//:metadata",
"//bazel/constraints:linux_x64": [
"@org_chromium_chromedriver_linux_x64//:metadata",
"@org_chromium_chromium_linux_x64//:metadata",
],
"@io_bazel_rules_webtesting//common/conditions:mac": [
"@org_chromium_chromedriver_macos//:metadata",
"@org_chromium_chromium_macos//:metadata",
"//bazel/constraints:macos_x64": [
"@org_chromium_chromedriver_macos_x64//:metadata",
"@org_chromium_chromium_macos_x64//:metadata",
],
"@io_bazel_rules_webtesting//common/conditions:windows": [
"//bazel/constraints:macos_arm64": [
"@org_chromium_chromedriver_macos_arm64//:metadata",
"@org_chromium_chromium_macos_arm64//:metadata",
],
"//bazel/constraints:windows_x32": [
"@org_chromium_chromedriver_windows//:metadata",
"@org_chromium_chromium_windows//:metadata",
],
Expand Down
79 changes: 53 additions & 26 deletions bazel/browsers/chromium/chromium.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,67 +10,94 @@ def define_chromium_repositories():
# https://github.com/angular/dev-infra/blob/master/bazel/browsers/README.md.

browser_archive(
name = "org_chromium_chromium_amd64",
name = "org_chromium_chromium_linux_x64",
licenses = ["notice"], # BSD 3-clause (maybe more?)
sha256 = "e2ce3260ad798151b88ee6ce53027533f0a596c311d960a514e82bf87c217ab3",
# 93.0.4532.0
sha256 = "673ee08b4cfaff128ef0b4f7517acb6b6b25c9315fc6494ec328ab38aaf952d1",
# 94.0.4578.0
urls = [
"https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/888689/chrome-linux.zip",
"https://storage.googleapis.com/dev-infra-mirror/chromium/888689/chrome-linux.zip",
"https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/902390/chrome-linux.zip",
"https://storage.googleapis.com/dev-infra-mirror/chromium/902390/chrome-linux.zip",
],
named_files = {
"CHROMIUM": "chrome-linux/chrome",
},
)

browser_archive(
name = "org_chromium_chromium_macos",
name = "org_chromium_chromium_macos_x64",
licenses = ["notice"], # BSD 3-clause (maybe more?)
sha256 = "46093b750f1efe5575bdb0a4dc8a229fbfaf5e1801f19c9480232c6ad3b35330",
# 93.0.4532.0
sha256 = "75f6bd26744368cd0fcbbec035766dea82e34def60e938fb48630be6799d46c7",
# 94.0.4578.0
urls = [
"https://storage.googleapis.com/chromium-browser-snapshots/Mac/888689/chrome-mac.zip",
"https://storage.googleapis.com/dev-infra-mirror/chromium/888689/chrome-mac.zip",
"https://storage.googleapis.com/chromium-browser-snapshots/Mac/902390/chrome-mac.zip",
"https://storage.googleapis.com/dev-infra-mirror/chromium/902390/chrome-mac_x64.zip",
],
named_files = {
"CHROMIUM": "chrome-mac/Chromium.app/Contents/MacOS/chromium",
"CHROMIUM": "chrome-mac/Chromium.app/Contents/MacOS/Chromium",
},
)

browser_archive(
name = "org_chromium_chromium_macos_arm64",
licenses = ["notice"], # BSD 3-clause (maybe more?)
sha256 = "4845ce895d030aeb8bfd877a599f1f07d8c7a77d1e08513e80e60bb0093fca24",
# 94.0.4578.0
urls = [
"https://storage.googleapis.com/chromium-browser-snapshots/Mac_Arm/902390/chrome-mac.zip",
"https://storage.googleapis.com/dev-infra-mirror/chromium/902390/chrome-mac_arm64.zip",
],
named_files = {
"CHROMIUM": "chrome-mac/Chromium.app/Contents/MacOS/Chromium",
},
)

browser_archive(
name = "org_chromium_chromium_windows",
licenses = ["notice"], # BSD 3-clause (maybe more?)
sha256 = "27398cdf31bcb070e60f0339330c4ebd9ff44f62c76b55b39c2b329e0ce63f58",
# 93.0.4532.0
sha256 = "8919cd2f8a4676af4acc50d022b6a946a5b21a5fec4e078b0ebb0c8e18f1ce90",
# 94.0.4578.0
urls = [
"https://storage.googleapis.com/chromium-browser-snapshots/Win/888689/chrome-win.zip",
"https://storage.googleapis.com/dev-infra-mirror/chromium/888689/chrome-win.zip",
"https://storage.googleapis.com/chromium-browser-snapshots/Win/902390/chrome-win.zip",
"https://storage.googleapis.com/dev-infra-mirror/chromium/902390/chrome-win.zip",
],
named_files = {
"CHROMIUM": "chrome-win/chrome.exe",
},
)

browser_archive(
name = "org_chromium_chromedriver_amd64",
name = "org_chromium_chromedriver_linux_x64",
licenses = ["reciprocal"], # BSD 3-clause, ICU, MPL 1.1, libpng (BSD/MIT-like), Academic Free License v. 2.0, BSD 2-clause, MIT
sha256 = "f898364b4e237101748ef9bb6a44715b3840422270bdca25f0a98eba2eb8d732",
sha256 = "1d2e73a19632031f5de876916e12b497d5b0e3dc83d1ce2fbe8665061adfd114",
urls = [
"https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/888689/chromedriver_linux64.zip",
"https://storage.googleapis.com/dev-infra-mirror/chromium/888689/chromedriver_linux64.zip",
"https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/902390/chromedriver_linux64.zip",
"https://storage.googleapis.com/dev-infra-mirror/chromium/902390/chromedriver_linux64.zip",
],
named_files = {
"CHROMEDRIVER": "chromedriver_linux64/chromedriver",
},
)

browser_archive(
name = "org_chromium_chromedriver_macos",
name = "org_chromium_chromedriver_macos_x64",
licenses = ["reciprocal"], # BSD 3-clause, ICU, MPL 1.1, libpng (BSD/MIT-like), Academic Free License v. 2.0, BSD 2-clause, MIT
sha256 = "36cc50c5194767b043913534f6ec16a7d7a85636b319729a67ffff486b30a5f6",
urls = [
"https://storage.googleapis.com/chromium-browser-snapshots/Mac/902390/chromedriver_mac64.zip",
"https://storage.googleapis.com/dev-infra-mirror/chromium/902390/chromedriver_mac_x64.zip",
],
named_files = {
"CHROMEDRIVER": "chromedriver_mac64/chromedriver",
},
)

browser_archive(
name = "org_chromium_chromedriver_macos_arm64",
licenses = ["reciprocal"], # BSD 3-clause, ICU, MPL 1.1, libpng (BSD/MIT-like), Academic Free License v. 2.0, BSD 2-clause, MIT
sha256 = "c297fa1a3dccdf40cf4c7b67ca302eca135aac09a67dfddc57f25b93cea0835c",
sha256 = "1f100aacf4bab4b3ac4218ecf654b17d66f2e07dd455f887bb3d9aa8d21862e1",
urls = [
"https://storage.googleapis.com/chromium-browser-snapshots/Mac/888689/chromedriver_mac64.zip",
"https://storage.googleapis.com/dev-infra-mirror/chromium/888689/chromedriver_mac64.zip",
"https://storage.googleapis.com/chromium-browser-snapshots/Mac_Arm/902390/chromedriver_mac64.zip",
"https://storage.googleapis.com/dev-infra-mirror/chromium/902390/chromedriver_mac_arm64.zip",
],
named_files = {
"CHROMEDRIVER": "chromedriver_mac64/chromedriver",
Expand All @@ -80,10 +107,10 @@ def define_chromium_repositories():
browser_archive(
name = "org_chromium_chromedriver_windows",
licenses = ["reciprocal"], # BSD 3-clause, ICU, MPL 1.1, libpng (BSD/MIT-like), Academic Free License v. 2.0, BSD 2-clause, MIT
sha256 = "2f2bd5f090f605797d81a50684daf9e84ffc5d049ca1341c3b9c3801daf37e86",
sha256 = "48392698f2ba338a0b9192f7c2154058a0b0b926aef0a5ef22aa6706b2bbc7b6",
urls = [
"https://storage.googleapis.com/chromium-browser-snapshots/Win/888689/chromedriver_win32.zip",
"https://storage.googleapis.com/dev-infra-mirror/chromium/888689/chromedriver_win32.zip",
"https://storage.googleapis.com/chromium-browser-snapshots/Win/902390/chromedriver_win32.zip",
"https://storage.googleapis.com/dev-infra-mirror/chromium/902390/chromedriver_win32.zip",
],
named_files = {
"CHROMEDRIVER": "chromedriver_win32/chromedriver.exe",
Expand Down
19 changes: 11 additions & 8 deletions bazel/browsers/chromium/find-stable-revision-for-all-platforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,25 @@ import {Spinner} from '../../../ng-dev/utils/spinner';
* See: https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html.
*/
enum BrowserPlatform {
LINUX = 'Linux_x64',
MAC = 'Mac',
LINUX_X64 = 'Linux_x64',
MAC_X64 = 'Mac',
MAC_ARM64 = 'Mac_Arm',
WINDOWS = 'Win',
}

/** Maps a browser platform to the archive file containing the browser binary. */
const PlatformBrowserArchiveMap = {
[BrowserPlatform.LINUX]: 'chrome-linux.zip',
[BrowserPlatform.MAC]: 'chrome-mac.zip',
[BrowserPlatform.LINUX_X64]: 'chrome-linux.zip',
[BrowserPlatform.MAC_X64]: 'chrome-mac.zip',
[BrowserPlatform.MAC_ARM64]: 'chrome-mac.zip',
[BrowserPlatform.WINDOWS]: 'chrome-win.zip',
};

/** Maps a browser platform to the archive file containing the driver. */
const PlatformDriverArchiveMap = {
[BrowserPlatform.LINUX]: 'chromedriver_linux64.zip',
[BrowserPlatform.MAC]: 'chromedriver_mac64.zip',
[BrowserPlatform.LINUX_X64]: 'chromedriver_linux64.zip',
[BrowserPlatform.MAC_X64]: 'chromedriver_mac64.zip',
[BrowserPlatform.MAC_ARM64]: 'chromedriver_mac64.zip',
[BrowserPlatform.WINDOWS]: 'chromedriver_win32.zip',
};

Expand Down Expand Up @@ -101,12 +104,12 @@ async function main(explicitStartRevision: number | null): Promise<void> {
);
console.info(
' '.repeat(15),
getSha256ChecksumForPlatform(availableRevision, platform, 'browser'),
await getSha256ChecksumForPlatform(availableRevision, platform, 'browser'),
);
console.info(' '.repeat(10), getRevisionArchiveUrl(availableRevision, platform, 'driver'));
console.info(
' '.repeat(15),
getSha256ChecksumForPlatform(availableRevision, platform, 'driver'),
await getSha256ChecksumForPlatform(availableRevision, platform, 'driver'),
);
console.info();
}
Expand Down
23 changes: 16 additions & 7 deletions bazel/browsers/firefox/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,31 @@ browser(
disabled = select({
# TODO: Consider adding support for Windows. Requires a portable version of
# Firefox. Official distribution only ships with installers.
"@io_bazel_rules_webtesting//common/conditions:windows": "Firefox is not supported on Windows",
"//bazel/constraints:windows_x32": "Firefox is not disabled on Windows but always passing",
"//bazel/constraints:windows_x64": "Firefox is not disabled on Windows but always passing",
# Note: We keep always keep others enabled. This will result in proper errors if e.g. a
# linux arm64 machine intends to run tests with Firefox but we miss binaries for the platform.
"//conditions:default": None,
}),
metadata = "firefox.json",
deps = [
"@io_bazel_rules_webtesting//go/wsl",
] + select({
"@io_bazel_rules_webtesting//common/conditions:linux": [
"@org_mozilla_firefox_amd64//:metadata",
"@org_mozilla_geckodriver_amd64//:metadata",
"//bazel/constraints:linux_x64": [
"@org_mozilla_firefox_linux_x64//:metadata",
"@org_mozilla_geckodriver_linux_x64//:metadata",
],
"@io_bazel_rules_webtesting//common/conditions:mac": [
"//bazel/constraints:macos_x64": [
# Firefox has a launcher that conditionally starts x64/arm64
"@org_mozilla_firefox_macos//:metadata",
"@org_mozilla_geckodriver_macos//:metadata",
"@org_mozilla_geckodriver_macos_x64//:metadata",
],
"@io_bazel_rules_webtesting//common/conditions:windows": [],
"//bazel/constraints:macos_arm64": [
# Firefox has a launcher that conditionally starts x64/arm64
"@org_mozilla_firefox_macos//:metadata",
"@org_mozilla_geckodriver_macos_arm64//:metadata",
],
"//conditions:default": [],
}),
)

Expand Down
21 changes: 18 additions & 3 deletions bazel/browsers/firefox/firefox.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def define_firefox_repositories():
# next to this file.

browser_archive(
name = "org_mozilla_firefox_amd64",
name = "org_mozilla_firefox_linux_x64",
licenses = ["reciprocal"], # MPL 2.0
sha256 = "998607f028043b3780f296eee03027279ef059acab5b50f9754df2bd69ca42b3",
# Firefox v90.0.1
Expand All @@ -24,6 +24,7 @@ def define_firefox_repositories():
)

browser_archive(
# Firefox has a launcher that conditionally starts x64/arm64
name = "org_mozilla_firefox_macos",
licenses = ["reciprocal"], # MPL 2.0
sha256 = "76c1b9c42b52c7e5be4c112a98b7d3762a18841367f778a179679ac0de751f05",
Expand All @@ -38,7 +39,7 @@ def define_firefox_repositories():
)

browser_archive(
name = "org_mozilla_geckodriver_amd64",
name = "org_mozilla_geckodriver_linux_x64",
licenses = ["reciprocal"], # MPL 2.0
sha256 = "ec164910a3de7eec71e596bd2a1814ae27ba4c9d112b611680a6470dbe2ce27b",
# Geckodriver v0.29.1
Expand All @@ -52,7 +53,7 @@ def define_firefox_repositories():
)

browser_archive(
name = "org_mozilla_geckodriver_macos",
name = "org_mozilla_geckodriver_macos_x64",
licenses = ["reciprocal"], # MPL 2.0
sha256 = "9929c804ad0157ca13fdafca808866c88815b658e7059280a9f08f7e70364963",
# Geckodriver v0.29.1
Expand All @@ -64,3 +65,17 @@ def define_firefox_repositories():
"GECKODRIVER": "geckodriver",
},
)

browser_archive(
name = "org_mozilla_geckodriver_macos_arm64",
licenses = ["reciprocal"], # MPL 2.0
sha256 = "a1ec058b930fbfb684e30071ea47eec61bc18acb489914a9e0d095ede6088eea",
# Geckodriver v0.29.1
urls = [
"https://github.com/mozilla/geckodriver/releases/download/v0.29.1/geckodriver-v0.29.1-macos-aarch64.tar.gz",
"https://storage.googleapis.com/dev-infra-mirror/mozilla/geckodriver/0.29.1/geckodriver-v0.29.1-macos-aarch64.tar.gz",
],
named_files = {
"GECKODRIVER": "geckodriver",
},
)
47 changes: 47 additions & 0 deletions bazel/constraints/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package(default_visibility = ["//visibility:public"])

config_setting(
name = "linux_x64",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
)

config_setting(
name = "macos_x64",
constraint_values = [
"@platforms//os:macos",
"@platforms//cpu:x86_64",
],
)

config_setting(
name = "macos_arm64",
constraint_values = [
"@platforms//os:macos",
"@platforms//cpu:aarch64",
],
)

config_setting(
name = "windows_x64",
constraint_values = [
"@platforms//os:windows",
"@platforms//cpu:x86_64",
],
)

config_setting(
name = "windows_x32",
constraint_values = [
"@platforms//os:windows",
"@platforms//cpu:x86_32",
],
)

# Make source files available for distribution via pkg_npm
filegroup(
name = "files",
srcs = glob(["*"]),
)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"rollup-plugin-sourcemaps": "^0.6.3",
"selenium-webdriver": "3.5.0",
"semver": "^7.3.5",
"ts-node": "^10.0.0",
"ts-node": "^10.2.1",
"tslib": "^2.3.0",
"tslint": "^6.1.3",
"typed-graphqlify": "^3.1.1",
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2904,7 +2904,7 @@ trim-off-newlines@^1.0.0:
resolved "https://registry.yarnpkg.com/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz#9f9ba9d9efa8764c387698bcbfeb2c848f11adb3"
integrity sha1-n5up2e+odkw4dpi8v+sshI8RrbM=

ts-node@^10.0.0:
ts-node@^10.2.1:
version "10.2.1"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.2.1.tgz#4cc93bea0a7aba2179497e65bb08ddfc198b3ab5"
integrity sha512-hCnyOyuGmD5wHleOQX6NIjJtYVIO8bPP8F2acWkB4W06wdlkgyvJtubO/I9NkI88hCFECbsEgoLc0VNkYmcSfw==
Expand Down

0 comments on commit 0ffac18

Please sign in to comment.