From bf86e7b8ec2e4821dc8161840fb5cc4ba951397c Mon Sep 17 00:00:00 2001 From: Adam Singer Date: Fri, 16 Aug 2024 22:36:50 +0000 Subject: [PATCH] Setup buck2 to build buck2 with remote execution Enable setup to build buck2 with remote execution. * Create github action that generates .buckconfig.local using `NATIVELINK_HEADER_RW_KEY` from gha secrets. * Set `container-image` used for remote execution specific to setup of buck2. * Update .gitignore to include .buckconfig.local. * Include a `platforms` configuration for prelude/platforms --- .../actions/build_buck2_nativelink/action.yml | 27 +++++++++++++++++++ .gitignore | 2 ++ prelude/platforms/defs.bzl | 12 ++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 .github/actions/build_buck2_nativelink/action.yml diff --git a/.github/actions/build_buck2_nativelink/action.yml b/.github/actions/build_buck2_nativelink/action.yml new file mode 100644 index 0000000000000..d11e60514e8bb --- /dev/null +++ b/.github/actions/build_buck2_nativelink/action.yml @@ -0,0 +1,27 @@ +name: build_buck2_nativelink +inputs: + NATIVELINK_HEADER_RW_KEY_SECRET: + description: '' + required: true +runs: + using: composite + steps: + - name: Build `buck2` with `buck2` using remote execution + run: |- + { + echo "[buck2_re_client] + engine_address = grpc://scheduler-buck2.build-faster.nativelink.net:443 + action_cache_address = grpc://cas-buck2.build-faster.nativelink.net:443 + cas_address = grpc://cas-buck2.build-faster.nativelink.net:443 + http_headers = x-nativelink-api-key:${NATIVELINK_HEADER_RW_KEY} + tls = true + instance_name = main + enabled = true + capabilities = true + [build] + execution_platforms = prelude//platforms:default" + } > .buckconfig.local + $RUNNER_TEMP/artifacts/buck2 build //:buck2 -v 4 + env: + NATIVELINK_HEADER_RW_KEY: ${{ inputs.NATIVELINK_HEADER_RW_KEY_SECRET }} + shell: bash diff --git a/.gitignore b/.gitignore index 5ca9410a5c866..b4f162b581542 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ Cargo.lock buck-out /.direnv +.buckconfig.local + # symlinks /examples/with_prelude/prelude /examples/with_prelude/third-party/ocaml/opam diff --git a/prelude/platforms/defs.bzl b/prelude/platforms/defs.bzl index ca6710bbc19d5..75693e1c3d94d 100644 --- a/prelude/platforms/defs.bzl +++ b/prelude/platforms/defs.bzl @@ -17,7 +17,17 @@ def _execution_platform_impl(ctx: AnalysisContext) -> list[Provider]: configuration = cfg, executor_config = CommandExecutorConfig( local_enabled = True, - remote_enabled = False, + remote_enabled = True, + use_limited_hybrid = True, + allow_limited_hybrid_fallbacks = True, + allow_hybrid_fallbacks_on_failure = True, + remote_cache_enabled = True, + remote_execution_properties = { + "OSFamily": "linux", + "container-image": "docker://buck2-github:latest", + }, + remote_execution_use_case = "buck2-default", + remote_output_paths = "output_paths", use_windows_path_separators = ctx.attrs.use_windows_path_separators, ), )