optimize: parallelize test dependencies installation

This commit is contained in:
yetone
2025-08-02 17:45:13 +08:00
parent 751d1855e7
commit 54ef723283

View File

@@ -29,14 +29,13 @@ log_verbose() {
fi fi
} }
clone_deps() { # Process a single dependency (used for parallel execution)
local deps_dir=${1:-"$PWD/deps"} process_single_dep() {
log_verbose "Cloning dependencies into: $deps_dir" local dep="$1"
mkdir -p "$deps_dir" local deps_dir="$2"
local repo_name="$(echo "$dep" | cut -d'/' -f2)"
for dep in "${DEPS[@]}"; do
repo_name="$(echo "$dep" | cut -d'/' -f2)"
local repo_path="$deps_dir/$repo_name" local repo_path="$deps_dir/$repo_name"
if [ -d "$repo_path/.git" ]; then if [ -d "$repo_path/.git" ]; then
log_verbose "Updating existing repository: $repo_path" log_verbose "Updating existing repository: $repo_path"
( (
@@ -48,6 +47,7 @@ clone_deps() {
git reset -q --hard origin/master git reset -q --hard origin/master
else else
log "Could not find main or master branch for $repo_name" log "Could not find main or master branch for $repo_name"
return 1
fi fi
) )
else else
@@ -58,7 +58,36 @@ clone_deps() {
log_verbose "Cloning new repository: $dep to $repo_path" log_verbose "Cloning new repository: $dep to $repo_path"
git clone -q --depth 1 "https://github.com/${dep}.git" "$repo_path" git clone -q --depth 1 "https://github.com/${dep}.git" "$repo_path"
fi fi
}
clone_deps() {
local deps_dir=${1:-"$PWD/deps"}
log_verbose "Cloning dependencies into: $deps_dir (parallel mode)"
mkdir -p "$deps_dir"
# Array to store background process PIDs
local pids=()
# Start all dependency processes in parallel
for dep in "${DEPS[@]}"; do
process_single_dep "$dep" "$deps_dir" &
pids+=($!)
done done
# Wait for all background processes to complete and check their exit status
local failed_count=0
for pid in "${pids[@]}"; do
if ! wait "$pid"; then
((failed_count++))
fi
done
if [ "$failed_count" -gt 0 ]; then
log "Warning: $failed_count dependencies failed to process"
return 1
fi
log_verbose "All dependencies processed successfully"
} }
install_luals() { install_luals() {