Retry transient dependency downloads during source qualification
Device Core qualification / qualify (push) Successful in 6m3s

This commit is contained in:
DCCONSTRUCTIONS
2026-09-30 08:26:20 +03:00
parent 893cb6490c
commit 70065fb74c
3 changed files with 83 additions and 2 deletions
+28 -2
View File
@@ -9,6 +9,7 @@ from pathlib import Path
import re
import subprocess
import sys
import time
SHA = re.compile(r"[0-9a-f]{40}")
@@ -19,15 +20,37 @@ DEPENDENCIES = {
}
def run(args, cwd, capture=False):
def run(args, cwd, capture=False, capture_errors=False):
return subprocess.run(
args, cwd=cwd, check=True, text=True,
stdout=subprocess.PIPE if capture else None,
stderr=subprocess.STDOUT if capture_errors else None,
env={**os.environ, "GIT_TERMINAL_PROMPT": "0", "CI": "true",
"NODEDC_LAUNCHER_REPO": str(Path(__file__).resolve().parents[3] / "NODEDC_LAUNCHER")},
).stdout
def install_dependencies(cwd):
"""Retry only explicit transport failures in a disposable npm ci checkout."""
command = ["npm", "ci", "--ignore-scripts", "--no-audit", "--no-fund"]
transient = {"ECONNRESET", "ETIMEDOUT", "EAI_AGAIN"}
for attempt in range(1, 4):
try:
output = run(command, cwd, capture=True, capture_errors=True)
except subprocess.CalledProcessError as error:
output = error.output or ""
print(output, end="", flush=True)
codes = set(re.findall(r"^npm (?:error|ERR!) code ([A-Z][A-Z0-9_]*)\s*$",
output, re.MULTILINE))
if attempt == 3 or not codes or not codes.issubset(transient):
raise
print("ci_dependency_retry=" + str(attempt) + ";codes=" + ",".join(sorted(codes)), flush=True)
time.sleep(5 * attempt)
else:
print(output or "", end="", flush=True)
return
def read_lock(root):
lock = json.loads((root / "infra/ci/sources.lock.json").read_text())
if lock.get("schema") != "nodedc.device-core.ci-sources.v1":
@@ -126,7 +149,10 @@ def qualify(root, commit, lock, report):
completed = []
for name, cwd, command in steps:
print("ci_step=" + name, flush=True)
run(command, cwd)
if name in ("design-install", "device-install"):
install_dependencies(cwd)
else:
run(command, cwd)
completed.append(name)
verify_sources(root, commit, lock)
result = {