diff --git a/.bazelci/isolate.sh b/.bazelci/isolate.sh new file mode 100755 index 0000000000..32a1de3fcf --- /dev/null +++ b/.bazelci/isolate.sh @@ -0,0 +1,32 @@ +#!/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}" + +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 ".git" \ + ! -name ".bazelci" \ + -exec rm -rf '{}' + diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index aeeb7103d6..1159c2f732 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -180,6 +180,8 @@ tasks: name: "Sphinxdocs: Ubuntu" working_directory: "sphinxdocs" platform: ubuntu2204 + shell_commands: + - "../.bazelci/isolate.sh sphinxdocs" build_targets: - "//..." test_targets: @@ -188,6 +190,8 @@ tasks: name: "Sphinxdocs: Mac" working_directory: "sphinxdocs" platform: macos_arm64 + shell_commands: + - "../.bazelci/isolate.sh sphinxdocs" build_targets: - "//..." test_targets: