Skip to content

Commit

Permalink
[bazel] Move prebuilt selenium-manager to MODULE
Browse files Browse the repository at this point in the history
  • Loading branch information
p0deje committed Apr 18, 2024
1 parent 2749ec7 commit 70bb02a
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 62 deletions.
3 changes: 2 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,5 @@ crate.from_cargo(
)
use_repo(crate, "crates")

register_toolchains("@rust_toolchains//:all")
selenium_manager_artifacts = use_extension("//common:selenium_manager.bzl", "selenium_manager_artifacts")
use_repo(selenium_manager_artifacts, "download_sm_linux", "download_sm_macos", "download_sm_windows")
70 changes: 66 additions & 4 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 2 additions & 57 deletions WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
@@ -1,59 +1,8 @@
workspace(
name = "selenium",
)
workspace(name = "selenium")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "bazel_skylib",
sha256 = "66ffd9315665bfaafc96b52278f57c7e2dd09f5ede279ea6d39b2be471e7e3aa",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz",
],
)

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

http_archive(
name = "aspect_bazel_lib",
sha256 = "f75d03783588e054899eb0729a97fb5b8973c1a26f30373fafd485c90bf207d1",
strip_prefix = "bazel-lib-2.4.2",
url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.4.2/bazel-lib-v2.4.2.tar.gz",
)

load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies", "aspect_bazel_lib_register_toolchains")

aspect_bazel_lib_dependencies()

aspect_bazel_lib_register_toolchains()

# The go rules are often a dependency of _something_, so loading the version
# we want early
http_archive(
name = "io_bazel_rules_go",
sha256 = "6b65cb7917b4d1709f9410ffe00ecf3e160edf674b78c54a894471320862184f",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
],
)

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains(version = "1.19.3")

# 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",
)
# rules_closure are not published to BCR.

http_archive(
name = "io_bazel_rules_closure",
Expand All @@ -76,10 +25,6 @@ rules_closure_dependencies()

rules_closure_toolchains()

load("//common:selenium_manager.bzl", "selenium_manager")

selenium_manager()

load("//common:repositories.bzl", "pin_browsers")

pin_browsers()
Expand Down
7 changes: 7 additions & 0 deletions common/selenium_manager.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,10 @@ def selenium_manager():
sha256 = "13bd63fa51a75bbf1b98beb221edceed3f33bacf2e3b25cd39ef4e6ac84371eb",
url = "https://github.com/SeleniumHQ/selenium_manager_artifacts/releases/download/selenium-manager-6a15586/selenium-manager-windows.exe",
)

def _selenium_manager_artifacts_impl(_ctx):
selenium_manager()

selenium_manager_artifacts = module_extension(
implementation = _selenium_manager_artifacts_impl,
)
8 changes: 8 additions & 0 deletions scripts/selenium_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ def selenium_manager():
content = content + print_linux(base_url, sha_dict['linux'])
content = content + print_macos(base_url, sha_dict['macos'])
content = content + print_windows(base_url, sha_dict['windows'])
content += """
def _selenium_manager_artifacts_impl(_ctx):
selenium_manager()
selenium_manager_artifacts = module_extension(
implementation = _selenium_manager_artifacts_impl,
)
"""

current_script_dir = Path(os.path.realpath(__file__)).parent
target_file_path = current_script_dir.parent / "common/selenium_manager.bzl"
Expand Down

0 comments on commit 70bb02a

Please sign in to comment.