From 566f76d6d15bc220708d2203c690f5952c959b83 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Tue, 14 Apr 2026 16:42:45 -0700 Subject: [PATCH 1/3] tests: better simulate BCR environment --- .bazelci/isolate.sh | 22 ++++++++++++++++++++++ .bazelci/presubmit.yml | 11 +++++++++++ 2 files changed, 33 insertions(+) create mode 100755 .bazelci/isolate.sh diff --git a/.bazelci/isolate.sh b/.bazelci/isolate.sh new file mode 100755 index 0000000000..4b82b53468 --- /dev/null +++ b/.bazelci/isolate.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -euo pipefail + +MODULE_DIR="${1:-}" + +if [[ -z "${MODULE_DIR}" ]]; then + echo "Usage: $0 " + exit 1 +fi + +# Find the repository root assuming this script is in .bazelci/ +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(dirname "$SCRIPT_DIR")" + +cd "${REPO_ROOT}" + +echo "Removing files outside of ${MODULE_DIR} to simulate BCR environment..." +find . -maxdepth 1 -mindepth 1 \ + ! -name "${MODULE_DIR}" \ + ! -name ".git" \ + ! -name ".bazelci" \ + -exec rm -rf '{}' + diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index aeeb7103d6..ebcf8451a9 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -100,6 +100,7 @@ buildifier: bazel: ${{ bazel }} working_directory: gazelle/examples/bzlmod_build_file_generation shell_commands: + - "../../../.bazelci/isolate.sh gazelle" - "echo 'common --override_module=rules_python=' >> .bazelrc" - "bazel run //:gazelle_python_manifest.update" - "bazel run //:gazelle -- update" @@ -159,6 +160,8 @@ tasks: <<: *minimum_supported_version name: "Gazelle: workspace, minimum supported Bazel version" platform: ubuntu2204 + shell_commands: + - "../.bazelci/isolate.sh gazelle" build_targets: ["//..."] test_targets: ["//..."] working_directory: gazelle @@ -166,12 +169,16 @@ tasks: <<: *common_workspace_flags name: "Gazelle: workspace" platform: ubuntu2204 + shell_commands: + - "../.bazelci/isolate.sh gazelle" build_targets: ["//..."] test_targets: ["//..."] working_directory: gazelle gazelle_extension: name: "Gazelle: default settings" platform: ubuntu2204 + shell_commands: + - "../.bazelci/isolate.sh gazelle" build_targets: ["//..."] test_targets: ["//..."] working_directory: gazelle @@ -180,6 +187,8 @@ tasks: name: "Sphinxdocs: Ubuntu" working_directory: "sphinxdocs" platform: ubuntu2204 + shell_commands: + - "../.bazelci/isolate.sh sphinxdocs" build_targets: - "//..." test_targets: @@ -188,6 +197,8 @@ tasks: name: "Sphinxdocs: Mac" working_directory: "sphinxdocs" platform: macos_arm64 + shell_commands: + - "../.bazelci/isolate.sh sphinxdocs" build_targets: - "//..." test_targets: From b2d5a52840904252069df543ab2097990dbda356 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Tue, 14 Apr 2026 19:36:13 -0700 Subject: [PATCH 2/3] add some checks to prevent rm -fr deleting too much --- .bazelci/isolate.sh | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/.bazelci/isolate.sh b/.bazelci/isolate.sh index 4b82b53468..32a1de3fcf 100755 --- a/.bazelci/isolate.sh +++ b/.bazelci/isolate.sh @@ -1,22 +1,32 @@ #!/usr/bin/env bash set -euo pipefail -MODULE_DIR="${1:-}" +module_dir="${1:-}" -if [[ -z "${MODULE_DIR}" ]]; then +if [[ -z "${module_dir}" ]]; then echo "Usage: $0 " exit 1 fi # Find the repository root assuming this script is in .bazelci/ -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -REPO_ROOT="$(dirname "$SCRIPT_DIR")" +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +repo_root="$(dirname "${script_dir}")" -cd "${REPO_ROOT}" +cd "${repo_root}" -echo "Removing files outside of ${MODULE_DIR} to simulate BCR environment..." +if [[ ! -f "MODULE.bazel" ]]; then + echo "Error: MODULE.bazel not found in ${repo_root}. Are you sure this is the repo root?" + exit 1 +fi + +if [[ ! -d "${module_dir}" ]]; then + echo "Error: Module directory '${module_dir}' not found in ${repo_root}." + exit 1 +fi + +echo "Removing files outside of ${module_dir} to simulate BCR environment..." find . -maxdepth 1 -mindepth 1 \ - ! -name "${MODULE_DIR}" \ + ! -name "${module_dir}" \ ! -name ".git" \ ! -name ".bazelci" \ -exec rm -rf '{}' + From 8206d47abbbfd46eedb40892766c9c84346fc140 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Tue, 14 Apr 2026 19:41:21 -0700 Subject: [PATCH 3/3] remove isolate from gazelle --- .bazelci/presubmit.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index ebcf8451a9..1159c2f732 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -100,7 +100,6 @@ buildifier: bazel: ${{ bazel }} working_directory: gazelle/examples/bzlmod_build_file_generation shell_commands: - - "../../../.bazelci/isolate.sh gazelle" - "echo 'common --override_module=rules_python=' >> .bazelrc" - "bazel run //:gazelle_python_manifest.update" - "bazel run //:gazelle -- update" @@ -160,8 +159,6 @@ tasks: <<: *minimum_supported_version name: "Gazelle: workspace, minimum supported Bazel version" platform: ubuntu2204 - shell_commands: - - "../.bazelci/isolate.sh gazelle" build_targets: ["//..."] test_targets: ["//..."] working_directory: gazelle @@ -169,16 +166,12 @@ tasks: <<: *common_workspace_flags name: "Gazelle: workspace" platform: ubuntu2204 - shell_commands: - - "../.bazelci/isolate.sh gazelle" build_targets: ["//..."] test_targets: ["//..."] working_directory: gazelle gazelle_extension: name: "Gazelle: default settings" platform: ubuntu2204 - shell_commands: - - "../.bazelci/isolate.sh gazelle" build_targets: ["//..."] test_targets: ["//..."] working_directory: gazelle