From df538b3aaf72c5f2c51940d56793783200d52b41 Mon Sep 17 00:00:00 2001 From: Jack Kingsman Date: Thu, 12 Mar 2026 19:53:10 -0700 Subject: [PATCH] Parallelize docker_ci --- scripts/docker_ci.sh | 48 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/scripts/docker_ci.sh b/scripts/docker_ci.sh index e08150b..cd0a629 100755 --- a/scripts/docker_ci.sh +++ b/scripts/docker_ci.sh @@ -22,8 +22,6 @@ run_combo() { local npm_version="$2" local image="node:${node_version}-slim" - echo -e "${YELLOW}=== Node ${node_version} / npm ${npm_version} ===${NC}" - docker run --rm \ -v "$SCRIPT_DIR:/src:ro" \ -w /tmp \ @@ -39,14 +37,54 @@ run_combo() { npm run build " - echo -e "${GREEN}Passed:${NC} Node ${node_version} / npm ${npm_version}" - echo } +TMP_DIR="$(mktemp -d)" +declare -a JOB_PIDS=() +declare -a JOB_LABELS=() +declare -a JOB_LOGS=() + +cleanup() { + rm -rf "$TMP_DIR" +} + +trap cleanup EXIT + for node_version in "${NODE_VERSIONS[@]}"; do for npm_version in "${NPM_VERSIONS[@]}"; do - run_combo "$node_version" "$npm_version" + label="Node ${node_version} / npm ${npm_version}" + log_file="$TMP_DIR/node-${node_version}-npm-${npm_version}.log" + + echo -e "${BLUE}Starting:${NC} ${label}" + ( + echo -e "${YELLOW}=== ${label} ===${NC}" + run_combo "$node_version" "$npm_version" + ) >"$log_file" 2>&1 & + + JOB_PIDS+=("$!") + JOB_LABELS+=("$label") + JOB_LOGS+=("$log_file") done done +echo + +failures=0 +for idx in "${!JOB_PIDS[@]}"; do + if wait "${JOB_PIDS[$idx]}"; then + echo -e "${GREEN}Passed:${NC} ${JOB_LABELS[$idx]}" + else + failures=$((failures + 1)) + echo -e "${RED}Failed:${NC} ${JOB_LABELS[$idx]}" + echo -e "${YELLOW}--- ${JOB_LABELS[$idx]} log ---${NC}" + cat "${JOB_LOGS[$idx]}" + echo + fi +done + +if (( failures > 0 )); then + echo -e "${RED}=== Docker CI matrix failed (${failures} job(s)) ===${NC}" + exit 1 +fi + echo -e "${GREEN}=== Docker CI matrix passed ===${NC}"