diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7489c3f14..ecebe78eed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -508,7 +508,7 @@ jobs: run: bash scripts/ci/install-workspace-dependencies.sh --ignore-scripts - name: Install dependencies if: runner.os == 'Windows' - run: bun install --frozen-lockfile --ignore-scripts --linker=hoisted + run: bash scripts/ci/install-workspace-dependencies.sh --ignore-scripts --linker=hoisted - run: bun run --cwd packages/cli test src/utils/npxCommand.test.ts src/commands/skills.test.ts sdk-tests: diff --git a/examples/k8s-jobs/Dockerfile.example b/examples/k8s-jobs/Dockerfile.example index 56d1510ab4..e35248125a 100644 --- a/examples/k8s-jobs/Dockerfile.example +++ b/examples/k8s-jobs/Dockerfile.example @@ -104,8 +104,10 @@ COPY packages/core/package.json packages/core/ COPY packages/engine/package.json packages/engine/ COPY packages/producer/package.json packages/producer/ +# A corrupt tarball extraction can print an error and then hang instead of +# exiting (fix/regression-docker-build-timeout). Bound each attempt and retry. RUN npm install --global bun && \ - bun install --frozen-lockfile && \ + (timeout 300 bun install --frozen-lockfile || timeout 300 bun install --frozen-lockfile) && \ npm uninstall --global bun # Bring in the source. We're not building the producer's dist/ here — bun's diff --git a/scripts/ci/install-workspace-dependencies.sh b/scripts/ci/install-workspace-dependencies.sh index 93018bf4ad..c7641cc7c9 100644 --- a/scripts/ci/install-workspace-dependencies.sh +++ b/scripts/ci/install-workspace-dependencies.sh @@ -4,9 +4,32 @@ set -u max_attempts=3 retry_delay_seconds="${HF_BUN_INSTALL_RETRY_DELAY_SECONDS:-5}" +install_timeout_seconds="${HF_BUN_INSTALL_TIMEOUT_SECONDS:-300}" + +# Portable: this runs on ubuntu/macos/windows(Git Bash), and GNU `timeout` +# is not reliably present there (macOS has none by default). A hung bun +# install errors then never exits (see fix/regression-docker-build-timeout), +# so without this the retry loop below never fires. +run_with_timeout() { + local seconds=$1 + shift + "$@" & + local pid=$! + local elapsed=0 + while kill -0 "$pid" 2>/dev/null; do + if ((elapsed >= seconds)); then + kill -TERM "$pid" 2>/dev/null + wait "$pid" 2>/dev/null + return 124 + fi + sleep 1 + elapsed=$((elapsed + 1)) + done + wait "$pid" +} for ((attempt = 1; attempt <= max_attempts; attempt += 1)); do - if bun install --frozen-lockfile "$@"; then + if run_with_timeout "$install_timeout_seconds" bun install --frozen-lockfile "$@"; then exit 0 else install_status=$?