From 9980663f83eb09b4e8ead2bbd9f07ca29810fda2 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Sun, 22 Nov 2026 20:27:48 -0500 Subject: [PATCH] CI: retry npm audit on registry errors only The registry's audit endpoint returned a spurious 400 ('Invalid package tree') on an unchanged lockfile; the same commit passed minutes later. Real advisories still fail at once. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/ci.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 1d8a0db..9ae1afb 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -61,7 +61,17 @@ jobs: steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 - name: Audit production and dev dependencies - run: npm audit --audit-level=high + run: | + # Retry only when the registry itself fails (it has returned spurious 400s); + # a real advisory fails at once. + for attempt in 1 2 3; do + if out=$(npm audit --audit-level=high 2>&1); then echo "$out"; exit 0; fi + echo "$out" + echo "$out" | grep -q "audit endpoint returned an error" || exit 1 + echo "npm registry error (attempt $attempt); retrying in 20s" + sleep 20 + done + exit 1 - name: Software bill of materials (production dependencies) run: npm sbom --sbom-format cyclonedx --omit dev --package-lock-only > sbom.cdx.json - name: Keep the SBOM for each main build