From a27cd2d28150b71882847a8bfdc03d275e29a1eb Mon Sep 17 00:00:00 2001 From: Son Luong Ngoc Date: Fri, 27 Mar 2026 06:50:07 +0700 Subject: [PATCH] bazel: re-organize bazelrc (#15522) Replaced ci.bazelrc and v8-ci.bazelrc by custom configs inside the main .bazelrc file. As a result, github workflows setup is simplified down to a single '--config=' flag usage. Moved the build metadata flags to config=ci. Added custom tags metadata to help differentiate invocations based on workflow (bazel vs v8) and os (linux/macos/windows). Enabled users to override the default values in .bazelrc by using a user.bazelrc file locally. Added user.bazelrc to gitignore. --- .bazelrc | 48 ++++++++++++++++++++++++++ .github/workflows/bazel.yml | 12 ++++--- .github/workflows/ci.bazelrc | 27 --------------- .github/workflows/rusty-v8-release.yml | 2 +- .github/workflows/v8-canary.yml | 2 +- .github/workflows/v8-ci.bazelrc | 5 --- .gitignore | 1 + 7 files changed, 59 insertions(+), 38 deletions(-) delete mode 100644 .github/workflows/ci.bazelrc delete mode 100644 .github/workflows/v8-ci.bazelrc diff --git a/.bazelrc b/.bazelrc index 2ff9cbc28..ce7c1e1d4 100644 --- a/.bazelrc +++ b/.bazelrc @@ -60,3 +60,51 @@ common:remote --jobs=800 # Enable pipelined compilation since we are not bound by local CPU count. #common:remote --@rules_rust//rust/settings:pipelined_compilation +# GitHub Actions CI configs. +common:ci --remote_download_minimal +common:ci --keep_going +common:ci --verbose_failures +common:ci --build_metadata=REPO_URL=https://github.com/openai/codex.git +common:ci --build_metadata=ROLE=CI +common:ci --build_metadata=VISIBILITY=PUBLIC + +# Disable disk cache in CI since we have a remote one and aren't using persistent workers. +common:ci --disk_cache= + +# Shared config for the main Bazel CI workflow. +common:ci-bazel --config=ci +common:ci-bazel --build_metadata=TAG_workflow=bazel + +# Rearrange caches on Windows so they're on the same volume as the checkout. +common:ci-windows --config=ci-bazel +common:ci-windows --build_metadata=TAG_os=windows +common:ci-windows --repo_contents_cache=D:/a/.cache/bazel-repo-contents-cache +common:ci-windows --repository_cache=D:/a/.cache/bazel-repo-cache + +# We prefer to run the build actions entirely remotely so we can dial up the concurrency. +# We have platform-specific tests, so we want to execute the tests on all platforms using the strongest sandboxing available on each platform. + +# On linux, we can do a full remote build/test, by targeting the right (x86/arm) runners, so we have coverage of both. +# Linux crossbuilds don't work until we untangle the libc constraint mess. +common:ci-linux --config=ci-bazel +common:ci-linux --build_metadata=TAG_os=linux +common:ci-linux --config=remote +common:ci-linux --strategy=remote +common:ci-linux --platforms=//:rbe + +# On mac, we can run all the build actions remotely but test actions locally. +common:ci-macos --config=ci-bazel +common:ci-macos --build_metadata=TAG_os=macos +common:ci-macos --config=remote +common:ci-macos --strategy=remote +common:ci-macos --strategy=TestRunner=darwin-sandbox,local + +# Linux-only V8 CI config. +common:ci-v8 --config=ci +common:ci-v8 --build_metadata=TAG_workflow=v8 +common:ci-v8 --build_metadata=TAG_os=linux +common:ci-v8 --config=remote +common:ci-v8 --strategy=remote + +# Optional per-user local overrides. +try-import %workspace%/user.bazelrc diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index 0497cd54e..1c12db52b 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -144,10 +144,7 @@ jobs: bazel_args=( test --test_verbose_timeout_warnings - --build_metadata=REPO_URL=https://github.com/openai/codex.git --build_metadata=COMMIT_SHA=$(git rev-parse HEAD) - --build_metadata=ROLE=CI - --build_metadata=VISIBILITY=PUBLIC ) bazel_targets=( @@ -164,6 +161,13 @@ jobs: bazel_args+=("--test_env=CODEX_JS_REPL_NODE_PATH=${node_bin}") fi + ci_config=ci-linux + if [[ "${RUNNER_OS:-}" == "macOS" ]]; then + ci_config=ci-macos + elif [[ "${RUNNER_OS:-}" == "Windows" ]]; then + ci_config=ci-windows + fi + if [[ -n "${BUILDBUDDY_API_KEY:-}" ]]; then echo "BuildBuddy API key is available; using remote Bazel configuration." # Work around Bazel 9 remote repo contents cache / overlay materialization failures @@ -173,8 +177,8 @@ jobs: set +e bazel $BAZEL_STARTUP_ARGS \ --noexperimental_remote_repo_contents_cache \ - --bazelrc=.github/workflows/ci.bazelrc \ "${bazel_args[@]}" \ + "--config=${ci_config}" \ "--remote_header=x-buildbuddy-api-key=$BUILDBUDDY_API_KEY" \ -- \ "${bazel_targets[@]}" \ diff --git a/.github/workflows/ci.bazelrc b/.github/workflows/ci.bazelrc deleted file mode 100644 index 997a774eb..000000000 --- a/.github/workflows/ci.bazelrc +++ /dev/null @@ -1,27 +0,0 @@ -common --remote_download_minimal -common --keep_going -common --verbose_failures - -# Disable disk cache since we have remote one and aren't using persistent workers. -common --disk_cache= - -# Rearrange caches on Windows so they're on the same volume as the checkout. -common:windows --repo_contents_cache=D:/a/.cache/bazel-repo-contents-cache -common:windows --repository_cache=D:/a/.cache/bazel-repo-cache - -# We prefer to run the build actions entirely remotely so we can dial up the concurrency. -# We have platform-specific tests, so we want to execute the tests on all platforms using the strongest sandboxing available on each platform. - -# On linux, we can do a full remote build/test, by targeting the right (x86/arm) runners, so we have coverage of both. -# Linux crossbuilds don't work until we untangle the libc constraint mess. -common:linux --config=remote -common:linux --strategy=remote -common:linux --platforms=//:rbe - -# On mac, we can run all the build actions remotely but test actions locally. -common:macos --config=remote -common:macos --strategy=remote -common:macos --strategy=TestRunner=darwin-sandbox,local - -# On windows we cannot cross-build the tests but run them locally due to what appears to be a Bazel bug -# (windows vs unix path confusion) diff --git a/.github/workflows/rusty-v8-release.yml b/.github/workflows/rusty-v8-release.yml index bb191b88c..60aac2436 100644 --- a/.github/workflows/rusty-v8-release.yml +++ b/.github/workflows/rusty-v8-release.yml @@ -116,8 +116,8 @@ jobs: bazel \ --noexperimental_remote_repo_contents_cache \ - --bazelrc=.github/workflows/v8-ci.bazelrc \ "${bazel_args[@]}" \ + --config=ci-v8 \ "--remote_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY}" - name: Stage release pair diff --git a/.github/workflows/v8-canary.yml b/.github/workflows/v8-canary.yml index 213c6a7b6..6e068e802 100644 --- a/.github/workflows/v8-canary.yml +++ b/.github/workflows/v8-canary.yml @@ -108,8 +108,8 @@ jobs: bazel \ --noexperimental_remote_repo_contents_cache \ - --bazelrc=.github/workflows/v8-ci.bazelrc \ "${bazel_args[@]}" \ + --config=ci-v8 \ "--remote_header=x-buildbuddy-api-key=${BUILDBUDDY_API_KEY}" - name: Stage release pair diff --git a/.github/workflows/v8-ci.bazelrc b/.github/workflows/v8-ci.bazelrc deleted file mode 100644 index df1b4bec3..000000000 --- a/.github/workflows/v8-ci.bazelrc +++ /dev/null @@ -1,5 +0,0 @@ -import %workspace%/.github/workflows/ci.bazelrc - -common --build_metadata=REPO_URL=https://github.com/openai/codex.git -common --build_metadata=ROLE=CI -common --build_metadata=VISIBILITY=PUBLIC diff --git a/.gitignore b/.gitignore index 8f39b7b1c..82269594b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ node_modules # build dist/ bazel-* +user.bazelrc build/ out/ storybook-static/