Skip to content

Add firefox linux binaries for rust_wasm_bindgen_test #3320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1067,14 +1067,13 @@ tasks:
name: Extensions wasm-bindgen
working_directory: extensions/wasm_bindgen
shell_commands:
- "sudo apt -y update && sudo apt -y install libxcb1 libatk1.0-0 libatk-bridge2.0-0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libpango-1.0-0 libxkbcommon-x11-0 libcairo2"
- "bash ./test/bazelci_linux_setup.sh"
build_flags: *aspects_flags
test_flags: *aspects_flags
build_targets:
- "//..."
# TODO: Chromedriver cannot launch chrome on linux
# test_targets:
# - "//..."
test_targets:
- "//..."
extensions_wasm_bindgen_linux_rbe:
platform: rbe_ubuntu2004
name: Extensions wasm-bindgen
Expand All @@ -1086,13 +1085,9 @@ tasks:
test_flags: *aspects_flags
build_targets:
- "//..."
# TODO: Chromedriver cannot launch chrome on linux
# TODO: https://github.com/bazelbuild/rules_rust/issues/3039
# test_targets:
# - "--"
# - "//..."
# # TODO: https://github.com/bazelbuild/rules_rust/issues/3039
# - "-//rules_js/test:hello_world_wasm_lib_test"
# - "-//rules_js/test:hello_world_wasm_direct_test"
extensions_wasm_bindgen_macos:
platform: macos_arm64
name: Extensions wasm-bindgen
Expand Down
16 changes: 15 additions & 1 deletion .bcr/extensions/wasm_bindgen/presubmit.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
bcr_test_module:
module_path: ""
matrix:
platform: ["macos_arm64", "ubuntu2004", "windows"]
platform: ["macos_arm64", "windows"]
bazel: ["7.x", "8.x"]
tasks:
run_tests:
Expand All @@ -10,3 +10,17 @@ bcr_test_module:
bazel: ${{ bazel }}
test_targets:
- "//..."
bcr_test_module_linux:
module_path: ""
matrix:
platform: ["ubuntu2004"]
bazel: ["7.x", "8.x"]
tasks:
run_tests:
shell_commands:
- "bash ./test/bazelci_linux_setup.sh"
name: "Run test module"
platform: ${{ platform }}
bazel: ${{ bazel }}
test_targets:
- "//..."
9 changes: 9 additions & 0 deletions extensions/wasm_bindgen/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ common --experimental_cc_shared_library
## Unique configuration groups
###############################################################################

# Explicitly use firefox for browser tests.
build:firefox --//settings:test_browser=firefox

# Explicitly use chrome for browser tests
build:chrome --//settings:test_browser=chrome

# Default linux to run firefox
build:linux --config=firefox

# Enable use of the nightly toolchains.
build:nightly --@rules_rust//rust/toolchain/channel=nightly

Expand Down
43 changes: 8 additions & 35 deletions extensions/wasm_bindgen/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load(":defs.bzl", "rust_wasm_bindgen_toolchain")

exports_files([
Expand All @@ -13,32 +12,6 @@ toolchain_type(
visibility = ["//visibility:public"],
)

string_flag(
name = "test_browser",
build_setting_default = "chrome",
values = [
"chrome",
"firefox",
],
visibility = ["//visibility:public"],
)

config_setting(
name = "test_browser_chrome",
flag_values = {
":test_browser": "chrome",
},
visibility = ["//visibility:public"],
)

config_setting(
name = "test_browser_firefox",
flag_values = {
":test_browser": "firefox",
},
visibility = ["//visibility:public"],
)

bzl_library(
name = "bzl_lib",
srcs = glob(["**/*.bzl"]),
Expand All @@ -52,24 +25,24 @@ bzl_library(
rust_wasm_bindgen_toolchain(
name = "default_wasm_bindgen_toolchain_impl",
browser = select({
":test_browser_chrome": "@chrome",
":test_browser_firefox": "@firefox",
"//settings:test_browser_chrome": "@chrome",
"//settings:test_browser_firefox": "@firefox",
}),
browser_type = select({
":test_browser_chrome": "chrome",
":test_browser_firefox": "firefox",
"//settings:test_browser_chrome": "chrome",
"//settings:test_browser_firefox": "firefox",
}),
visibility = ["//visibility:public"],
wasm_bindgen_cli = "//3rdparty:wasm_bindgen_cli",
wasm_bindgen_test = "//3rdparty:wasm_bindgen_test",
wasm_bindgen_test_runner = "//3rdparty:wasm_bindgen_test_runner",
webdriver = select({
":test_browser_chrome": "@chromedriver",
":test_browser_firefox": "@geckodriver",
"//settings:test_browser_chrome": "@chromedriver",
"//settings:test_browser_firefox": "@geckodriver",
}),
webdriver_args = select({
":test_browser_chrome": ["--verbose"],
":test_browser_firefox": [],
"//settings:test_browser_chrome": ["--verbose"],
"//settings:test_browser_firefox": [],
}),
webdriver_json = "webdriver.json",
)
Expand Down
3 changes: 3 additions & 0 deletions extensions/wasm_bindgen/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ use_repo(
"chromedriver_win32",
"chromedriver_win64",
"firefox",
"firefox_linux_aarch64",
"firefox_linux_x86_64",
"firefox_local",
"geckodriver",
"geckodriver_linux64",
"geckodriver_linux_aarch64",
Expand Down
7 changes: 2 additions & 5 deletions extensions/wasm_bindgen/private/webdrivers/BUILD.chrome.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ alias(

alias(
name = "chrome_linux",
actual = select({
"@platforms//cpu:aarch64": "@chrome_linux_aarch64",
"//conditions:default": "@chrome_linux64",
}),
actual = "@chrome_linux64",
target_compatible_with = ["@platforms//os:linux"],
)

Expand All @@ -28,7 +25,7 @@ alias(
alias(
name = "chrome",
actual = select({
"@platforms//os:linux": "@chrome_linux64",
"@platforms//os:linux": ":chrome_linux",
"@platforms//os:macos": ":chrome_macos",
"@platforms//os:windows": ":chrome_windows",
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ alias(

alias(
name = "chrome_headless_shell_linux",
actual = select({
"@platforms//cpu:aarch64": "@chrome_headless_shell_linux_aarch64",
"//conditions:default": "@chrome_headless_shell_linux64",
}),
actual = "@chrome_headless_shell_linux64",
target_compatible_with = ["@platforms//os:linux"],
)

Expand All @@ -28,7 +25,7 @@ alias(
alias(
name = "chrome_headless_shell",
actual = select({
"@platforms//os:linux": "@chrome_headless_shell_linux64",
"@platforms//os:linux": ":chrome_headless_shell_linux",
"@platforms//os:macos": ":chrome_headless_shell_macos",
"@platforms//os:windows": ":chrome_headless_shell_windows",
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ alias(

alias(
name = "chromedriver_linux",
actual = select({
"@platforms//cpu:aarch64": "@chromedriver_linux_aarch64",
"//conditions:default": "@chromedriver_linux64",
}),
actual = "@chromedriver_linux64",
target_compatible_with = ["@platforms//os:linux"],
)

Expand All @@ -28,7 +25,7 @@ alias(
alias(
name = "chromedriver",
actual = select({
"@platforms//os:linux": "@chromedriver_linux64",
"@platforms//os:linux": ":chromedriver_linux",
"@platforms//os:macos": ":chromedriver_macos",
"@platforms//os:windows": ":chromedriver_windows",
}),
Expand Down
30 changes: 30 additions & 0 deletions extensions/wasm_bindgen/private/webdrivers/BUILD.firefox.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
alias(
name = "firefox_macos",
actual = "@firefox_local//:firefox",
target_compatible_with = ["@platforms//os:macos"],
)

alias(
name = "firefox_linux",
actual = select({
"@platforms//cpu:aarch64": "@firefox_linux_aarch64",
"//conditions:default": "@firefox_linux_x86_64",
}),
target_compatible_with = ["@platforms//os:linux"],
)

alias(
name = "firefox_windows",
actual = "@firefox_local//:firefox",
target_compatible_with = ["@platforms//os:windows"],
)

alias(
name = "firefox",
actual = select({
"@platforms//os:linux": ":firefox_linux",
"@platforms//os:macos": ":firefox_macos",
"@platforms//os:windows": ":firefox_windows",
}),
visibility = ["//visibility:public"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ alias(
)
"""

def _local_firefox_repository_impl(repository_ctx):
def _firefox_local_repository_impl(repository_ctx):
repository_ctx.file("WORKSPACE.bazel", """workspace(name = "{}")""".format(
repository_ctx.name,
))
Expand Down Expand Up @@ -168,7 +168,7 @@ def _local_firefox_repository_impl(repository_ctx):

repository_ctx.file("BUILD.bazel", _FIREFOX_BUILD_CONTENT_WINDOWS if is_windows else _FIREFOX_BUILD_CONTENT_UNIX)

local_firefox_repository = repository_rule(
firefox_local_repository = repository_rule(
doc = """\
A repository rule for wrapping the path to a host installed firefox binary

Expand All @@ -177,7 +177,7 @@ Note that firefox binaries can be found here: https://ftp.mozilla.org/pub/firefo
However, for platforms like MacOS and Windows, the storage formats are not something that can be extracted
in a repository rule.
""",
implementation = _local_firefox_repository_impl,
implementation = _firefox_local_repository_impl,
environ = ["FIREFOX_BINARY"],
)

Expand Down Expand Up @@ -226,10 +226,41 @@ def firefox_deps():
build_file = Label("//private/webdrivers:BUILD.geckodriver.bazel"),
)

firefox_version = "136.0"

for platform, integrity in {
"linux-aarch64": "sha256-vveh8MLGr9pl8cHtvj4T/dk1wzaxYkMMfTUTkidAgAo=",
"linux-x86_64": "sha256-UiL1HKrPzK8PDPeVEX8K03Qi/p1BPvGPLBceFiK5RVo=",
}.items():
archive = "tar.xz"
tool = "firefox"
name = "firefox_{}".format(platform.replace("-", "_"))
direct_deps.append(struct(repo = name))
maybe(
webdriver_repository,
name = name,
original_name = name,
urls = ["https://ftp.mozilla.org/pub/firefox/releases/{version}/{platform}/en-US/firefox-{version}.{archive}".format(
version = firefox_version,
platform = platform,
archive = archive,
)],
strip_prefix = "firefox",
integrity = integrity,
tool = tool,
)

direct_deps.append(struct(repo = "firefox_local"))
maybe(
firefox_local_repository,
name = "firefox_local",
)

direct_deps.append(struct(repo = "firefox"))
maybe(
local_firefox_repository,
build_file_repository,
name = "firefox",
build_file = Label("//private/webdrivers:BUILD.firefox.bazel"),
)

return direct_deps
Expand Down
27 changes: 27 additions & 0 deletions extensions/wasm_bindgen/settings/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")

string_flag(
name = "test_browser",
build_setting_default = "chrome",
values = [
"chrome",
"firefox",
],
visibility = ["//visibility:public"],
)

config_setting(
name = "test_browser_chrome",
flag_values = {
":test_browser": "chrome",
},
visibility = ["//visibility:public"],
)

config_setting(
name = "test_browser_firefox",
flag_values = {
":test_browser": "firefox",
},
visibility = ["//visibility:public"],
)
21 changes: 21 additions & 0 deletions extensions/wasm_bindgen/test/bazelci_linux_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# A script for installing the necessary dependencies on Buildkite workers to run
# `rust_wasm_bindgen_test` targets.

set -euo pipefail

sudo apt -y update
sudo apt -y install \
libxcb1 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libxcomposite1 \
libxdamage1 \
libxfixes3 \
libxrandr2 \
libgbm1 \
libpango-1.0-0 \
libxkbcommon-x11-0 \
libcairo2 \
libgtk-3-0 \
libx11-xcb1