diff --git a/buck2/cpp/.buckconfig b/buck2/cpp/.buckconfig index 8af31dd8..28021ed9 100644 --- a/buck2/cpp/.buckconfig +++ b/buck2/cpp/.buckconfig @@ -13,26 +13,26 @@ # limitations under the License. [cells] - root = . - prelude = prelude - toolchains = toolchains - none = none +root = . +prelude = prelude +toolchains = toolchains +none = none [cell_aliases] - config = prelude - ovr_config = prelude - fbcode = none - fbsource = none - fbcode_macros = none - buck = none +config = prelude +ovr_config = prelude +fbcode = none +fbsource = none +fbcode_macros = none +buck = none # Uses a copy of the prelude bundled with the buck2 binary. You can alternatively delete this # section and vendor a copy of the prelude to the `prelude` directory of your project. [external_cells] - prelude = bundled +prelude = bundled [parser] - target_platform_detector_spec = target:root//...->prelude//platforms:default +target_platform_detector_spec = target:root//...->root//platforms:remote_platform [buck2] digest_algorithms = SHA256 @@ -44,7 +44,10 @@ cas_address = .cluster.engflow.com http_headers = [build] - execution_platforms = root//platforms:remote_platform +execution_platforms = root//platforms:remote_platform [project] - ignore = .git +ignore = .git + +[re] +remote_execution_test_build_mode = root//platforms:remote_execution_action_keys diff --git a/buck2/cpp/BUCK b/buck2/cpp/BUCK index 2fa862fd..11abfa2c 100644 --- a/buck2/cpp/BUCK +++ b/buck2/cpp/BUCK @@ -16,16 +16,12 @@ cxx_binary( name = "main", srcs = ["main.cpp"], link_style = "static", - exec_compatible_with = ["//platforms:remote_platform"], - default_target_platform = "//platforms:remote_platform", ) cxx_binary( name = "cpp", srcs = ["main.cc"], deps = [":cpp_lib"], - exec_compatible_with = ["//platforms:remote_platform"], - default_target_platform = "//platforms:remote_platform", ) cxx_library( @@ -35,8 +31,6 @@ cxx_library( ], exported_headers = glob(["**/*.h"]), visibility = ["PUBLIC"], - exec_compatible_with = ["//platforms:remote_platform"], - default_target_platform = "//platforms:remote_platform", ) cxx_test( @@ -45,7 +39,4 @@ cxx_test( deps = [ ":cpp_lib", ], - exec_compatible_with = ["//platforms:remote_platform"], - default_target_platform = "//platforms:remote_platform", - remote_execution_action_key_providers = "//platforms:remote_execution_action_keys", ) diff --git a/buck2/cpp/README.md b/buck2/cpp/README.md index a336db64..a4566deb 100644 --- a/buck2/cpp/README.md +++ b/buck2/cpp/README.md @@ -49,11 +49,11 @@ Clone the repository and replace the relevant configs in `.buckconfig`. Build the example: ``` -buck2 build //:cpp_lib +buck2 build --remote-only //:cpp_lib ``` Test the example: ``` -buck2 test //:cpp_test +buck2 test --remote-only //:cpp_test ``` diff --git a/buck2/golang/.buckconfig b/buck2/golang/.buckconfig index 8e773e99..e411992c 100644 --- a/buck2/golang/.buckconfig +++ b/buck2/golang/.buckconfig @@ -1,20 +1,20 @@ [cells] - root = . - prelude = prelude - toolchains = toolchains - none = none +root = . +prelude = prelude +toolchains = toolchains +none = none [cell_aliases] - config = prelude - fbcode = none - fbsource = none - buck = none +config = prelude +fbcode = none +fbsource = none +buck = none [external_cells] - prelude = bundled +prelude = bundled [parser] - target_platform_detector_spec = target:root//...->prelude//platforms:default +target_platform_detector_spec = target:root//...->root//platforms:remote_platform [buck2] digest_algorithms = SHA256 @@ -26,7 +26,10 @@ cas_address = .cluster.engflow.com http_headers = [build] - execution_platforms = root//platforms:remote_platform +execution_platforms = root//platforms:remote_platform [project] - ignore = .git +ignore = .git + +[re] +remote_execution_test_build_mode = root//platforms:remote_execution_action_keys diff --git a/buck2/golang/README.md b/buck2/golang/README.md index adda6072..ae6db264 100644 --- a/buck2/golang/README.md +++ b/buck2/golang/README.md @@ -13,7 +13,7 @@ It is based on three existing samples in the Buck2 upstream repo and the EngFlow In the `platforms` cell we specify: * The platform used for remote execution in this project `root//platforms:remote_platform`, which includes the definition of the Docker image used for remote execution, and that defines constraints for targets to run in the remote execution environment. This platform provides an `ExecutionPlatformRegistrationInfo`. * The action keys `root//platforms:remote_execution_action_keys`, which provides a default `BuildModeInfo` that is needed for RE of tests to function properly. -* The platform `image` configured in `platforms/defs.bzl`, notably, uses a different image than other Buck2 samples in this repo. Specifically, it uses a public AWS image that has `go` preinstalled. This is because, unlike Bazel go rules, Buck2 go rules do not include a hermetic go binary. +* The platform `image` configured in `platforms/defs.bzl`, notably, uses a different image than other Buck2 samples in this repo. Specifically, it uses a public AWS image that has `go` preinstalled. This is because, unlike Bazel go rules, Buck2 go rules do not include a hermetic go binary. Image details can be found in https://gallery.ecr.aws/docker/library/golang. he Dockerfile can be found in https://github.com/docker-library/golang/blob/master/1.23/bookworm/Dockerfile. In the `toolchains` cell we specify: @@ -27,13 +27,13 @@ The `main` cell and `library` cell: To test this cell with RE run (after setting up `.buckconfig` as indicated below): ``` -buck2 test //go/greeting:greeting_test +buck2 test --remote-only //go/greeting:greeting_test ``` You can also build the `main` for this sample by running: ``` -buck2 build //go:hello +buck2 build --remote-only //go:hello ``` ### Relevant configs in `.buckconfig` diff --git a/buck2/golang/go/greeting/BUCK b/buck2/golang/go/greeting/BUCK index 1af167a4..3763f835 100644 --- a/buck2/golang/go/greeting/BUCK +++ b/buck2/golang/go/greeting/BUCK @@ -21,5 +21,4 @@ go_library( go_test( name = "greeting_test", srcs = glob(["*.go"]), - remote_execution_action_key_providers = "//platforms:remote_execution_action_keys", ) diff --git a/buck2/golang/platforms/defs.bzl b/buck2/golang/platforms/defs.bzl index 0bef8330..59fee93d 100644 --- a/buck2/golang/platforms/defs.bzl +++ b/buck2/golang/platforms/defs.bzl @@ -25,6 +25,7 @@ def _platforms(ctx): # A bookworm image with go pre-installed. # Unlike Bazel go_toolchain, Buck2 go_toolchain does not include a hermetic go binary. Image details can be found in https://gallery.ecr.aws/docker/library/golang. + # The Dockerfile can be found in https://github.com/docker-library/golang/blob/master/1.23/bookworm/Dockerfile. image = "docker://public.ecr.aws/docker/library/golang:1.23.3-bookworm@sha256:3f3b9daa3de608f3e869cd2ff8baf21555cf0fca9fd34251b8f340f9b7c30ec5" name = ctx.label.raw_target() platform = ExecutionPlatformInfo( @@ -46,6 +47,7 @@ def _platforms(ctx): return [ DefaultInfo(), ExecutionPlatformRegistrationInfo(platforms = [platform]), + PlatformInfo(label = str(name), configuration = configuration), ] def _action_keys(ctx): @@ -55,7 +57,7 @@ def _action_keys(ctx): ] platforms = rule( - attrs = {}, + attrs = {}, impl = _platforms ) diff --git a/buck2/python/.buckconfig b/buck2/python/.buckconfig index 8e773e99..e411992c 100644 --- a/buck2/python/.buckconfig +++ b/buck2/python/.buckconfig @@ -1,20 +1,20 @@ [cells] - root = . - prelude = prelude - toolchains = toolchains - none = none +root = . +prelude = prelude +toolchains = toolchains +none = none [cell_aliases] - config = prelude - fbcode = none - fbsource = none - buck = none +config = prelude +fbcode = none +fbsource = none +buck = none [external_cells] - prelude = bundled +prelude = bundled [parser] - target_platform_detector_spec = target:root//...->prelude//platforms:default +target_platform_detector_spec = target:root//...->root//platforms:remote_platform [buck2] digest_algorithms = SHA256 @@ -26,7 +26,10 @@ cas_address = .cluster.engflow.com http_headers = [build] - execution_platforms = root//platforms:remote_platform +execution_platforms = root//platforms:remote_platform [project] - ignore = .git +ignore = .git + +[re] +remote_execution_test_build_mode = root//platforms:remote_execution_action_keys diff --git a/buck2/python/README.md b/buck2/python/README.md index ff0e9af6..b2e63da2 100644 --- a/buck2/python/README.md +++ b/buck2/python/README.md @@ -26,7 +26,7 @@ The `main` cell and `library` cell: To test these cells with RE run (after setting up `.buckconfig` as indicated below): ``` -buck2 build //main:check_main +buck2 build --remote-only //main:check_main ``` The `hello` cell: @@ -36,7 +36,7 @@ The `hello` cell: To test this cell with RE run (after setting up `.buckconfig` as indicated below): ``` -buck2 test //hello:hello_unittest_test +buck2 test --remote-only //hello:hello_unittest_test ``` ### Relevant configs in `.buckconfig` diff --git a/buck2/python/hello/BUCK b/buck2/python/hello/BUCK index 77655db3..d9902ed7 100644 --- a/buck2/python/hello/BUCK +++ b/buck2/python/hello/BUCK @@ -30,5 +30,4 @@ python_test( name = "hello_unittest_test", srcs = ["hello_unittest_test.py"], deps = [":hellolib"], - remote_execution_action_key_providers = "//platforms:remote_execution_action_keys", ) diff --git a/buck2/python/platforms/defs.bzl b/buck2/python/platforms/defs.bzl index 419dc3f4..ffc1429a 100644 --- a/buck2/python/platforms/defs.bzl +++ b/buck2/python/platforms/defs.bzl @@ -45,6 +45,7 @@ def _platforms(ctx): return [ DefaultInfo(), ExecutionPlatformRegistrationInfo(platforms = [platform]), + PlatformInfo(label = str(name), configuration = configuration), ] def _action_keys(ctx): @@ -54,7 +55,7 @@ def _action_keys(ctx): ] platforms = rule( - attrs = {}, + attrs = {}, impl = _platforms ) diff --git a/buck2/rust/.buckconfig b/buck2/rust/.buckconfig index fc5ca33f..e411992c 100644 --- a/buck2/rust/.buckconfig +++ b/buck2/rust/.buckconfig @@ -30,3 +30,6 @@ execution_platforms = root//platforms:remote_platform [project] ignore = .git + +[re] +remote_execution_test_build_mode = root//platforms:remote_execution_action_keys diff --git a/buck2/rust/BUCK b/buck2/rust/BUCK index 2542c69f..5eed858d 100644 --- a/buck2/rust/BUCK +++ b/buck2/rust/BUCK @@ -34,9 +34,4 @@ rust_test( ["test/**/*.rs"], ), deps = [":library"], - # TODO: remove these once https://github.com/facebook/buck2/pull/826 gets merged. - remote_execution_action_key_providers = select({ - "//platforms:engflow": "//platforms:remote_execution_action_keys", - "DEFAULT": None, - }), ) diff --git a/buck2/rust/platforms/BUCK b/buck2/rust/platforms/BUCK index 67a4d912..8e4f659a 100644 --- a/buck2/rust/platforms/BUCK +++ b/buck2/rust/platforms/BUCK @@ -15,21 +15,11 @@ load(":defs.bzl", "platforms") load(":defs.bzl", "action_keys") -constraint_setting( - name = "re_provider" -) - -constraint_value( - name = "engflow", - constraint_setting = ":re_provider", -) - # This platform configures details of remote execution. platforms( name = "remote_platform", cpu_configuration = "config//cpu:x86_64", os_configuration = "config//os:linux", - re_provider = ":engflow", ) # This action_key provides a default BuildModeInfo that is needed for RE of tests to function properly. diff --git a/buck2/rust/platforms/defs.bzl b/buck2/rust/platforms/defs.bzl index 386a109e..3e52d51b 100644 --- a/buck2/rust/platforms/defs.bzl +++ b/buck2/rust/platforms/defs.bzl @@ -20,7 +20,6 @@ def _platforms(ctx): constraints = dict() constraints.update(ctx.attrs.cpu_configuration[ConfigurationInfo].constraints) constraints.update(ctx.attrs.os_configuration[ConfigurationInfo].constraints) - constraints.update(ctx.attrs.re_provider[ConfigurationInfo].constraints) configuration = ConfigurationInfo( constraints = constraints, values = {}, @@ -63,7 +62,6 @@ platforms = rule( attrs = { "cpu_configuration": attrs.dep(providers = [ConfigurationInfo]), "os_configuration": attrs.dep(providers = [ConfigurationInfo]), - "re_provider": attrs.dep(providers = [ConfigurationInfo]), }, impl = _platforms ) diff --git a/infra/setup-buck2.sh b/infra/setup-buck2.sh index e6d8a2ad..a428eb54 100755 --- a/infra/setup-buck2.sh +++ b/infra/setup-buck2.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash set -xe -# Get the Buck2 binary - pinned to https://github.com/facebook/buck2/releases/tag/2024-12-16 -curl -L -O https://github.com/facebook/buck2/releases/download/2024-12-16/buck2-x86_64-unknown-linux-musl.zst +# Get the Buck2 binary - pinned to https://github.com/facebook/buck2/releases/tag/2024-03-01 +curl -L -O https://github.com/facebook/buck2/releases/download/2025-03-01/buck2-x86_64-unknown-linux-musl.zst # Unpack the binary. unzstd buck2-x86_64-unknown-linux-musl.zst diff --git a/infra/test-buck2.sh b/infra/test-buck2.sh index 6dd778bb..0fbde1e5 100755 --- a/infra/test-buck2.sh +++ b/infra/test-buck2.sh @@ -6,20 +6,20 @@ alias buck2="$(realpath buck2-exe)" # Run cpp example cd buck2/cpp -buck2 build //:cpp_lib -buck2 test //:cpp_test +buck2 build --remote-only //:cpp_lib +buck2 test --remote-only //:cpp_test cd .. # Run python example cd python -buck2 build //main:check_main -buck2 test //hello:hello_unittest_test +buck2 build --remote-only //main:check_main +buck2 test --remote-only //hello:hello_unittest_test cd .. # Run go example cd golang -buck2 build //go:hello -buck2 test //go/greeting:greeting_test +buck2 build --remote-only //go:hello +buck2 test --remote-only //go/greeting:greeting_test cd .. # Run rust example