Skip to content

Commit

Permalink
Merge branch 'SeleniumHQ:trunk' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangwt-cn committed Mar 21, 2024
2 parents 0a8c20e + 8640896 commit 3014648
Show file tree
Hide file tree
Showing 80 changed files with 7,040 additions and 80,846 deletions.
2 changes: 2 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ dotnet/src/webdriver/obj
java/build/production
java/client/build
java/server/build
javascript/grid-ui/node_modules
javascript/node/selenium-webdriver/node_modules
node_modules
24 changes: 17 additions & 7 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,24 @@ build --javacopt="--release 11"
build --experimental_strict_java_deps=strict
build --explicit_java_test_deps

# Ensure builds are unpolluted by the user env
# Allow spaces in runfile paths
build --nobuild_runfile_links

build --incompatible_strict_action_env
# More JS magic
build --experimental_allow_unresolved_symlinks

# Required for faster TS builds
build --@aspect_rules_ts//ts:skipLibCheck=always
fetch --@aspect_rules_ts//ts:skipLibCheck=always
query --@aspect_rules_ts//ts:skipLibCheck=always

# Except for the PATH environment variable
build --@aspect_rules_ts//ts:default_to_tsc_transpiler
fetch --@aspect_rules_ts//ts:default_to_tsc_transpiler
query --@aspect_rules_ts//ts:default_to_tsc_transpiler

build --action_env=PATH
# Ensure builds are unpolluted by the user env

build --incompatible_strict_action_env

# For build stamping

Expand All @@ -53,7 +64,6 @@ test --test_env=DISPLAY
test --test_env=FIREFOX_NIGHTLY_BINARY
test --test_env=GITHUB_ACTIONS
test --test_env=MOZ_HEADLESS
test --test_env=PATH # Remove once browser pinning works
test --test_env=SELENIUM_BROWSER
test --test_env=TRAVIS
test --test_env=PYTHON_VERSION
Expand All @@ -70,8 +80,8 @@ test --test_env=JRUBY_OPTS="--dev"

# JRuby/TruffleRuby: https://github.com/jruby/jruby/issues/5661

build --action_env=HOME
test --test_env=HOME
#build --action_env=HOME
#test --test_env=HOME

# Expose necessary variables for Selenium-Manager.

Expand Down
20 changes: 1 addition & 19 deletions .github/workflows/ci-javascript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,4 @@ jobs:
cache-key: node
run: |
export SELENIUM_BROWSER=${{ matrix.browser }}
bazel test --flaky_test_attempts 3 //javascript/node/selenium-webdriver:tests
# As soon as this gets merged https://github.com/facebook/jest/pull/9351, we should upgrade Jest and
# run bazel test javascript/grid-ui:test for these tests
grid-ui:
name: Grid UI Tests
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout source tree
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18
- name: NPM install
run: cd javascript/grid-ui && npm install
- name: Run unit tests
run: cd javascript/grid-ui && npm test
bazel test --flaky_test_attempts 3 //javascript/node/selenium-webdriver:${{matrix.browser}}-browser-tests
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ junitvmwatcher*.properties
test-output/
.*.swp
*~
.aspect/
common/build
/build/
cpp/iedriver/IEReturnTypes.h
Expand Down
6 changes: 6 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Disabling pnpm [hoisting](https://pnpm.io/npmrc#hoist) by setting `hoist=false` is recommended on
# projects using rules_js so that pnpm outside of Bazel lays out a node_modules tree similar to what
# rules_js lays out under Bazel (without a hidden node_modules/.pnpm/node_modules). See
# https://github.com/aspect-build/rules_js/blob/7377f2d0387cc2a9251137929b1c53ccdb3fbcf0/docs/npm_import.md#npm_translate_lock
# documentation for more information.
hoist=false
14 changes: 14 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
load("@aspect_rules_js//npm:defs.bzl", "npm_link_package")
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//common:browsers.bzl", "chrome_data", "firefox_data")
load("//java:browsers.bzl", "chrome_jvm_flags", "firefox_jvm_flags")
load("//java:defs.bzl", "artifact")

exports_files([
"package.json",
"pnpm-workspace.yaml",
])

npm_link_all_packages(name = "node_modules")

filegroup(
name = "license",
srcs = [
Expand Down Expand Up @@ -53,6 +62,11 @@ java_binary(
],
)

npm_link_package(
name = "node_modules/selenium-webdriver",
src = "//javascript/node/selenium-webdriver",
)

platform(
name = "rosetta",
constraint_values = [
Expand Down
89 changes: 77 additions & 12 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@ load("@maven//:defs.bzl", "pinned_maven_install")

pinned_maven_install()

# Stop `aspect_rules_js` and `rules_dotnet` from fighting over `aspect_bazel_lib`
http_archive(
name = "aspect_bazel_lib",
sha256 = "4d6010ca5e3bb4d7045b071205afa8db06ec11eb24de3f023d74d77cca765f66",
strip_prefix = "bazel-lib-1.39.0",
url = "https://github.com/aspect-build/bazel-lib/releases/download/v1.39.0/bazel-lib-v1.39.0.tar.gz",
)

http_archive(
name = "rules_dotnet",
sha256 = "d01b0f44e58224deeb8ac81afe8701385d41b16c8028709d3a4ed5b46f1c48a0",
Expand Down Expand Up @@ -231,7 +239,12 @@ load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_regi

rules_rust_dependencies()

rust_register_toolchains()
rust_register_toolchains(
edition = "2021",
versions = [
"1.76.0",
],
)

load("@rules_rust//crate_universe:defs.bzl", "crates_repository")

Expand All @@ -247,26 +260,78 @@ load("@crates//:defs.bzl", "crate_repositories")
crate_repositories()

http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "709cc0dcb51cf9028dd57c268066e5bc8f03a119ded410a13b5c3925d6e43c48",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.4/rules_nodejs-5.8.4.tar.gz"],
name = "aspect_rules_js",
sha256 = "a2f941e27f02e84521c2d47fd530c66d57dd6d6e44b4a4f1496fe304851d8e48",
strip_prefix = "rules_js-1.35.0",
url = "https://github.com/aspect-build/rules_js/releases/download/v1.35.0/rules_js-v1.35.0.tar.gz",
)

load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies")
load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

build_bazel_rules_nodejs_dependencies()
rules_js_dependencies()

load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "npm_install")
load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")

node_repositories(
nodejs_register_toolchains(
name = "nodejs",
node_version = "18.17.0",
)

npm_install(
load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")

npm_translate_lock(
name = "npm",
package_json = "//:package.json",
package_lock_json = "//:package-lock.json",
symlink_node_modules = False,
data = [
"@//:package.json",
"@//:pnpm-workspace.yaml",
"@//javascript/grid-ui:package.json",
"@//javascript/node/selenium-webdriver:package.json",
],
generate_bzl_library_targets = True,
npmrc = "//:.npmrc",
pnpm_lock = "//:pnpm-lock.yaml",
update_pnpm_lock = True,
verify_node_modules_ignored = "//:.bazelignore",
)

load("@npm//:repositories.bzl", "npm_repositories")

npm_repositories()

http_archive(
name = "aspect_rules_ts",
sha256 = "bd3e7b17e677d2b8ba1bac3862f0f238ab16edb3e43fb0f0b9308649ea58a2ad",
strip_prefix = "rules_ts-2.1.0",
url = "https://github.com/aspect-build/rules_ts/releases/download/v2.1.0/rules_ts-v2.1.0.tar.gz",
)

load("@aspect_rules_ts//ts:repositories.bzl", "rules_ts_dependencies")

rules_ts_dependencies(
ts_version = "4.9.5",
)

load("@bazel_features//:deps.bzl", "bazel_features_deps")

bazel_features_deps()

http_archive(
name = "aspect_rules_esbuild",
sha256 = "999349afef62875301f45ec8515189ceaf2e85b1e67a17e2d28b95b30e1d6c0b",
strip_prefix = "rules_esbuild-0.18.0",
url = "https://github.com/aspect-build/rules_esbuild/releases/download/v0.18.0/rules_esbuild-v0.18.0.tar.gz",
)

load("@aspect_rules_esbuild//esbuild:dependencies.bzl", "rules_esbuild_dependencies")

rules_esbuild_dependencies()

# Register a toolchain containing esbuild npm package and native bindings
load("@aspect_rules_esbuild//esbuild:repositories.bzl", "esbuild_register_toolchains")

esbuild_register_toolchains(
name = "esbuild",
esbuild_version = "0.19.9",
)

http_archive(
Expand Down
15 changes: 14 additions & 1 deletion common/extensions/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")

filegroup(
name = "extensions",
srcs = glob([
Expand All @@ -9,12 +11,22 @@ filegroup(
"//java/test/org/openqa/selenium/edge:__pkg__",
"//java/test/org/openqa/selenium/environment:__pkg__",
"//java/test/org/openqa/selenium/firefox:__pkg__",
"//javascript/node/selenium-webdriver:__pkg__",
"//javascript/node/selenium-webdriver:__subpackages__",
"//py:__pkg__",
"//rb/spec:__subpackages__",
],
)

js_library(
name = "js-lib",
data = [
":extensions",
],
visibility = [
"//javascript/node/selenium-webdriver:__subpackages__",
],
)

exports_files(
[
"webextensions-selenium-example.xpi",
Expand All @@ -23,6 +35,7 @@ exports_files(
],
visibility = [
"//java/test/org/openqa/selenium/firefox:__pkg__",
"//javascript/node/selenium-webdriver:__subpackages__",
"//py:__pkg__",
],
)
4 changes: 4 additions & 0 deletions common/private/drivers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ def _symlink_if_available(repository_ctx, driver_name):

return "\n".join([
"bool_setting(name = \"use_%s\", build_setting_default = %s)" % (driver_name, driver != None),
"",
"exports_files([\"%s\"])" % driver_name,
"",
"""js_library(name = "%s-js", data = [":%s"])""" % (driver_name, driver_name),
"",
])

def _local_drivers_impl(repository_ctx):
contents = [
"load(\"@bazel_skylib//rules:common_settings.bzl\", \"bool_setting\")",
"load(\"@aspect_rules_js//js:defs.bzl\", \"js_library\")",
"",
"package(default_visibility = [\"//visibility:public\"])",
_symlink_if_available(repository_ctx, "chromedriver"),
Expand Down

0 comments on commit 3014648

Please sign in to comment.