From 490128a04420d7d5316714186e61c85626d17144 Mon Sep 17 00:00:00 2001 From: "privilegedescalation-engineer[bot]" <269729446+privilegedescalation-engineer[bot]@users.noreply.github.com> Date: Mon, 4 May 2026 12:08:20 +0000 Subject: [PATCH] Add 3-attempt retry to npm/pnpm install step in plugin workflows (#132) PRI-459: Adds 3-attempt retry wrapper (5s backoff) around the Install dependencies step in plugin-ci.yaml and plugin-release.yaml to handle transient npm/pnpm registry failures. Co-authored-by: Chris Farhood --- .github/workflows/plugin-ci.yaml | 24 +++++++++++++++++++----- .github/workflows/plugin-release.yaml | 22 ++++++++++++++++++---- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/.github/workflows/plugin-ci.yaml b/.github/workflows/plugin-ci.yaml index 6f2a151..f01b7b3 100644 --- a/.github/workflows/plugin-ci.yaml +++ b/.github/workflows/plugin-ci.yaml @@ -115,10 +115,24 @@ jobs: - name: Install dependencies run: | - if [ "${{ steps.pkg-manager.outputs.manager }}" = "pnpm" ]; then - pnpm install --frozen-lockfile - else - npm ci + max_attempts=3 + attempt=1 + while [ $attempt -le $max_attempts ]; do + echo "Attempt $attempt of $max_attempts" + if [ "${{ steps.pkg-manager.outputs.manager }}" = "pnpm" ]; then + pnpm install --frozen-lockfile && break + else + npm ci && break + fi + if [ $attempt -lt $max_attempts ]; then + echo "::warning::Install step failed on attempt $attempt. Retrying in 5 seconds..." + sleep 5 + fi + attempt=$((attempt + 1)) + done + if [ $attempt -gt $max_attempts ]; then + echo "::error::Install step failed after $max_attempts attempts." + exit 1 fi - name: Build plugin @@ -162,4 +176,4 @@ jobs: npx audit-ci --pnpm --audit-level=high else npx audit-ci --npm --audit-level=high - fi + fi \ No newline at end of file diff --git a/.github/workflows/plugin-release.yaml b/.github/workflows/plugin-release.yaml index 7ace5c1..5b59ba6 100644 --- a/.github/workflows/plugin-release.yaml +++ b/.github/workflows/plugin-release.yaml @@ -226,10 +226,24 @@ jobs: - name: Install dependencies run: | - if [ "${{ steps.pkg-manager.outputs.manager }}" = "pnpm" ]; then - pnpm install --frozen-lockfile - else - npm ci + max_attempts=3 + attempt=1 + while [ $attempt -le $max_attempts ]; do + echo "Attempt $attempt of $max_attempts" + if [ "${{ steps.pkg-manager.outputs.manager }}" = "pnpm" ]; then + pnpm install --frozen-lockfile && break + else + npm ci && break + fi + if [ $attempt -lt $max_attempts ]; then + echo "::warning::Install step failed on attempt $attempt. Retrying in 5 seconds..." + sleep 5 + fi + attempt=$((attempt + 1)) + done + if [ $attempt -gt $max_attempts ]; then + echo "::error::Install step failed after $max_attempts attempts." + exit 1 fi - name: Build plugin