From 036064d977bafdbb83e5f42976d31c41f39ef237 Mon Sep 17 00:00:00 2001 From: Tim Stranske Date: Tue, 26 May 2026 02:42:08 -0500 Subject: [PATCH] fix: avoid coverage guard artifact probe loop --- .github/workflows/maint-coverage-guard.yml | 27 +++---------------- .../workflows/maint-coverage-guard.yml | 27 +++---------------- 2 files changed, 8 insertions(+), 46 deletions(-) diff --git a/.github/workflows/maint-coverage-guard.yml b/.github/workflows/maint-coverage-guard.yml index 1f2c66e88..c1d7072f2 100644 --- a/.github/workflows/maint-coverage-guard.yml +++ b/.github/workflows/maint-coverage-guard.yml @@ -126,7 +126,7 @@ jobs: paginateWithRetry: (githubInstance, method, params) => githubInstance.paginate(method, params), }; - const { paginateWithRetry, withRetry } = retryHelpers; + const { paginateWithRetry } = retryHelpers; const runs = await paginateWithRetry( github, github.rest.actions.listWorkflowRuns, @@ -150,30 +150,11 @@ jobs: new Date(b.run_started_at || b.created_at || 0) - new Date(a.run_started_at || a.created_at || 0), ); - let candidate = null; - for (const run of runs) { - const artifacts = await withRetry(() => - github.rest.actions.listWorkflowRunArtifacts({ - owner, - repo, - run_id: run.id, - per_page: 100, - }), - ); - const hasCoverageTrend = artifacts.data.artifacts.some( - (artifact) => - artifact.name === 'gate-coverage-trend' && !artifact.expired, - ); - if (hasCoverageTrend) { - candidate = run; - break; - } - } + const candidate = + runs.find((run) => ['success', 'neutral'].includes(run.conclusion || '')) || runs[0]; if (!candidate) { - core.warning( - 'Unable to locate a completed Gate workflow run with coverage artifacts.', - ); + core.warning('Unable to locate a completed Gate workflow run.'); core.setOutput('run_id', ''); return; } diff --git a/templates/consumer-repo/.github/workflows/maint-coverage-guard.yml b/templates/consumer-repo/.github/workflows/maint-coverage-guard.yml index bf0ddb802..c38b3d2b9 100644 --- a/templates/consumer-repo/.github/workflows/maint-coverage-guard.yml +++ b/templates/consumer-repo/.github/workflows/maint-coverage-guard.yml @@ -136,7 +136,7 @@ jobs: paginateWithRetry: (githubInstance, method, params) => githubInstance.paginate(method, params), }; - const { paginateWithRetry, withRetry } = retryHelpers; + const { paginateWithRetry } = retryHelpers; const runs = await paginateWithRetry( github, github.rest.actions.listWorkflowRuns, @@ -160,30 +160,11 @@ jobs: new Date(b.run_started_at || b.created_at || 0) - new Date(a.run_started_at || a.created_at || 0), ); - let candidate = null; - for (const run of runs) { - const artifacts = await withRetry(() => - github.rest.actions.listWorkflowRunArtifacts({ - owner, - repo, - run_id: run.id, - per_page: 100, - }), - ); - const hasCoverageTrend = artifacts.data.artifacts.some( - (artifact) => - artifact.name === 'gate-coverage-trend' && !artifact.expired, - ); - if (hasCoverageTrend) { - candidate = run; - break; - } - } + const candidate = + runs.find((run) => ['success', 'neutral'].includes(run.conclusion || '')) || runs[0]; if (!candidate) { - core.warning( - 'Unable to locate a completed Gate workflow run with coverage artifacts.', - ); + core.warning('Unable to locate a completed Gate workflow run.'); core.setOutput('run_id', ''); return; }