From 2ac225e444a5281e39a00652635a6ddbedf6d449 Mon Sep 17 00:00:00 2001 From: Nicolas Lopez Date: Thu, 19 Dec 2024 12:06:25 -0500 Subject: [PATCH 01/16] update buck2 samples according to recommendations in rust2 sample PR --- buck2/cpp/README.md | 4 ++-- buck2/cpp/platforms/BUCK | 10 ++++++++++ buck2/cpp/platforms/defs.bzl | 2 ++ buck2/golang/README.md | 6 +++--- buck2/golang/go/greeting/BUCK | 5 ++++- buck2/golang/platforms/BUCK | 10 ++++++++++ buck2/golang/platforms/defs.bzl | 7 ++++++- buck2/python/README.md | 4 ++-- buck2/python/hello/BUCK | 5 ++++- buck2/python/platforms/BUCK | 10 ++++++++++ buck2/python/platforms/defs.bzl | 5 ++++- infra/test-buck2.sh | 12 ++++++------ 12 files changed, 63 insertions(+), 17 deletions(-) diff --git a/buck2/cpp/README.md b/buck2/cpp/README.md index a336db64..68095ebb 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 --target-platforms //platforms:remote_platform //:cpp_lib ``` Test the example: ``` -buck2 test //:cpp_test +buck2 test --target-platforms //platforms:remote_platform //:cpp_test ``` diff --git a/buck2/cpp/platforms/BUCK b/buck2/cpp/platforms/BUCK index 8e4f659a..67a4d912 100644 --- a/buck2/cpp/platforms/BUCK +++ b/buck2/cpp/platforms/BUCK @@ -15,11 +15,21 @@ 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/cpp/platforms/defs.bzl b/buck2/cpp/platforms/defs.bzl index 830d53fb..fe221cc9 100644 --- a/buck2/cpp/platforms/defs.bzl +++ b/buck2/cpp/platforms/defs.bzl @@ -20,6 +20,7 @@ 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 = {}, @@ -61,6 +62,7 @@ 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/buck2/golang/README.md b/buck2/golang/README.md index adda6072..cf38ca73 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 --target-platforms //platforms:remote_platform //go/greeting:greeting_test ``` You can also build the `main` for this sample by running: ``` -buck2 build //go:hello +buck2 build --target-platforms //platforms:remote_platform //go:hello ``` ### Relevant configs in `.buckconfig` diff --git a/buck2/golang/go/greeting/BUCK b/buck2/golang/go/greeting/BUCK index 1af167a4..c428a305 100644 --- a/buck2/golang/go/greeting/BUCK +++ b/buck2/golang/go/greeting/BUCK @@ -21,5 +21,8 @@ go_library( go_test( name = "greeting_test", srcs = glob(["*.go"]), - remote_execution_action_key_providers = "//platforms:remote_execution_action_keys", + remote_execution_action_key_providers = select({ + "//platforms:engflow": "//platforms:remote_execution_action_keys", + "DEFAULT": None, + }), ) diff --git a/buck2/golang/platforms/BUCK b/buck2/golang/platforms/BUCK index cc1595f9..be9b5df9 100644 --- a/buck2/golang/platforms/BUCK +++ b/buck2/golang/platforms/BUCK @@ -15,9 +15,19 @@ 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", + re_provider = ":engflow", ) # This action_key provides a default BuildModeInfo that is needed for RE of tests to function properly. diff --git a/buck2/golang/platforms/defs.bzl b/buck2/golang/platforms/defs.bzl index 0bef8330..b1958c80 100644 --- a/buck2/golang/platforms/defs.bzl +++ b/buck2/golang/platforms/defs.bzl @@ -18,6 +18,7 @@ load("@prelude//:build_mode.bzl", "BuildModeInfo") def _platforms(ctx): constraints = dict() + constraints.update(ctx.attrs.re_provider[ConfigurationInfo].constraints) configuration = ConfigurationInfo( constraints = constraints, values = {}, @@ -25,6 +26,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 +48,7 @@ def _platforms(ctx): return [ DefaultInfo(), ExecutionPlatformRegistrationInfo(platforms = [platform]), + PlatformInfo(label = str(name), configuration = configuration), ] def _action_keys(ctx): @@ -55,7 +58,9 @@ def _action_keys(ctx): ] platforms = rule( - attrs = {}, + attrs = { + "re_provider": attrs.dep(providers = [ConfigurationInfo]), + }, impl = _platforms ) diff --git a/buck2/python/README.md b/buck2/python/README.md index ff0e9af6..0d3a2dbe 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 --target-platforms //platforms:remote_platform //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 --target-platforms //platforms:remote_platform //hello:hello_unittest_test ``` ### Relevant configs in `.buckconfig` diff --git a/buck2/python/hello/BUCK b/buck2/python/hello/BUCK index 77655db3..5654a42f 100644 --- a/buck2/python/hello/BUCK +++ b/buck2/python/hello/BUCK @@ -30,5 +30,8 @@ python_test( name = "hello_unittest_test", srcs = ["hello_unittest_test.py"], deps = [":hellolib"], - remote_execution_action_key_providers = "//platforms:remote_execution_action_keys", + remote_execution_action_key_providers = select({ + "//platforms:engflow": "//platforms:remote_execution_action_keys", + "DEFAULT": None, + }), ) diff --git a/buck2/python/platforms/BUCK b/buck2/python/platforms/BUCK index cc1595f9..be9b5df9 100644 --- a/buck2/python/platforms/BUCK +++ b/buck2/python/platforms/BUCK @@ -15,9 +15,19 @@ 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", + re_provider = ":engflow", ) # This action_key provides a default BuildModeInfo that is needed for RE of tests to function properly. diff --git a/buck2/python/platforms/defs.bzl b/buck2/python/platforms/defs.bzl index 419dc3f4..50f5972f 100644 --- a/buck2/python/platforms/defs.bzl +++ b/buck2/python/platforms/defs.bzl @@ -18,6 +18,7 @@ load("@prelude//:build_mode.bzl", "BuildModeInfo") def _platforms(ctx): constraints = dict() + constraints.update(ctx.attrs.re_provider[ConfigurationInfo].constraints) configuration = ConfigurationInfo( constraints = constraints, values = {}, @@ -54,7 +55,9 @@ def _action_keys(ctx): ] platforms = rule( - attrs = {}, + attrs = { + "re_provider": attrs.dep(providers = [ConfigurationInfo]), + }, impl = _platforms ) diff --git a/infra/test-buck2.sh b/infra/test-buck2.sh index 6dd778bb..37b0218f 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 --target-platforms //platforms:remote_platform //:cpp_lib +buck2 test --target-platforms //platforms:remote_platform //:cpp_test cd .. # Run python example cd python -buck2 build //main:check_main -buck2 test //hello:hello_unittest_test +buck2 build --target-platforms //platforms:remote_platform //main:check_main +buck2 test --target-platforms //platforms:remote_platform //hello:hello_unittest_test cd .. # Run go example cd golang -buck2 build //go:hello -buck2 test //go/greeting:greeting_test +buck2 build --target-platforms //platforms:remote_platform //go:hello +buck2 test --target-platforms //platforms:remote_platform //go/greeting:greeting_test cd .. # Run rust example From f7d2c7457cad4e46d213a7c598917b21807cf707 Mon Sep 17 00:00:00 2001 From: Nicolas Lopez Date: Thu, 19 Dec 2024 12:11:43 -0500 Subject: [PATCH 02/16] update buck2 samples according to recommendations in rust2 sample PR --- buck2/cpp/BUCK | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/buck2/cpp/BUCK b/buck2/cpp/BUCK index 2fa862fd..c35757a4 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,8 @@ 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", + remote_execution_action_key_providers = select({ + "//platforms:engflow": "//platforms:remote_execution_action_keys", + "DEFAULT": None, + }), ) From 1a14258dd24e8c2375f2dc28dd78a72087cd9562 Mon Sep 17 00:00:00 2001 From: Nicolas Lopez Date: Thu, 19 Dec 2024 13:56:49 -0500 Subject: [PATCH 03/16] fix python platform --- buck2/python/platforms/defs.bzl | 1 + 1 file changed, 1 insertion(+) diff --git a/buck2/python/platforms/defs.bzl b/buck2/python/platforms/defs.bzl index 50f5972f..d775e32d 100644 --- a/buck2/python/platforms/defs.bzl +++ b/buck2/python/platforms/defs.bzl @@ -46,6 +46,7 @@ def _platforms(ctx): return [ DefaultInfo(), ExecutionPlatformRegistrationInfo(platforms = [platform]), + PlatformInfo(label = str(name), configuration = configuration), ] def _action_keys(ctx): From 87cd73688cb675cb7f5c3fbd4c4a8e9d918818db Mon Sep 17 00:00:00 2001 From: Nicolas Lopez Date: Tue, 7 Jan 2025 10:06:34 -0500 Subject: [PATCH 04/16] add todo to samples --- buck2/cpp/BUCK | 1 + buck2/golang/go/greeting/BUCK | 1 + buck2/python/hello/BUCK | 1 + 3 files changed, 3 insertions(+) diff --git a/buck2/cpp/BUCK b/buck2/cpp/BUCK index c35757a4..887f35d2 100644 --- a/buck2/cpp/BUCK +++ b/buck2/cpp/BUCK @@ -39,6 +39,7 @@ cxx_test( deps = [ ":cpp_lib", ], + # 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/golang/go/greeting/BUCK b/buck2/golang/go/greeting/BUCK index c428a305..25c3b0bb 100644 --- a/buck2/golang/go/greeting/BUCK +++ b/buck2/golang/go/greeting/BUCK @@ -21,6 +21,7 @@ go_library( go_test( name = "greeting_test", srcs = glob(["*.go"]), + # 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/python/hello/BUCK b/buck2/python/hello/BUCK index 5654a42f..021500d1 100644 --- a/buck2/python/hello/BUCK +++ b/buck2/python/hello/BUCK @@ -30,6 +30,7 @@ python_test( name = "hello_unittest_test", srcs = ["hello_unittest_test.py"], deps = [":hellolib"], + # 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, From 66fd0f403f6c670a2aa863812035419df864a50c Mon Sep 17 00:00:00 2001 From: Nicolas Lopez Date: Tue, 7 Jan 2025 13:21:13 -0500 Subject: [PATCH 05/16] use --remote_only --- buck2/cpp/.buckconfig | 2 +- buck2/golang/.buckconfig | 2 +- buck2/python/.buckconfig | 2 +- infra/test-buck2.sh | 12 ++++++------ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/buck2/cpp/.buckconfig b/buck2/cpp/.buckconfig index 8af31dd8..c12fbc42 100644 --- a/buck2/cpp/.buckconfig +++ b/buck2/cpp/.buckconfig @@ -32,7 +32,7 @@ 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 diff --git a/buck2/golang/.buckconfig b/buck2/golang/.buckconfig index 8e773e99..eceb0450 100644 --- a/buck2/golang/.buckconfig +++ b/buck2/golang/.buckconfig @@ -14,7 +14,7 @@ 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 diff --git a/buck2/python/.buckconfig b/buck2/python/.buckconfig index 8e773e99..eceb0450 100644 --- a/buck2/python/.buckconfig +++ b/buck2/python/.buckconfig @@ -14,7 +14,7 @@ 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 diff --git a/infra/test-buck2.sh b/infra/test-buck2.sh index 37b0218f..6b3fc457 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 --target-platforms //platforms:remote_platform //:cpp_lib -buck2 test --target-platforms //platforms:remote_platform //:cpp_test +buck2 build --remote-only //:cpp_lib +buck2 test --remote-only //:cpp_test cd .. # Run python example cd python -buck2 build --target-platforms //platforms:remote_platform //main:check_main -buck2 test --target-platforms //platforms:remote_platform //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 --target-platforms //platforms:remote_platform //go:hello -buck2 test --target-platforms //platforms:remote_platform //go/greeting:greeting_test +buck2 build --remote-only //go:hello +buck2 test --remote-only //go/greeting:greeting_test cd .. # Run rust example From e1b9159d8a649e2fa52a4a3049f35c57416d7819 Mon Sep 17 00:00:00 2001 From: Nicolas Lopez Date: Tue, 7 Jan 2025 13:23:08 -0500 Subject: [PATCH 06/16] fix --- infra/test-buck2.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infra/test-buck2.sh b/infra/test-buck2.sh index 6b3fc457..eb922e4f 100755 --- a/infra/test-buck2.sh +++ b/infra/test-buck2.sh @@ -12,7 +12,7 @@ cd .. # Run python example cd python -buck2 build --remote-only//main:check_main +buck2 build --remote-only //main:check_main buck2 test ---remote-only //hello:hello_unittest_test cd .. From f669195d21a67de73ab9e890324eae25f586b403 Mon Sep 17 00:00:00 2001 From: Nicolas Lopez Date: Tue, 7 Jan 2025 13:26:19 -0500 Subject: [PATCH 07/16] fix --- infra/test-buck2.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infra/test-buck2.sh b/infra/test-buck2.sh index eb922e4f..0fbde1e5 100755 --- a/infra/test-buck2.sh +++ b/infra/test-buck2.sh @@ -13,7 +13,7 @@ cd .. # Run python example cd python buck2 build --remote-only //main:check_main -buck2 test ---remote-only //hello:hello_unittest_test +buck2 test --remote-only //hello:hello_unittest_test cd .. # Run go example From a12e83b63c15f66a9de47f45c6a0c1ac6d8e54ad Mon Sep 17 00:00:00 2001 From: Nicolas Lopez Date: Wed, 26 Feb 2025 13:08:45 -0500 Subject: [PATCH 08/16] update this old PR --- buck2/cpp/.buckconfig | 28 ++++++++++++++-------------- buck2/cpp/README.md | 4 ++-- buck2/golang/.buckconfig | 24 ++++++++++++------------ buck2/golang/README.md | 2 +- buck2/python/.buckconfig | 24 ++++++++++++------------ buck2/python/README.md | 4 ++-- 6 files changed, 43 insertions(+), 43 deletions(-) diff --git a/buck2/cpp/.buckconfig b/buck2/cpp/.buckconfig index c12fbc42..f9a0245d 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//...->root//platforms:remote_platform +target_platform_detector_spec = target:root//...->root//platforms:remote_platform [buck2] digest_algorithms = SHA256 @@ -44,7 +44,7 @@ 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 diff --git a/buck2/cpp/README.md b/buck2/cpp/README.md index 68095ebb..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 --target-platforms //platforms:remote_platform //:cpp_lib +buck2 build --remote-only //:cpp_lib ``` Test the example: ``` -buck2 test --target-platforms //platforms:remote_platform //:cpp_test +buck2 test --remote-only //:cpp_test ``` diff --git a/buck2/golang/.buckconfig b/buck2/golang/.buckconfig index eceb0450..fc5ca33f 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//...->root//platforms:remote_platform +target_platform_detector_spec = target:root//...->root//platforms:remote_platform [buck2] digest_algorithms = SHA256 @@ -26,7 +26,7 @@ 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 diff --git a/buck2/golang/README.md b/buck2/golang/README.md index cf38ca73..cc08569f 100644 --- a/buck2/golang/README.md +++ b/buck2/golang/README.md @@ -33,7 +33,7 @@ buck2 test --target-platforms //platforms:remote_platform //go/greeting:greeting You can also build the `main` for this sample by running: ``` -buck2 build --target-platforms //platforms:remote_platform //go:hello +buck2 build --remote-only //go:hello ``` ### Relevant configs in `.buckconfig` diff --git a/buck2/python/.buckconfig b/buck2/python/.buckconfig index eceb0450..fc5ca33f 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//...->root//platforms:remote_platform +target_platform_detector_spec = target:root//...->root//platforms:remote_platform [buck2] digest_algorithms = SHA256 @@ -26,7 +26,7 @@ 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 diff --git a/buck2/python/README.md b/buck2/python/README.md index 0d3a2dbe..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 --target-platforms //platforms:remote_platform //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 --target-platforms //platforms:remote_platform //hello:hello_unittest_test +buck2 test --remote-only //hello:hello_unittest_test ``` ### Relevant configs in `.buckconfig` From 50cc28ed26d70f11667132f9ac60219261e4ed1f Mon Sep 17 00:00:00 2001 From: Nicolas Lopez Date: Wed, 26 Feb 2025 13:21:32 -0500 Subject: [PATCH 09/16] remove remote_execution_action_key_providers --- buck2/cpp/.buckconfig | 3 +++ buck2/cpp/BUCK | 5 ----- buck2/golang/.buckconfig | 3 +++ buck2/golang/go/greeting/BUCK | 5 ----- buck2/python/.buckconfig | 3 +++ buck2/python/hello/BUCK | 5 ----- buck2/rust/.buckconfig | 3 +++ buck2/rust/BUCK | 5 ----- 8 files changed, 12 insertions(+), 20 deletions(-) diff --git a/buck2/cpp/.buckconfig b/buck2/cpp/.buckconfig index f9a0245d..5c609ed8 100644 --- a/buck2/cpp/.buckconfig +++ b/buck2/cpp/.buckconfig @@ -48,3 +48,6 @@ execution_platforms = root//platforms:remote_platform [project] ignore = .git + +[re] +remote_execution_action_key_providers = "//platforms:remote_execution_action_keys" diff --git a/buck2/cpp/BUCK b/buck2/cpp/BUCK index 887f35d2..11abfa2c 100644 --- a/buck2/cpp/BUCK +++ b/buck2/cpp/BUCK @@ -39,9 +39,4 @@ cxx_test( deps = [ ":cpp_lib", ], - # 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/golang/.buckconfig b/buck2/golang/.buckconfig index fc5ca33f..14809de0 100644 --- a/buck2/golang/.buckconfig +++ b/buck2/golang/.buckconfig @@ -30,3 +30,6 @@ execution_platforms = root//platforms:remote_platform [project] ignore = .git + +[re] +remote_execution_action_key_providers = "//platforms:remote_execution_action_keys" diff --git a/buck2/golang/go/greeting/BUCK b/buck2/golang/go/greeting/BUCK index 25c3b0bb..3763f835 100644 --- a/buck2/golang/go/greeting/BUCK +++ b/buck2/golang/go/greeting/BUCK @@ -21,9 +21,4 @@ go_library( go_test( name = "greeting_test", srcs = glob(["*.go"]), - # 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/python/.buckconfig b/buck2/python/.buckconfig index fc5ca33f..14809de0 100644 --- a/buck2/python/.buckconfig +++ b/buck2/python/.buckconfig @@ -30,3 +30,6 @@ execution_platforms = root//platforms:remote_platform [project] ignore = .git + +[re] +remote_execution_action_key_providers = "//platforms:remote_execution_action_keys" diff --git a/buck2/python/hello/BUCK b/buck2/python/hello/BUCK index 021500d1..d9902ed7 100644 --- a/buck2/python/hello/BUCK +++ b/buck2/python/hello/BUCK @@ -30,9 +30,4 @@ python_test( name = "hello_unittest_test", srcs = ["hello_unittest_test.py"], deps = [":hellolib"], - # 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/.buckconfig b/buck2/rust/.buckconfig index fc5ca33f..14809de0 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_action_key_providers = "//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, - }), ) From 199c69d38b4fd25f7c094451a79a4b02e75f0cca Mon Sep 17 00:00:00 2001 From: Nicolas Lopez Date: Wed, 26 Feb 2025 13:28:31 -0500 Subject: [PATCH 10/16] fix --- buck2/cpp/.buckconfig | 2 +- buck2/golang/.buckconfig | 2 +- buck2/python/.buckconfig | 2 +- buck2/rust/.buckconfig | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/buck2/cpp/.buckconfig b/buck2/cpp/.buckconfig index 5c609ed8..a32489fa 100644 --- a/buck2/cpp/.buckconfig +++ b/buck2/cpp/.buckconfig @@ -50,4 +50,4 @@ execution_platforms = root//platforms:remote_platform ignore = .git [re] -remote_execution_action_key_providers = "//platforms:remote_execution_action_keys" +remote_execution_action_key_providers = root//platforms:remote_execution_action_keys diff --git a/buck2/golang/.buckconfig b/buck2/golang/.buckconfig index 14809de0..29805086 100644 --- a/buck2/golang/.buckconfig +++ b/buck2/golang/.buckconfig @@ -32,4 +32,4 @@ execution_platforms = root//platforms:remote_platform ignore = .git [re] -remote_execution_action_key_providers = "//platforms:remote_execution_action_keys" +remote_execution_action_key_providers = root//platforms:remote_execution_action_keys diff --git a/buck2/python/.buckconfig b/buck2/python/.buckconfig index 14809de0..29805086 100644 --- a/buck2/python/.buckconfig +++ b/buck2/python/.buckconfig @@ -32,4 +32,4 @@ execution_platforms = root//platforms:remote_platform ignore = .git [re] -remote_execution_action_key_providers = "//platforms:remote_execution_action_keys" +remote_execution_action_key_providers = root//platforms:remote_execution_action_keys diff --git a/buck2/rust/.buckconfig b/buck2/rust/.buckconfig index 14809de0..29805086 100644 --- a/buck2/rust/.buckconfig +++ b/buck2/rust/.buckconfig @@ -32,4 +32,4 @@ execution_platforms = root//platforms:remote_platform ignore = .git [re] -remote_execution_action_key_providers = "//platforms:remote_execution_action_keys" +remote_execution_action_key_providers = root//platforms:remote_execution_action_keys From 660d2e9c9b16d3c0dc7a6d74036fcc982a73cbce Mon Sep 17 00:00:00 2001 From: Nicolas Lopez Date: Wed, 26 Feb 2025 13:37:18 -0500 Subject: [PATCH 11/16] fix --- buck2/cpp/.buckconfig | 2 +- buck2/golang/.buckconfig | 2 +- buck2/python/.buckconfig | 2 +- buck2/rust/.buckconfig | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/buck2/cpp/.buckconfig b/buck2/cpp/.buckconfig index a32489fa..28021ed9 100644 --- a/buck2/cpp/.buckconfig +++ b/buck2/cpp/.buckconfig @@ -50,4 +50,4 @@ execution_platforms = root//platforms:remote_platform ignore = .git [re] -remote_execution_action_key_providers = root//platforms:remote_execution_action_keys +remote_execution_test_build_mode = root//platforms:remote_execution_action_keys diff --git a/buck2/golang/.buckconfig b/buck2/golang/.buckconfig index 29805086..e411992c 100644 --- a/buck2/golang/.buckconfig +++ b/buck2/golang/.buckconfig @@ -32,4 +32,4 @@ execution_platforms = root//platforms:remote_platform ignore = .git [re] -remote_execution_action_key_providers = root//platforms:remote_execution_action_keys +remote_execution_test_build_mode = root//platforms:remote_execution_action_keys diff --git a/buck2/python/.buckconfig b/buck2/python/.buckconfig index 29805086..e411992c 100644 --- a/buck2/python/.buckconfig +++ b/buck2/python/.buckconfig @@ -32,4 +32,4 @@ execution_platforms = root//platforms:remote_platform ignore = .git [re] -remote_execution_action_key_providers = root//platforms:remote_execution_action_keys +remote_execution_test_build_mode = root//platforms:remote_execution_action_keys diff --git a/buck2/rust/.buckconfig b/buck2/rust/.buckconfig index 29805086..e411992c 100644 --- a/buck2/rust/.buckconfig +++ b/buck2/rust/.buckconfig @@ -32,4 +32,4 @@ execution_platforms = root//platforms:remote_platform ignore = .git [re] -remote_execution_action_key_providers = root//platforms:remote_execution_action_keys +remote_execution_test_build_mode = root//platforms:remote_execution_action_keys From 3c5b74eb01111c9cf837e6db17eaae86eda116c6 Mon Sep 17 00:00:00 2001 From: Nicolas Lopez Date: Wed, 26 Feb 2025 13:46:28 -0500 Subject: [PATCH 12/16] use latest --- infra/setup-buck2.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infra/setup-buck2.sh b/infra/setup-buck2.sh index e6d8a2ad..d0e15a3c 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 - using latest +curl -L -O https://github.com/facebook/buck2/releases/download/latest/buck2-x86_64-unknown-linux-musl.zst # Unpack the binary. unzstd buck2-x86_64-unknown-linux-musl.zst From db15e595119b9f93b0be28bc78f233481f3be0d1 Mon Sep 17 00:00:00 2001 From: Nicolas Lopez Date: Wed, 26 Feb 2025 13:50:51 -0500 Subject: [PATCH 13/16] remove unnecessary platform changes --- buck2/cpp/platforms/BUCK | 10 ---------- buck2/cpp/platforms/defs.bzl | 2 -- buck2/golang/platforms/BUCK | 10 ---------- buck2/golang/platforms/defs.bzl | 4 ---- buck2/python/platforms/BUCK | 10 ---------- buck2/python/platforms/defs.bzl | 4 ---- buck2/rust/platforms/BUCK | 10 ---------- buck2/rust/platforms/defs.bzl | 2 -- 8 files changed, 52 deletions(-) diff --git a/buck2/cpp/platforms/BUCK b/buck2/cpp/platforms/BUCK index 67a4d912..8e4f659a 100644 --- a/buck2/cpp/platforms/BUCK +++ b/buck2/cpp/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/cpp/platforms/defs.bzl b/buck2/cpp/platforms/defs.bzl index fe221cc9..830d53fb 100644 --- a/buck2/cpp/platforms/defs.bzl +++ b/buck2/cpp/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 = {}, @@ -62,7 +61,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/buck2/golang/platforms/BUCK b/buck2/golang/platforms/BUCK index be9b5df9..cc1595f9 100644 --- a/buck2/golang/platforms/BUCK +++ b/buck2/golang/platforms/BUCK @@ -15,19 +15,9 @@ 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", - re_provider = ":engflow", ) # This action_key provides a default BuildModeInfo that is needed for RE of tests to function properly. diff --git a/buck2/golang/platforms/defs.bzl b/buck2/golang/platforms/defs.bzl index b1958c80..4e381c73 100644 --- a/buck2/golang/platforms/defs.bzl +++ b/buck2/golang/platforms/defs.bzl @@ -18,7 +18,6 @@ load("@prelude//:build_mode.bzl", "BuildModeInfo") def _platforms(ctx): constraints = dict() - constraints.update(ctx.attrs.re_provider[ConfigurationInfo].constraints) configuration = ConfigurationInfo( constraints = constraints, values = {}, @@ -58,9 +57,6 @@ def _action_keys(ctx): ] platforms = rule( - attrs = { - "re_provider": attrs.dep(providers = [ConfigurationInfo]), - }, impl = _platforms ) diff --git a/buck2/python/platforms/BUCK b/buck2/python/platforms/BUCK index be9b5df9..cc1595f9 100644 --- a/buck2/python/platforms/BUCK +++ b/buck2/python/platforms/BUCK @@ -15,19 +15,9 @@ 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", - re_provider = ":engflow", ) # This action_key provides a default BuildModeInfo that is needed for RE of tests to function properly. diff --git a/buck2/python/platforms/defs.bzl b/buck2/python/platforms/defs.bzl index d775e32d..adc80ec7 100644 --- a/buck2/python/platforms/defs.bzl +++ b/buck2/python/platforms/defs.bzl @@ -18,7 +18,6 @@ load("@prelude//:build_mode.bzl", "BuildModeInfo") def _platforms(ctx): constraints = dict() - constraints.update(ctx.attrs.re_provider[ConfigurationInfo].constraints) configuration = ConfigurationInfo( constraints = constraints, values = {}, @@ -56,9 +55,6 @@ def _action_keys(ctx): ] platforms = rule( - attrs = { - "re_provider": attrs.dep(providers = [ConfigurationInfo]), - }, impl = _platforms ) 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 ) From c4b52c177efcb61a6a15b139758c1695c0493084 Mon Sep 17 00:00:00 2001 From: Nicolas Lopez Date: Wed, 26 Feb 2025 13:55:08 -0500 Subject: [PATCH 14/16] fix --- buck2/golang/platforms/defs.bzl | 1 + buck2/python/platforms/defs.bzl | 1 + 2 files changed, 2 insertions(+) diff --git a/buck2/golang/platforms/defs.bzl b/buck2/golang/platforms/defs.bzl index 4e381c73..59fee93d 100644 --- a/buck2/golang/platforms/defs.bzl +++ b/buck2/golang/platforms/defs.bzl @@ -57,6 +57,7 @@ def _action_keys(ctx): ] platforms = rule( + attrs = {}, impl = _platforms ) diff --git a/buck2/python/platforms/defs.bzl b/buck2/python/platforms/defs.bzl index adc80ec7..ffc1429a 100644 --- a/buck2/python/platforms/defs.bzl +++ b/buck2/python/platforms/defs.bzl @@ -55,6 +55,7 @@ def _action_keys(ctx): ] platforms = rule( + attrs = {}, impl = _platforms ) From 6576cccf4a85830cd4066b8ccb7d90eef170676d Mon Sep 17 00:00:00 2001 From: Nicolas Lopez Date: Thu, 27 Feb 2025 10:35:41 -0500 Subject: [PATCH 15/16] review comment --- buck2/golang/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buck2/golang/README.md b/buck2/golang/README.md index cc08569f..ae6db264 100644 --- a/buck2/golang/README.md +++ b/buck2/golang/README.md @@ -27,7 +27,7 @@ The `main` cell and `library` cell: To test this cell with RE run (after setting up `.buckconfig` as indicated below): ``` -buck2 test --target-platforms //platforms:remote_platform //go/greeting:greeting_test +buck2 test --remote-only //go/greeting:greeting_test ``` You can also build the `main` for this sample by running: From 452efd3360ca9206711a88cfbab4fdc168a9e7d6 Mon Sep 17 00:00:00 2001 From: Nicolas Lopez Date: Mon, 3 Mar 2025 09:50:41 -0500 Subject: [PATCH 16/16] use 03-01 --- infra/setup-buck2.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infra/setup-buck2.sh b/infra/setup-buck2.sh index d0e15a3c..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 - using latest -curl -L -O https://github.com/facebook/buck2/releases/download/latest/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