fix(hwlab): route node yaml deps through proxy (#819)
Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
@@ -140,7 +140,7 @@ targets:
|
||||
- ARG no_proxy
|
||||
- RUN ln -sf /usr/local/bin/bun /usr/local/bin/bunx
|
||||
- ENV HWLAB_CI_NODE_DEPS=/opt/hwlab-ci-node-deps/node_modules
|
||||
- RUN set -eu; export HTTP_PROXY="${HTTP_PROXY:-${http_proxy:-}}"; export HTTPS_PROXY="${HTTPS_PROXY:-${https_proxy:-$HTTP_PROXY}}"; export ALL_PROXY="${ALL_PROXY:-${all_proxy:-}}"; export NO_PROXY="${NO_PROXY:-${no_proxy:-}}"; export http_proxy="$HTTP_PROXY"; export https_proxy="$HTTPS_PROXY"; export all_proxy="$ALL_PROXY"; export no_proxy="$NO_PROXY"; export npm_config_proxy="$HTTP_PROXY"; export npm_config_https_proxy="$HTTPS_PROXY"; export npm_config_registry="https://registry.npmjs.org/"; export npm_config_fetch_retries=2; export npm_config_fetch_retry_mintimeout=2000; export npm_config_fetch_retry_maxtimeout=16000; export npm_config_fetch_timeout=120000; mkdir -p /opt/hwlab-ci-node-deps; cd /opt/hwlab-ci-node-deps; printf '{"private":true,"dependencies":{}}\n' > package.json; ok=0; delay=2; for attempt in 1 2 3 4 5; do echo "{\"event\":\"tools-yaml-node-npm-install\",\"attempt\":\"$attempt/5\",\"proxy\":\"${HTTPS_PROXY:-$HTTP_PROXY}\"}" >&2; if timeout 180s npm install --package-lock=false --no-save --ignore-scripts --no-audit --no-fund --omit=dev yaml@2.8.3; then ok=1; break; fi; if [ "$attempt" = 5 ]; then break; fi; echo "{\"event\":\"tools-yaml-node-npm-install\",\"status\":\"retrying\",\"attempt\":\"$attempt/5\",\"sleepSeconds\":$delay}" >&2; sleep "$delay"; delay=$((delay * 2)); done; test "$ok" = 1; node --input-type=module -e 'import("/opt/hwlab-ci-node-deps/node_modules/yaml/browser/dist/index.js").then((yaml)=>console.log("yaml-ok", typeof yaml.parse))'
|
||||
- RUN set -eu; export HTTP_PROXY="${HTTP_PROXY:-${http_proxy:-}}"; export HTTPS_PROXY="${HTTPS_PROXY:-${https_proxy:-$HTTP_PROXY}}"; export ALL_PROXY="${ALL_PROXY:-${all_proxy:-}}"; export NO_PROXY="${NO_PROXY:-${no_proxy:-}}"; export http_proxy="$HTTP_PROXY"; export https_proxy="$HTTPS_PROXY"; export all_proxy="$ALL_PROXY"; export no_proxy="$NO_PROXY"; export npm_config_proxy="$HTTP_PROXY"; export npm_config_https_proxy="$HTTPS_PROXY"; export npm_config_registry="https://registry.npmjs.org/"; export BUN_CONFIG_REGISTRY="https://registry.npmjs.org/"; export npm_config_fetch_retries=2; export npm_config_fetch_retry_mintimeout=2000; export npm_config_fetch_retry_maxtimeout=16000; export npm_config_fetch_timeout=120000; mkdir -p /opt/hwlab-ci-node-deps; cd /opt/hwlab-ci-node-deps; printf '{"private":true,"dependencies":{}}\n' > package.json; ok=0; delay=2; for attempt in 1 2 3 4 5; do echo "{\"event\":\"tools-yaml-node-npm-install\",\"attempt\":\"$attempt/5\",\"proxy\":\"${HTTPS_PROXY:-$HTTP_PROXY}\"}" >&2; if timeout 180s npm install --package-lock=false --no-save --ignore-scripts --no-audit --no-fund --omit=dev yaml@2.8.3; then ok=1; break; fi; if [ "$attempt" = 5 ]; then break; fi; echo "{\"event\":\"tools-yaml-node-npm-install\",\"status\":\"retrying\",\"attempt\":\"$attempt/5\",\"sleepSeconds\":$delay}" >&2; sleep "$delay"; delay=$((delay * 2)); done; test "$ok" = 1; node --input-type=module -e 'import("/opt/hwlab-ci-node-deps/node_modules/yaml/browser/dist/index.js").then((yaml)=>console.log("yaml-ok", typeof yaml.parse))'
|
||||
- RUN node --version && npm --version && bun --version && git --version && python3 --version && docker --version && ssh -V
|
||||
buildArgs: {}
|
||||
buildNetwork: host
|
||||
|
||||
@@ -4697,13 +4697,43 @@ function shouldRenderNodeRuntimeControlPlaneLocally(spec: HwlabRuntimeLaneSpec):
|
||||
function yamlDependencyInstallScript(registry: string, fetchTimeoutSeconds: number, retries: number, context: string): string[] {
|
||||
const timeoutSeconds = Math.max(15, Math.ceil(fetchTimeoutSeconds));
|
||||
const retryCount = Math.max(0, Math.floor(retries));
|
||||
const maxAttempts = retryCount + 1;
|
||||
const safeContext = context.replace(/[^A-Za-z0-9_.-]/gu, "-");
|
||||
return [
|
||||
`yaml_registry=${shellQuote(registry)}`,
|
||||
`yaml_fetch_timeout=${shellQuote(String(timeoutSeconds))}`,
|
||||
`yaml_fetch_retries=${shellQuote(String(retryCount))}`,
|
||||
`yaml_max_attempts=${shellQuote(String(maxAttempts))}`,
|
||||
`yaml_dependency_context=${shellQuote(safeContext)}`,
|
||||
"yaml_dependency_log() { echo '{\"event\":\"yaml-dependency\",\"context\":\"'\"$yaml_dependency_context\"'\",\"status\":\"'\"$1\"'\",\"manager\":\"'\"${2:-}\"'\"}' >&2; }",
|
||||
"yaml_prepare_node_package_proxy() {",
|
||||
" yaml_http_proxy=\"${HTTP_PROXY:-${http_proxy:-${ALL_PROXY:-${all_proxy:-}}}}\"",
|
||||
" yaml_https_proxy=\"${HTTPS_PROXY:-${https_proxy:-${yaml_http_proxy}}}\"",
|
||||
" yaml_all_proxy=\"${ALL_PROXY:-${all_proxy:-${yaml_http_proxy}}}\"",
|
||||
" if [ -n \"$yaml_http_proxy\" ]; then export HTTP_PROXY=\"$yaml_http_proxy\" http_proxy=\"$yaml_http_proxy\" npm_config_proxy=\"$yaml_http_proxy\"; fi",
|
||||
" if [ -n \"$yaml_https_proxy\" ]; then export HTTPS_PROXY=\"$yaml_https_proxy\" https_proxy=\"$yaml_https_proxy\" npm_config_https_proxy=\"$yaml_https_proxy\"; fi",
|
||||
" if [ -n \"$yaml_all_proxy\" ]; then export ALL_PROXY=\"$yaml_all_proxy\" all_proxy=\"$yaml_all_proxy\"; fi",
|
||||
" export npm_config_registry=\"$yaml_registry\"",
|
||||
" export npm_config_fetch_retries=\"$yaml_fetch_retries\"",
|
||||
" export npm_config_fetch_retry_mintimeout=2000",
|
||||
" export npm_config_fetch_retry_maxtimeout=16000",
|
||||
" export npm_config_fetch_timeout=$((yaml_fetch_timeout * 1000))",
|
||||
"}",
|
||||
"yaml_run_dependency_manager() {",
|
||||
" yaml_manager=\"$1\"; shift",
|
||||
" yaml_attempt=1",
|
||||
" yaml_delay=2",
|
||||
" while [ \"$yaml_attempt\" -le \"$yaml_max_attempts\" ]; do",
|
||||
" echo '{\"event\":\"yaml-dependency\",\"context\":\"'\"$yaml_dependency_context\"'\",\"status\":\"attempt\",\"manager\":\"'\"$yaml_manager\"'\",\"attempt\":\"'\"$yaml_attempt/$yaml_max_attempts\"'\",\"proxy\":\"'\"${yaml_https_proxy:-$yaml_http_proxy}\"'\"}' >&2",
|
||||
" if timeout \"$yaml_fetch_timeout\" \"$@\"; then return 0; fi",
|
||||
" if [ \"$yaml_attempt\" -ge \"$yaml_max_attempts\" ]; then return 1; fi",
|
||||
" echo '{\"event\":\"yaml-dependency\",\"context\":\"'\"$yaml_dependency_context\"'\",\"status\":\"retrying\",\"manager\":\"'\"$yaml_manager\"'\",\"attempt\":\"'\"$yaml_attempt/$yaml_max_attempts\"'\",\"sleepSeconds\":'\"$yaml_delay\"'}' >&2",
|
||||
" sleep \"$yaml_delay\"",
|
||||
" yaml_delay=$((yaml_delay * 2))",
|
||||
" yaml_attempt=$((yaml_attempt + 1))",
|
||||
" done",
|
||||
" return 1",
|
||||
"}",
|
||||
"yaml_npm_debug_log_tail() {",
|
||||
" yaml_npm_log_dir=\"${HOME:-/tmp}/.npm/_logs\"",
|
||||
" if [ ! -d \"$yaml_npm_log_dir\" ]; then return 0; fi",
|
||||
@@ -4714,22 +4744,11 @@ function yamlDependencyInstallScript(registry: string, fetchTimeoutSeconds: numb
|
||||
" fi",
|
||||
"}",
|
||||
"if ! node -e 'require.resolve(\"yaml\")' >/dev/null 2>&1; then",
|
||||
" mkdir -p node_modules/yaml",
|
||||
" yaml_tarball=\"${yaml_registry%/}/yaml/-/yaml-2.8.3.tgz\"",
|
||||
" yaml_tgz=\"$(mktemp)\"",
|
||||
" if command -v curl >/dev/null 2>&1 && command -v tar >/dev/null 2>&1; then",
|
||||
" if timeout \"$yaml_fetch_timeout\" curl -fsSL --retry \"$yaml_fetch_retries\" --connect-timeout 10 -o \"$yaml_tgz\" \"$yaml_tarball\"; then",
|
||||
" tar -xzf \"$yaml_tgz\" -C node_modules/yaml --strip-components=1",
|
||||
" yaml_dependency_log installed tarball",
|
||||
" else",
|
||||
" yaml_dependency_log tarball-failed tarball",
|
||||
" fi",
|
||||
" fi",
|
||||
" rm -f \"$yaml_tgz\"",
|
||||
" yaml_prepare_node_package_proxy",
|
||||
"fi",
|
||||
"if ! node -e 'require.resolve(\"yaml\")' >/dev/null 2>&1 && command -v bun >/dev/null 2>&1; then",
|
||||
" rm -rf node_modules/yaml",
|
||||
" if timeout \"$yaml_fetch_timeout\" bun add --no-save --ignore-scripts --registry \"$yaml_registry\" yaml@2.8.3; then",
|
||||
" if yaml_run_dependency_manager bun bun add --no-save --ignore-scripts --registry \"$yaml_registry\" yaml@2.8.3; then",
|
||||
" yaml_dependency_log installed bun",
|
||||
" else",
|
||||
" yaml_dependency_log bun-failed bun",
|
||||
@@ -4738,7 +4757,7 @@ function yamlDependencyInstallScript(registry: string, fetchTimeoutSeconds: numb
|
||||
"if ! node -e 'require.resolve(\"yaml\")' >/dev/null 2>&1; then",
|
||||
" rm -rf node_modules/yaml",
|
||||
" command -v npm >/dev/null 2>&1 || { yaml_dependency_log failed missing-tool; exit 31; }",
|
||||
" if npm install --package-lock=false --no-save --ignore-scripts --no-audit --no-fund --omit=dev --registry \"$yaml_registry\" yaml@2.8.3; then",
|
||||
" if yaml_run_dependency_manager npm npm install --package-lock=false --no-save --ignore-scripts --no-audit --no-fund --omit=dev --registry \"$yaml_registry\" yaml@2.8.3; then",
|
||||
" yaml_dependency_log installed npm",
|
||||
" else",
|
||||
" yaml_dependency_log npm-failed npm",
|
||||
|
||||
Reference in New Issue
Block a user