Skip to content

Commit 0825f56

Browse files
abnobdossAbanoub Doss
andauthored
ci: retry build dir cleanup on Windows (#807)
## What Retry `rm -rf` cleanup in the CMake CI helper scripts. Windows can briefly keep a just-built executable or DLL open, which can make cleanup fail even after the build and tests have passed. `build_example.sh` retries before configuring and still lets `mkdir` fail if the directory remains, so it will not build in a half-deleted tree. `build_iceberg.sh` retries after the build and does not fail an otherwise successful job if final cleanup is still blocked. --------- Co-authored-by: Abanoub Doss <abanoub.doss@gmail.com>
1 parent 2191844 commit 0825f56

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

ci/scripts/build_example.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,18 @@ source_dir=${1}
2323
build_dir=${1}/build
2424
run_example=${ICEBERG_RUN_EXAMPLE:-OFF}
2525

26-
rm -rf "${build_dir}"
26+
# Clean up before configuring. If Windows still holds a just-built exe/dll
27+
# after the retries, let mkdir fail rather than reuse a half-deleted tree.
28+
for attempt in 1 2 3; do
29+
if rm -rf "${build_dir}"; then
30+
break
31+
fi
32+
if [[ "${attempt}" != "3" ]]; then
33+
sleep 2
34+
else
35+
echo "Failed to remove build directory after 3 attempts: ${build_dir}" >&2
36+
fi
37+
done
2738
mkdir "${build_dir}"
2839
pushd ${build_dir}
2940

ci/scripts/build_iceberg.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,15 @@ fi
105105

106106
popd
107107

108-
# clean up between builds
109-
rm -rf ${build_dir}
108+
# Clean up after the build. Windows can briefly hold a just-built exe/dll,
109+
# so retry but do not fail an otherwise successful CI job.
110+
for attempt in 1 2 3; do
111+
if rm -rf "${build_dir}"; then
112+
break
113+
fi
114+
if [[ "${attempt}" != "3" ]]; then
115+
sleep 2
116+
else
117+
echo "Failed to remove build directory after 3 attempts: ${build_dir}" >&2
118+
fi
119+
done

0 commit comments

Comments
 (0)