Skip to content

Commit cceccc7

Browse files
Prucekclaude
andcommitted
parallelize binary builds and add BUILD_IMAGES allow-list
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f56c667 commit cceccc7

1 file changed

Lines changed: 40 additions & 4 deletions

File tree

hack/install.sh

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ if [[ ${2:-} == "remove-dummy" ]]; then
2727
rm -f cmd/repo-init/frontend/dist/dummy
2828
fi
2929

30+
# BUILD_IMAGES is an allow-list: if set, only these binaries are built.
31+
# SKIPPED_IMAGES is a deny-list: if set, these binaries are skipped.
32+
# BUILD_IMAGES takes precedence over SKIPPED_IMAGES.
33+
declare -A build_images_map
34+
if [[ -n "${BUILD_IMAGES:-}" ]]; then
35+
echo "Building only: ${BUILD_IMAGES}"
36+
IFS=',' read -ra build_array <<< "${BUILD_IMAGES}"
37+
for img in "${build_array[@]}"; do
38+
build_images_map["${img}"]=1
39+
done
40+
fi
41+
3042
declare -A skipped_images_map
3143
if [[ -n "${SKIPPED_IMAGES:-}" ]]; then
3244
echo "Skipping images: ${SKIPPED_IMAGES}"
@@ -36,11 +48,35 @@ if [[ -n "${SKIPPED_IMAGES:-}" ]]; then
3648
done
3749
fi
3850

39-
for dir in $( find ./cmd/ -mindepth 1 -maxdepth 1 -type d -not \( -name '*ipi-deprovison*' \) ); do
51+
pids=()
52+
failures=()
53+
54+
for dir in $( find ./cmd/ -mindepth 1 -maxdepth 1 -type d -not \( -name '*ipi-deprovison*' \) | sort ); do
4055
command="$( basename "${dir}" )"
41-
if [[ -n "${skipped_images_map[${command}]:-}" ]]; then
42-
echo "Skipping install for ${command} (in SKIPPED_IMAGES)"
56+
57+
# If BUILD_IMAGES is set, only build listed binaries
58+
if [[ -n "${BUILD_IMAGES:-}" ]]; then
59+
if [[ -z "${build_images_map[${command}]:-}" ]]; then
4360
continue
61+
fi
62+
elif [[ -n "${skipped_images_map[${command}]:-}" ]]; then
63+
echo "Skipping install for ${command} (in SKIPPED_IMAGES)"
64+
continue
4465
fi
45-
go install -v $RACE_FLAG -ldflags "-X 'sigs.k8s.io/prow/pkg/version.Name=${command}' -X 'sigs.k8s.io/prow/pkg/version.Version=${version}'" "./cmd/${command}/..."
66+
67+
echo "Building ${command}..."
68+
go install -v $RACE_FLAG -ldflags "-X 'sigs.k8s.io/prow/pkg/version.Name=${command}' -X 'sigs.k8s.io/prow/pkg/version.Version=${version}'" "./cmd/${command}/..." &
69+
pids+=($!)
4670
done
71+
72+
# Wait for all parallel builds and collect failures
73+
for pid in "${pids[@]}"; do
74+
if ! wait "$pid"; then
75+
failures+=("$pid")
76+
fi
77+
done
78+
79+
if [[ ${#failures[@]} -gt 0 ]]; then
80+
echo "ERROR: ${#failures[@]} build(s) failed"
81+
exit 1
82+
fi

0 commit comments

Comments
 (0)