Skip to content

Commit 7a68221

Browse files
authored
tests: better simulate BCR environment (#3706)
Better simulate the BCR environment by removing files that aren't extracted when BCR extracts the release archive.
1 parent c33ba23 commit 7a68221

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

.bazelci/isolate.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
module_dir="${1:-}"
5+
6+
if [[ -z "${module_dir}" ]]; then
7+
echo "Usage: $0 <module_directory>"
8+
exit 1
9+
fi
10+
11+
# Find the repository root assuming this script is in .bazelci/
12+
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13+
repo_root="$(dirname "${script_dir}")"
14+
15+
cd "${repo_root}"
16+
17+
if [[ ! -f "MODULE.bazel" ]]; then
18+
echo "Error: MODULE.bazel not found in ${repo_root}. Are you sure this is the repo root?"
19+
exit 1
20+
fi
21+
22+
if [[ ! -d "${module_dir}" ]]; then
23+
echo "Error: Module directory '${module_dir}' not found in ${repo_root}."
24+
exit 1
25+
fi
26+
27+
echo "Removing files outside of ${module_dir} to simulate BCR environment..."
28+
find . -maxdepth 1 -mindepth 1 \
29+
! -name "${module_dir}" \
30+
! -name ".git" \
31+
! -name ".bazelci" \
32+
-exec rm -rf '{}' +

.bazelci/presubmit.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ tasks:
180180
name: "Sphinxdocs: Ubuntu"
181181
working_directory: "sphinxdocs"
182182
platform: ubuntu2204
183+
shell_commands:
184+
- "../.bazelci/isolate.sh sphinxdocs"
183185
build_targets:
184186
- "//..."
185187
test_targets:
@@ -188,6 +190,8 @@ tasks:
188190
name: "Sphinxdocs: Mac"
189191
working_directory: "sphinxdocs"
190192
platform: macos_arm64
193+
shell_commands:
194+
- "../.bazelci/isolate.sh sphinxdocs"
191195
build_targets:
192196
- "//..."
193197
test_targets:

0 commit comments

Comments
 (0)