From c06b82b0302225d2651f18c57b8662e0812789f3 Mon Sep 17 00:00:00 2001 From: Manuel Naranjo Date: Sat, 7 Nov 2026 13:27:53 +0100 Subject: [PATCH 1/2] ci: add BuildBuddy and RBE support on CI --- .bazelrc | 32 +++++++++++++++++- .github/actions/setup-bazel/action.yml | 31 +++++++++++++++++ .github/workflows/build.yaml | 6 ++-- .github/workflows/ci.bazelrc | 4 +++ .github/workflows/ci.yaml | 20 ++--------- AGENTS.md | 5 +++ MODULE.bazel | 19 +++++++++++ MODULE.bazel.lock | 38 ++++++++++++++++++--- bazel/BUILD.bazel | 21 ++++++++++++ bazel/rbe.bzl | 29 ++++++++++++++++ e2e/dnf-hermetic-lock/.bazelrc | 5 ++- tools/setup_buildbuddy.sh | 46 ++++++++++++++++++++++++++ 12 files changed, 230 insertions(+), 26 deletions(-) create mode 100644 .github/actions/setup-bazel/action.yml create mode 100644 bazel/BUILD.bazel create mode 100644 bazel/rbe.bzl create mode 100755 tools/setup_buildbuddy.sh diff --git a/.bazelrc b/.bazelrc index 1d9d36a..0637ef1 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,11 +1,41 @@ +# Startup options +startup --experimental_remote_repo_contents_cache + +# Common settings +common --deleted_packages=e2e/dnf-hermetic-lock +common --experimental_repo_remote_exec + # Bzlmod common --enable_bzlmod +# Bazel RBE configuration profile targeting //bazel:ubuntu24_04_amd64 +# The container image of remote actions can be overridden (e.g. in .bazelrc.user) with +# common --repo_env=RBE_CONTAINER_IMAGE=docker:///@sha256: +build:rbe --host_platform=//bazel:ubuntu24_04_amd64 +build:rbe --extra_execution_platforms=//bazel:ubuntu24_04_amd64 +build:rbe --spawn_strategy=remote +build:rbe --remote_local_fallback=true +build:rbe --remote_download_outputs=minimal +build:rbe --nobuild_runfile_links +build:rbe --remote_cache_compression +build:rbe --experimental_remote_cache_chunking +build:rbe --experimental_repo_remote_exec +build:rbe --disk_cache= +build:rbe --repository_cache= +build:rbe --noslim_profile +build:rbe --experimental_profile_include_target_label +build:rbe --experimental_profile_include_primary_output +test:rbe --remote_default_exec_properties=dockerNetwork=bridge +test:rbe --remote_default_exec_properties=network=bridge +build:rbe --action_env=LC_ALL=C --action_env=LANG=en +build:rbe --host_action_env=LC_ALL=C +build:rbe --jobs=40 + # CI configuration profile common:ci --color=yes common:ci --show_progress_rate_limit=5 test:ci --test_output=errors test:ci --test_summary=terse -# Import user configuration if present +# Import user configuration if present (must be last) try-import %workspace%/.bazelrc.user diff --git a/.github/actions/setup-bazel/action.yml b/.github/actions/setup-bazel/action.yml new file mode 100644 index 0000000..9aa41e8 --- /dev/null +++ b/.github/actions/setup-bazel/action.yml @@ -0,0 +1,31 @@ +# Bazel on a hosted runner, with the BuildBuddy remote cache and execution when +# both the endpoint and the API key are set (otherwise the GitHub Actions disk +# cache). Used by build.yaml and ci.yaml. +name: Set up Bazel +description: Installs Bazel and configures the optional BuildBuddy remote cache. + +inputs: + buildbuddy-endpoint: + description: BuildBuddy host name (gRPC at grpcs://, invocation links at https:///invocation/). + required: false + default: "" + buildbuddy-api-key: + description: API key for that BuildBuddy. + required: false + default: "" + +runs: + using: composite + steps: + - uses: bazel-contrib/setup-bazel@104e3eea9447cdaa4b00d0fb46191a3985d26ab3 # 0.19.1 + with: + bazelisk-cache: true + repository-cache: true + disk-cache: ${{ inputs.buildbuddy-endpoint == '' || inputs.buildbuddy-api-key == '' }} + - name: Configure remote cache + if: inputs.buildbuddy-endpoint != '' && inputs.buildbuddy-api-key != '' + shell: bash + env: + BUILDBUDDY_ENDPOINT: ${{ inputs.buildbuddy-endpoint }} + BUILDBUDDY_API_KEY: ${{ inputs.buildbuddy-api-key }} + run: tools/setup_buildbuddy.sh diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index cef54ab..014b4c8 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -26,10 +26,10 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: ref: ${{ inputs.ref || github.ref }} - - uses: bazel-contrib/setup-bazel@104e3eea9447cdaa4b00d0fb46191a3985d26ab3 # 0.19.1 + - uses: ./.github/actions/setup-bazel with: - bazelisk-cache: true - repository-cache: true + buildbuddy-endpoint: ${{ vars.BUILDBUDDY_ENDPOINT }} + buildbuddy-api-key: ${{ secrets.BUILDBUDDY_API_KEY }} - name: Build run: | mkdir -p dist diff --git a/.github/workflows/ci.bazelrc b/.github/workflows/ci.bazelrc index cbbd19b..891bc3a 100644 --- a/.github/workflows/ci.bazelrc +++ b/.github/workflows/ci.bazelrc @@ -8,6 +8,10 @@ test --test_output=errors # BuildBuddy remote cache / execution, enabled by the workflows when the # BUILDBUDDY_ENDPOINT repository variable (host name) and the BUILDBUDDY_API_KEY # secret are set. +# The workflow writes the endpoints derived from the host (--bes_backend, +# --remote_cache and, for buildbuddy-rbe, --remote_executor at grpcs://; +# --bes_results_url at https:///invocation/) and the API key +# (--remote_header) to .bazelrc.user; none of them are stored here. common:buildbuddy --remote_timeout=3600 common:buildbuddy --noexperimental_remote_cache_chunking common:buildbuddy-rbe --config=buildbuddy diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 29d18b5..b4fa926 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,26 +15,12 @@ concurrency: jobs: test: runs-on: ubuntu-26.04 - env: - BUILDBUDDY_ENDPOINT: ${{ vars.BUILDBUDDY_ENDPOINT }} - BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 - - uses: bazel-contrib/setup-bazel@104e3eea9447cdaa4b00d0fb46191a3985d26ab3 # 0.19.1 + - uses: ./.github/actions/setup-bazel with: - bazelisk-cache: true - repository-cache: true - disk-cache: ${{ env.BUILDBUDDY_ENDPOINT == '' || env.BUILDBUDDY_API_KEY == '' }} - - name: Configure remote cache - if: env.BUILDBUDDY_ENDPOINT != '' && env.BUILDBUDDY_API_KEY != '' - run: | - { - echo "common --config=buildbuddy" - echo "common:buildbuddy --bes_backend=grpcs://${BUILDBUDDY_ENDPOINT}" - echo "common:buildbuddy --bes_results_url=https://${BUILDBUDDY_ENDPOINT}/invocation/" - echo "common:buildbuddy --remote_cache=grpcs://${BUILDBUDDY_ENDPOINT}" - echo "common:buildbuddy --remote_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY}" - } > .bazelrc.user + buildbuddy-endpoint: ${{ vars.BUILDBUDDY_ENDPOINT }} + buildbuddy-api-key: ${{ secrets.BUILDBUDDY_API_KEY }} - name: Build run: bazel --bazelrc=.github/workflows/ci.bazelrc build //... - name: Test diff --git a/AGENTS.md b/AGENTS.md index 1982fd9..30bc766 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -8,3 +8,8 @@ 2. Commit changes to that branch. 3. Push the branch to `origin`. 4. Open a Pull Request against `main`. + +## CI & BuildBuddy Protocol + +- **All tests in CI must run with BuildBuddy enabled.** Any test execution in CI (including unit/smoke tests in root and e2e tests in `e2e/*`) must use `.github/actions/setup-bazel` with BuildBuddy endpoints and API keys so remote cache, remote execution (RBE), and BES invocation streaming are always active. +- **Do not delete or overwrite `.bazelrc.user`**: it is git-ignored and holds the user's remote execution credentials. Never print it either. diff --git a/MODULE.bazel b/MODULE.bazel index 3c6d5b8..41e52e7 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -28,6 +28,25 @@ bazel_dep(name = "rules_go", version = "0.65.0", dev_dependency = True) bazel_dep(name = "gazelle", version = "0.54.0", dev_dependency = True) bazel_dep(name = "toolchains_llvm", version = "1.13.0", dev_dependency = True) bazel_dep(name = "aspect_rules_py", version = "2.0.0-alpha.10", dev_dependency = True) +bazel_dep(name = "toolchains_buildbuddy", version = "0.0.4", dev_dependency = True) + +buildbuddy = use_extension( + "@toolchains_buildbuddy//:extensions.bzl", + "buildbuddy", + dev_dependency = True, +) +buildbuddy.platform( + container_image = "docker://gcr.io/flame-public/rbe-ubuntu24-04@sha256:be9853fc45092d2cf2bda3abed30d22182881659a50bf35c7125161d7cfc8a75", +) +use_repo(buildbuddy, "buildbuddy_toolchain") + +# The image above, unless RBE_CONTAINER_IMAGE is set with --repo_env. +rbe_container_image = use_repo_rule("//bazel:rbe.bzl", "rbe_container_image") + +rbe_container_image( + name = "rbe_container_image", + dev_dependency = True, +) python = use_extension("@aspect_rules_py//py:extensions.bzl", "python_interpreters", dev_dependency = True) python.toolchain(python_version = "3.13") diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index f54840b..bb59c09 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -12,6 +12,7 @@ "https://bcr.bazel.build/modules/abseil-cpp/20240116.2/MODULE.bazel": "73939767a4686cd9a520d16af5ab440071ed75cec1a876bf2fcfaf1f71987a16", "https://bcr.bazel.build/modules/abseil-cpp/20250127.1/MODULE.bazel": "c4a89e7ceb9bf1e25cf84a9f830ff6b817b72874088bf5141b314726e46a57c1", "https://bcr.bazel.build/modules/abseil-cpp/20250512.1/MODULE.bazel": "d209fdb6f36ffaf61c509fcc81b19e81b411a999a934a032e10cd009a0226215", + "https://bcr.bazel.build/modules/abseil-cpp/20250814.0/MODULE.bazel": "c43c16ca2c432566cdb78913964497259903ebe8fb7d9b57b38e9f1425b427b8", "https://bcr.bazel.build/modules/abseil-cpp/20250814.1/MODULE.bazel": "51f2312901470cdab0dbdf3b88c40cd21c62a7ed58a3de45b365ddc5b11bcab2", "https://bcr.bazel.build/modules/abseil-cpp/20250814.1/source.json": "cea3901d7e299da7320700abbaafe57a65d039f10d0d7ea601c4a66938ea4b0c", "https://bcr.bazel.build/modules/apple_support/1.11.1/MODULE.bazel": "1843d7cd8a58369a444fc6000e7304425fba600ff641592161d9f15b179fb896", @@ -171,6 +172,7 @@ "https://bcr.bazel.build/modules/rules_cc/0.2.18/MODULE.bazel": "4460ec36adc8f722a6a2a4ac9374cb91f2acebadaa93fc37966129afb3dece87", "https://bcr.bazel.build/modules/rules_cc/0.2.18/source.json": "abad668ff2fd63ada1ac49bf386d37e27048b89a3465a6fd968bb832b00a09d3", "https://bcr.bazel.build/modules/rules_cc/0.2.4/MODULE.bazel": "1ff1223dfd24f3ecf8f028446d4a27608aa43c3f41e346d22838a4223980b8cc", + "https://bcr.bazel.build/modules/rules_cc/0.2.8/MODULE.bazel": "f1df20f0bf22c28192a794f29b501ee2018fa37a3862a1a2132ae2940a23a642", "https://bcr.bazel.build/modules/rules_foreign_cc/0.9.0/MODULE.bazel": "c9e8c682bf75b0e7c704166d79b599f93b72cfca5ad7477df596947891feeef6", "https://bcr.bazel.build/modules/rules_fuzzing/0.5.2/MODULE.bazel": "40c97d1144356f52905566c55811f13b299453a14ac7769dfba2ac38192337a8", "https://bcr.bazel.build/modules/rules_go/0.41.0/MODULE.bazel": "55861d8e8bb0e62cbd2896f60ff303f62ffcb0eddb74ecb0e5c0cbe36fc292c8", @@ -189,6 +191,7 @@ "https://bcr.bazel.build/modules/rules_java/7.12.2/MODULE.bazel": "579c505165ee757a4280ef83cda0150eea193eed3bef50b1004ba88b99da6de6", "https://bcr.bazel.build/modules/rules_java/7.2.0/MODULE.bazel": "06c0334c9be61e6cef2c8c84a7800cef502063269a5af25ceb100b192453d4ab", "https://bcr.bazel.build/modules/rules_java/7.6.1/MODULE.bazel": "2f14b7e8a1aa2f67ae92bc69d1ec0fa8d9f827c4e17ff5e5f02e91caa3b2d0fe", + "https://bcr.bazel.build/modules/rules_java/8.16.1/MODULE.bazel": "0f20b1cecaa8e52f60a8f071e59a20b4e3b9a67f6c56c802ea256f6face692d3", "https://bcr.bazel.build/modules/rules_java/8.3.2/MODULE.bazel": "7336d5511ad5af0b8615fdc7477535a2e4e723a357b6713af439fe8cf0195017", "https://bcr.bazel.build/modules/rules_java/8.5.1/MODULE.bazel": "d8a9e38cc5228881f7055a6079f6f7821a073df3744d441978e7a43e20226939", "https://bcr.bazel.build/modules/rules_java/8.6.1/MODULE.bazel": "f4808e2ab5b0197f094cabce9f4b006a27766beb6a9975931da07099560ca9c2", @@ -235,7 +238,8 @@ "https://bcr.bazel.build/modules/rules_shell/0.3.0/MODULE.bazel": "de4402cd12f4cc8fda2354fce179fdb068c0b9ca1ec2d2b17b3e21b24c1a937b", "https://bcr.bazel.build/modules/rules_shell/0.4.1/MODULE.bazel": "00e501db01bbf4e3e1dd1595959092c2fadf2087b2852d3f553b5370f5633592", "https://bcr.bazel.build/modules/rules_shell/0.6.1/MODULE.bazel": "72e76b0eea4e81611ef5452aa82b3da34caca0c8b7b5c0c9584338aa93bae26b", - "https://bcr.bazel.build/modules/rules_shell/0.6.1/source.json": "20ec05cd5e592055e214b2da8ccb283c7f2a421ea0dc2acbf1aa792e11c03d0c", + "https://bcr.bazel.build/modules/rules_shell/0.8.0/MODULE.bazel": "f6a89f1d6a669a26f28fe814503857055d76306b79cfc11d12399af08d0b80ae", + "https://bcr.bazel.build/modules/rules_shell/0.8.0/source.json": "eb53cc815bc503c6683c5fe12d943f98883f81fc22f51403ec8a95610cba4195", "https://bcr.bazel.build/modules/rules_swift/1.16.0/MODULE.bazel": "4a09f199545a60d09895e8281362b1ff3bb08bbde69c6fc87aff5b92fcc916ca", "https://bcr.bazel.build/modules/rules_swift/2.1.1/MODULE.bazel": "494900a80f944fc7aa61500c2073d9729dff0b764f0e89b824eb746959bc1046", "https://bcr.bazel.build/modules/rules_swift/2.4.0/MODULE.bazel": "1639617eb1ede28d774d967a738b4a68b0accb40650beadb57c21846beab5efd", @@ -257,8 +261,10 @@ "https://bcr.bazel.build/modules/tar.bzl/0.10.9/source.json": "30a5cf0a8281adce53ab1c5a4291e88b2c161e2df1feb6cba4ee50556f1748d7", "https://bcr.bazel.build/modules/tar.bzl/0.2.1/MODULE.bazel": "52d1c00a80a8cc67acbd01649e83d8dd6a9dc426a6c0b754a04fe8c219c76468", "https://bcr.bazel.build/modules/tar.bzl/0.6.0/MODULE.bazel": "a3584b4edcfafcabd9b0ef9819808f05b372957bbdff41601429d5fd0aac2e7c", - "https://bcr.bazel.build/modules/toolchains_llvm/1.12.0/MODULE.bazel": "229c2f3ad32d76f69ef1e83bb1bac80984893836f279e644d7698faf305c6ab7", - "https://bcr.bazel.build/modules/toolchains_llvm/1.12.0/source.json": "4ebc975f57ccb23d313311e56ff49d2c7b83a2119054540fd9611ec4db0a2dc9", + "https://bcr.bazel.build/modules/toolchains_buildbuddy/0.0.4/MODULE.bazel": "735f0ed45a0334971a61157432127380ae9ce285aea6d489565cb81c7a4cf487", + "https://bcr.bazel.build/modules/toolchains_buildbuddy/0.0.4/source.json": "a5b69ff999ea39cf89df03cb5c174ae6fd621d7a1a7e4bd6be302ff9f2910695", + "https://bcr.bazel.build/modules/toolchains_llvm/1.13.0/MODULE.bazel": "0e5b6bdbcef2db9ba77d843524893d471854535dcb83f9c8b3342e12caeb241b", + "https://bcr.bazel.build/modules/toolchains_llvm/1.13.0/source.json": "76c655990ec05694b67a9b73d970f3cc81e36994e83a8d74019e0f4b197180a4", "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/MODULE.bazel": "7298990c00040a0e2f121f6c32544bab27d4452f80d9ce51349b1a28f3005c43", "https://bcr.bazel.build/modules/yq.bzl/0.1.1/MODULE.bazel": "9039681f9bcb8958ee2c87ffc74bdafba9f4369096a2b5634b88abc0eaefa072", "https://bcr.bazel.build/modules/yq.bzl/0.1.1/source.json": "2d2bad780a9f2b9195a4a370314d2c17ae95eaa745cefc2e12fbc49759b15aa3", @@ -406,10 +412,34 @@ } } }, + "@@toolchains_buildbuddy+//:extensions.bzl%buildbuddy": { + "general": { + "bzlTransitiveDigest": "YThiSErJv+jiCHJzZIEyk0yegQRS/x+T/ce309eGTvA=", + "usagesDigest": "Bsoz/TyG7VtFcREmDo2ww8qPUuaJJbdzBLxB17leMQM=", + "recordedInputs": [], + "generatedRepoSpecs": { + "buildbuddy_toolchain": { + "repoRuleId": "@@toolchains_buildbuddy+//:rules.bzl%_buildbuddy_toolchain", + "attributes": { + "container_image": "docker://gcr.io/flame-public/rbe-ubuntu24-04@sha256:be9853fc45092d2cf2bda3abed30d22182881659a50bf35c7125161d7cfc8a75", + "llvm": false, + "java_version": "", + "gcc_version": "", + "msvc_edition": "Community", + "msvc_release": "2022", + "msvc_version": "14.39.33519", + "windows_kits_release": "10", + "windows_kits_version": "10.0.22621.0", + "extra_cxx_builtin_include_directories": [] + } + } + } + } + }, "@@toolchains_llvm+//toolchain/extensions:distributions.bzl%llvm_distributions": { "general": { "bzlTransitiveDigest": "RfYsFLwRh0rVY8ReiYgbOEyr84zuBs7mbcHq3dPY3jI=", - "usagesDigest": "Kkvj0RQS/gl7yG/Xtc24V0QVoZToxoJ8Qign1KUny5U=", + "usagesDigest": "SpzySxlrOW6f2CQobJdEjFJjMM7e9Gt1jpvpK52eaMA=", "recordedInputs": [], "generatedRepoSpecs": { "llvm_distributions_data": { diff --git a/bazel/BUILD.bazel b/bazel/BUILD.bazel new file mode 100644 index 0000000..d35bcad --- /dev/null +++ b/bazel/BUILD.bazel @@ -0,0 +1,21 @@ +package(default_visibility = ["//visibility:public"]) + +# Remote execution platform: Ubuntu 24.04 container image provided by +# toolchains_buildbuddy, overridable with +# --repo_env=RBE_CONTAINER_IMAGE=docker://@sha256: (see rbe.bzl). +# Only the container image is inherited; the +# BuildBuddy-specific properties are cleared (an empty value drops an inherited +# key) so the platform also works on other REAPI backends. +platform( + name = "ubuntu24_04_amd64", + constraint_values = [ + "@platforms//os:linux", + "@platforms//cpu:x86_64", + ], + exec_properties = { + "Arch": "", + "OSFamily": "", + "dockerNetwork": "", + }, + parents = ["@rbe_container_image//:platform"], +) diff --git a/bazel/rbe.bzl b/bazel/rbe.bzl new file mode 100644 index 0000000..94efeea --- /dev/null +++ b/bazel/rbe.bzl @@ -0,0 +1,29 @@ +"""Remote execution container image, overridable with --repo_env.""" + +_BUILD = """\ +# Generated by //bazel:rbe.bzl. +platform( + name = "platform", + exec_properties = {exec_properties}, + parents = ["@buildbuddy_toolchain//:platform_linux_x86_64"], + visibility = ["//visibility:public"], +) +""" + +def _rbe_container_image_impl(rctx): + image = rctx.getenv("RBE_CONTAINER_IMAGE", "") + exec_properties = {"container-image": image} if image else {} + rctx.file("BUILD.bazel", _BUILD.format(exec_properties = repr(exec_properties))) + +rbe_container_image = repository_rule( + implementation = _rbe_container_image_impl, + doc = """Platform that sets the container image of remote actions. + +It inherits from the toolchains_buildbuddy platform (whose image is configured +in MODULE.bazel) and, when the RBE_CONTAINER_IMAGE repository environment +variable is set, overrides `container-image` with its value, e.g.: + + common --repo_env=RBE_CONTAINER_IMAGE=docker://registry.example.com/rbe@sha256: +""", + environ = ["RBE_CONTAINER_IMAGE"], +) diff --git a/e2e/dnf-hermetic-lock/.bazelrc b/e2e/dnf-hermetic-lock/.bazelrc index d248dc2..28e4693 100644 --- a/e2e/dnf-hermetic-lock/.bazelrc +++ b/e2e/dnf-hermetic-lock/.bazelrc @@ -1,3 +1,6 @@ +# Startup options +startup --experimental_remote_repo_contents_cache + # Bzlmod common --enable_bzlmod @@ -6,4 +9,4 @@ test:ci --test_output=errors test:ci --test_summary=terse # User configuration if present -try-import %workspace%/../../.bazelrc.user +try-import %workspace%/.bazelrc.user diff --git a/tools/setup_buildbuddy.sh b/tools/setup_buildbuddy.sh new file mode 100755 index 0000000..b367a9b --- /dev/null +++ b/tools/setup_buildbuddy.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Unifies the creation of .bazelrc.user containing BuildBuddy configuration +# for the root workspace and nested workspaces (e2e/*). + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" +cd "${REPO_ROOT}" + +ENDPOINT="${1:-${BUILDBUDDY_ENDPOINT:-}}" +API_KEY="${2:-${BUILDBUDDY_API_KEY:-}}" + +if [ -z "${ENDPOINT}" ] || [ -z "${API_KEY}" ]; then + echo "Usage: $0 [ ] (or set BUILDBUDDY_ENDPOINT and BUILDBUDDY_API_KEY)" >&2 + exit 1 +fi + +config_profile="buildbuddy-rbe" +if [ "$(uname -s)" != "Linux" ]; then + config_profile="buildbuddy" +fi + +write_buildbuddy_rc() { + local target_file="$1" + local profile="$2" + + cat < "${target_file}" +common --config=${profile} +common:buildbuddy --bes_backend=grpcs://${ENDPOINT} +common:buildbuddy --bes_results_url=https://${ENDPOINT}/invocation/ +common:buildbuddy --remote_cache=grpcs://${ENDPOINT} +EOF + if [ "${profile}" = "buildbuddy-rbe" ]; then + echo "common:buildbuddy-rbe --remote_executor=grpcs://${ENDPOINT}" >> "${target_file}" + fi + echo "common:buildbuddy --remote_header=x-buildbuddy-api-key=${API_KEY}" >> "${target_file}" +} + +write_buildbuddy_rc ".bazelrc.user" "${config_profile}" + +for suite in e2e/*; do + if [ -d "${suite}" ]; then + write_buildbuddy_rc "${suite}/.bazelrc.user" "buildbuddy" + fi +done From 029e8c134486a157a80a6bf4268b60a45b3a16cc Mon Sep 17 00:00:00 2001 From: Manuel Naranjo Date: Sat, 7 Nov 2026 13:46:42 +0100 Subject: [PATCH 2/2] ci: use BUILDBUDDY_TOKEN secret name matching repository configuration --- .github/actions/setup-bazel/action.yml | 2 +- .github/workflows/build.yaml | 4 ++-- .github/workflows/ci.bazelrc | 2 +- .github/workflows/ci.yaml | 2 +- .github/workflows/release.yml | 2 +- tools/setup_buildbuddy.sh | 5 +++-- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/actions/setup-bazel/action.yml b/.github/actions/setup-bazel/action.yml index 9aa41e8..d71a02b 100644 --- a/.github/actions/setup-bazel/action.yml +++ b/.github/actions/setup-bazel/action.yml @@ -27,5 +27,5 @@ runs: shell: bash env: BUILDBUDDY_ENDPOINT: ${{ inputs.buildbuddy-endpoint }} - BUILDBUDDY_API_KEY: ${{ inputs.buildbuddy-api-key }} + BUILDBUDDY_TOKEN: ${{ inputs.buildbuddy-api-key }} run: tools/setup_buildbuddy.sh diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 014b4c8..d284822 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -16,7 +16,7 @@ on: type: string default: "" secrets: - BUILDBUDDY_API_KEY: + BUILDBUDDY_TOKEN: required: false jobs: @@ -29,7 +29,7 @@ jobs: - uses: ./.github/actions/setup-bazel with: buildbuddy-endpoint: ${{ vars.BUILDBUDDY_ENDPOINT }} - buildbuddy-api-key: ${{ secrets.BUILDBUDDY_API_KEY }} + buildbuddy-api-key: ${{ secrets.BUILDBUDDY_TOKEN }} - name: Build run: | mkdir -p dist diff --git a/.github/workflows/ci.bazelrc b/.github/workflows/ci.bazelrc index 891bc3a..bb6a6a2 100644 --- a/.github/workflows/ci.bazelrc +++ b/.github/workflows/ci.bazelrc @@ -6,7 +6,7 @@ common --show_progress_rate_limit=30 test --test_output=errors # BuildBuddy remote cache / execution, enabled by the workflows when the -# BUILDBUDDY_ENDPOINT repository variable (host name) and the BUILDBUDDY_API_KEY +# BUILDBUDDY_ENDPOINT repository variable (host name) and the BUILDBUDDY_TOKEN # secret are set. # The workflow writes the endpoints derived from the host (--bes_backend, # --remote_cache and, for buildbuddy-rbe, --remote_executor at grpcs://; diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b4fa926..0445163 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,7 +20,7 @@ jobs: - uses: ./.github/actions/setup-bazel with: buildbuddy-endpoint: ${{ vars.BUILDBUDDY_ENDPOINT }} - buildbuddy-api-key: ${{ secrets.BUILDBUDDY_API_KEY }} + buildbuddy-api-key: ${{ secrets.BUILDBUDDY_TOKEN }} - name: Build run: bazel --bazelrc=.github/workflows/ci.bazelrc build //... - name: Test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index db42fea..13a7d37 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,7 +24,7 @@ jobs: ref: ${{ inputs.tag_name || github.ref_name }} version: ${{ inputs.tag_name || github.ref_name }} secrets: - BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }} + BUILDBUDDY_TOKEN: ${{ secrets.BUILDBUDDY_TOKEN }} release: needs: build diff --git a/tools/setup_buildbuddy.sh b/tools/setup_buildbuddy.sh index b367a9b..a1aac1a 100755 --- a/tools/setup_buildbuddy.sh +++ b/tools/setup_buildbuddy.sh @@ -9,10 +9,11 @@ REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" cd "${REPO_ROOT}" ENDPOINT="${1:-${BUILDBUDDY_ENDPOINT:-}}" -API_KEY="${2:-${BUILDBUDDY_API_KEY:-}}" +ENDPOINT="${ENDPOINT%/}" +API_KEY="${2:-${BUILDBUDDY_TOKEN:-${BUILDBUDDY_API_KEY:-}}}" if [ -z "${ENDPOINT}" ] || [ -z "${API_KEY}" ]; then - echo "Usage: $0 [ ] (or set BUILDBUDDY_ENDPOINT and BUILDBUDDY_API_KEY)" >&2 + echo "Usage: $0 [ ] (or set BUILDBUDDY_ENDPOINT and BUILDBUDDY_TOKEN)" >&2 exit 1 fi