Skip to content
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: 5 additions & 8 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,15 @@ common --host_per_file_copt=external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUIL
# Required to get `protobuf` compiling, which is required for `rules_closure`
common --incompatible_enable_proto_toolchain_resolution
build --incompatible_enable_cc_toolchain_resolution
build:linux --cxxopt=-std=c++17
build:linux --host_cxxopt=-std=c++17
build:macos --cxxopt=-std=c++17
build:macos --host_cxxopt=-std=c++17
build:windows --cxxopt=/std:c++17
build:windows --host_cxxopt=/std:c++17
build --cxxopt=-std=c++17
build --host_cxxopt=-std=c++17
build:windows --per_file_copt=external/protobuf\\+.*@/w
build:windows --host_per_file_copt=external/protobuf\\+.*@/w
common --define=protobuf_allow_msvc=true

# For build stamping
build --enable_platform_specific_config
common --enable_platform_specific_config
common:linux --host_platform=//:local_linux_gnu
Comment thread
shs96c marked this conversation as resolved.
common:windows --host_platform=//:local_windows_gnullvm
build:linux --workspace_status_command=scripts/build-info.sh
build:macos --workspace_status_command=scripts/build-info.sh
build:windows --workspace_status_command="powershell.exe scripts/build-info.ps1"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
uses: ./.github/workflows/bazel.yml
with:
name: Update Rust Version
run: ./go rust:version ${{ needs.parse-tag.outputs.version }} && ./go rust:update
run: ./go rust:version ${{ needs.parse-tag.outputs.version }}
artifact-name: rust-version

push-rust-version:
Expand Down Expand Up @@ -147,7 +147,7 @@ jobs:
with:
name: Run dependency updates
ref: staging/release-${{ needs.parse-tag.outputs.tag }}
run: ./go ${{ needs.parse-tag.outputs.language }}:update${{ needs.parse-tag.outputs.language == 'all' && ' && ./go rust:update' || '' }}
run: ./go ${{ needs.parse-tag.outputs.language }}:update${{ needs.parse-tag.outputs.language == 'all' }}
artifact-name: patch-dep-updates

calculate-changelog-depth:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ jobs:
uses: ./.github/workflows/bazel.yml
with:
name: Reset Versions
run: ./go ${{ needs.parse-tag.outputs.language }}:version nightly${{ needs.parse-tag.outputs.language == 'all' && ' && ./go rust:version nightly && ./go rust:update' || '' }}
run: ./go ${{ needs.parse-tag.outputs.language }}:version nightly${{ needs.parse-tag.outputs.language == 'all' && ' && ./go rust:version nightly' || '' }}
artifact-name: version-reset

update-version:
Expand Down
16 changes: 16 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,22 @@ platform(
],
)

platform(
name = "local_linux_gnu",
constraint_values = [
"@llvm//constraints/libc:gnu.2.28",
],
parents = ["@platforms//host"],
)

platform(
name = "local_windows_gnullvm",
constraint_values = [
"@rules_rs//rs/platforms/constraints:windows_gnullvm",
],
parents = ["@platforms//host"],
)

buildifier(
name = "buildifier",
lint_mode = "fix",
Expand Down
69 changes: 59 additions & 10 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,25 @@ bazel_dep(name = "aspect_rules_esbuild", version = "0.25.1")
bazel_dep(name = "aspect_rules_jest", version = "0.25.2")
bazel_dep(name = "aspect_rules_js", version = "3.0.3")
bazel_dep(name = "aspect_rules_ts", version = "3.8.6")
bazel_dep(name = "bazel_features", version = "1.43.0")
bazel_dep(name = "bazel_features", version = "1.45.0")
bazel_dep(name = "bazel_skylib", version = "1.9.0")
bazel_dep(name = "buildifier_prebuilt", version = "8.5.1")
bazel_dep(name = "contrib_rules_jvm", version = "0.32.0")
bazel_dep(name = "llvm", version = "0.7.9")
bazel_dep(name = "package_metadata", version = "0.0.7")
bazel_dep(name = "platforms", version = "1.0.0")

# If you update this, also update the prebuilt version of `protoc` we use below
bazel_dep(name = "protobuf", version = "33.5")

# Required for rules_rust to import the crates properly
bazel_dep(name = "rules_cc", version = "0.2.17", dev_dependency = True)
bazel_dep(name = "rules_cc", version = "0.2.18", dev_dependency = True)

# rules_rs pulls protobuf for optional prost support. Keep Selenium on the
# explicitly pinned protobuf version above so it stays paired with prebuilt protoc.
single_version_override(
module_name = "protobuf",
version = "33.5",
)

bazel_dep(name = "rules_android", version = "0.7.1")
bazel_dep(name = "rules_closure", version = "0.15.0")
Expand All @@ -33,7 +40,7 @@ bazel_dep(name = "rules_pkg", version = "1.2.0")
bazel_dep(name = "rules_python", version = "1.9.0")
bazel_dep(name = "rules_proto", version = "7.1.0")
bazel_dep(name = "rules_ruby", version = "0.25.0")
bazel_dep(name = "rules_rust", version = "0.69.0")
bazel_dep(name = "rules_rs", version = "0.0.61")

# Use latest rules_jvm_external for Bazel 9 compatibility
single_version_override(
Expand Down Expand Up @@ -386,15 +393,57 @@ use_repo(ruby, "bundle", "ruby", "ruby_toolchains")

register_toolchains("@ruby_toolchains//:all")

rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(versions = ["1.89.0"])
rules_rust = use_extension("@rules_rs//rs:rules_rust.bzl", "rules_rust")
use_repo(rules_rust, "rules_rust")

rust_toolchains = use_extension("@rules_rs//rs/toolchains:module_extension.bzl", "toolchains")
rust_toolchains.toolchain(
edition = "2024",
version = "1.89.0",
)
use_repo(rust_toolchains, "default_rust_toolchains")

register_toolchains("@default_rust_toolchains//:all")

# TODO: Register only Windows exec for now, full @llvm migration can be done as followup.
llvm_toolchains = use_extension("@llvm//extensions:toolchain.bzl", "toolchain")
llvm_toolchains.exec(
arch = "x86_64",
os = "windows",
)
llvm_toolchains.exec(
arch = "aarch64",
os = "windows",
)
use_repo(llvm_toolchains, "llvm_toolchains")

crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
register_toolchains("@llvm_toolchains//:all")

crate = use_extension("@rules_rs//rs:extensions.bzl", "crate")
crate.from_cargo(
name = "crates",
cargo_lockfile = "//rust:Cargo.lock",
lockfile = "//rust:Cargo.Bazel.lock",
manifests = ["//rust:Cargo.toml"],
cargo_lock = "//rust:Cargo.lock",
cargo_toml = "//rust:Cargo.toml",
platform_triples = [
"aarch64-apple-darwin",
"aarch64-pc-windows-msvc",
"aarch64-unknown-linux-gnu",
"x86_64-apple-darwin",
"x86_64-pc-windows-msvc",
"x86_64-unknown-linux-gnu",
],
)
crate.annotation(
Comment thread
shs96c marked this conversation as resolved.
crate = "bzip2-sys",
gen_build_script = "on",
)
crate.annotation(
crate = "lzma-sys",
gen_build_script = "on",
)
crate.annotation(
crate = "zstd-sys",
gen_build_script = "on",
)
use_repo(crate, "crates")

Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,7 @@ you can configure it use Bazel artifacts:

### Rust

To keep `Cargo.Bazel.lock` synchronized with `Cargo.lock`, run:

```shell
CARGO_BAZEL_REPIN=true bazel run @crates//:all
```
Rust Bazel dependencies are generated directly from `rust/Cargo.toml` and `rust/Cargo.lock`.

## Testing

Expand Down
1 change: 0 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ task :release_updates, [:tag, :channel] do |_task, arguments|
Rake::Task['update_multitool'].invoke
Rake::Task['authors'].invoke
Rake::Task['rust:version'].invoke(version)
Rake::Task['rust:update'].invoke
Rake::Task['rust:changelogs'].invoke
end

Expand Down
3 changes: 3 additions & 0 deletions common/remote-build/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ toolchain(
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
"@llvm//constraints/libc:gnu.2.28",
],
target_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
"@llvm//constraints/libc:gnu.2.28",
],
toolchain = "//common/remote-build/cc:cc-compiler-k8",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Expand All @@ -36,6 +38,7 @@ platform(
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
"@llvm//constraints/libc:gnu.2.28",
],
exec_properties = {
"container-image": "docker://docker.io/selenium/selenium-remote-build@sha256:ca164352826812f02eaa1b4dab89adcf5b3e57deb6798dd9f15d004099db59fe",
Expand Down
3 changes: 2 additions & 1 deletion rake_tasks/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
'py' => '//py/...',
'rb' => '//rb/...',
'dotnet' => '//dotnet/...',
'javascript' => '//javascript/selenium-webdriver/...'
'javascript' => '//javascript/selenium-webdriver/...',
'rust' => '//rust/...'
}.freeze

# Shared utilities used by language-specific rake tasks
Expand Down
16 changes: 0 additions & 16 deletions rake_tasks/rust.rake
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,6 @@ task :build do |_task, arguments|
Bazel.execute('build', args, '//rust:selenium-manager')
end

desc 'Update the rust lock files'
Comment thread
shs96c marked this conversation as resolved.
Comment thread
dzbarsky marked this conversation as resolved.
task :update do
# The first repin after a version bump can fail due to a stale checksum in
# Cargo.Bazel.lock; a second run lets Bazel reconcile and succeeds.
puts 'pinning cargo versions'
begin
Bazel.execute('fetch', ['--repo_env=CARGO_BAZEL_REPIN=true'], '@crates//:all')
rescue RuntimeError
puts 'repin failed, retrying...'
Bazel.execute('fetch', ['--repo_env=CARGO_BAZEL_REPIN=true'], '@crates//:all')
end
end

desc 'Pin Rust dependencies'
task pin: :update

desc 'Format Rust code with rustfmt'
task :format do
puts ' Running rustfmt...'
Expand Down
1 change: 0 additions & 1 deletion rust/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

## Common commands
- Build: `bazel build //rust/...`
- Repin crates: `CARGO_BAZEL_REPIN=true bazel run @crates//:all`

## Testing
See `rust/TESTING.md`
Expand Down
5 changes: 4 additions & 1 deletion rust/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@crates//:defs.bzl", "all_crate_deps")
load("@crates//:defs.bzl", "aliases", "all_crate_deps")
load("//rust:defs.bzl", "rust_binary", "rust_library", "rust_test", "rustfmt_config")

rustfmt_config(
Expand Down Expand Up @@ -76,6 +76,7 @@ rust_binary(
# instead of an underscore
name = "selenium-manager",
srcs = ["src/main.rs"],
aliases = aliases(),
edition = "2024",
version = "0.4.44-nightly",
visibility = ["//visibility:public"],
Expand All @@ -91,6 +92,7 @@ rust_library(
["src/**/*.rs"],
exclude = ["main.rs"],
),
aliases = aliases(),
compile_data = [
"src/resources/rules.md",
"src/resources/skills.md",
Expand Down Expand Up @@ -124,6 +126,7 @@ filegroup(
rust_test(
name = "unit",
size = "small",
aliases = aliases(),
crate = ":selenium_manager",
edition = "2024",
tags = ["no-sandbox"],
Expand Down
Loading
Loading