@kungfu-tech/buildchain 2.5.5-alpha.3 → 2.5.5-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kungfu-tech/buildchain",
3
- "version": "2.5.5-alpha.3",
3
+ "version": "2.5.5-alpha.4",
4
4
  "private": false,
5
5
  "description": "Buildchain Release Passport, release governance, CLI toolkit, and site facts.",
6
6
  "repository": "https://github.com/kungfu-systems/buildchain",
@@ -91,7 +91,7 @@ export function selectMergedChannelPullRequest({ pullRequests = [], targetRef, r
91
91
  return candidates[0];
92
92
  }
93
93
 
94
- export function selectReleaseCandidateRun({ runs = [], pullRequest, workflowName = "" }) {
94
+ export function selectReleaseCandidateRuns({ runs = [], pullRequest, workflowName = "" }) {
95
95
  const prNumber = Number(pullRequest?.number || 0);
96
96
  const prHeadSha = String(pullRequest?.head?.sha || pullRequest?.headRefOid || "").trim();
97
97
  const prHeadBranch = normalizeBranch(pullRequest?.head?.ref || pullRequest?.headRefName || "");
@@ -111,7 +111,11 @@ export function selectReleaseCandidateRun({ runs = [], pullRequest, workflowName
111
111
  return matchesPr && matchesWorkflow && run.event === "pull_request" && run.status === "completed" && run.conclusion === "success";
112
112
  });
113
113
  candidates.sort((left, right) => Date.parse(right.updated_at || right.created_at || "") - Date.parse(left.updated_at || left.created_at || ""));
114
- return candidates[0];
114
+ return candidates;
115
+ }
116
+
117
+ export function selectReleaseCandidateRun({ runs = [], pullRequest, workflowName = "" }) {
118
+ return selectReleaseCandidateRuns({ runs, pullRequest, workflowName })[0];
115
119
  }
116
120
 
117
121
  function outputPath(filePath) {
@@ -375,24 +379,40 @@ export async function resolveReleaseCandidateArtifacts({
375
379
  fetchImpl,
376
380
  path: `/repos/${repoInfo.owner}/${repoInfo.repo}/actions/workflows/${encodeURIComponent(workflowFile)}/runs?event=pull_request&status=success&per_page=100`,
377
381
  });
378
- const run = selectReleaseCandidateRun({
382
+ const candidateRuns = selectReleaseCandidateRuns({
379
383
  runs: Array.isArray(runs.workflow_runs) ? runs.workflow_runs : [],
380
384
  pullRequest,
381
385
  workflowName,
382
386
  });
383
- if (!run) {
387
+ if (!candidateRuns.length) {
384
388
  throw new Error(`no successful ${workflowName} pull_request run found for channel PR #${pullRequest.number}`);
385
389
  }
386
- const artifactResponse = await githubJson({
387
- apiUrl,
388
- token,
389
- fetchImpl,
390
- path: `/repos/${repoInfo.owner}/${repoInfo.repo}/actions/runs/${run.id}/artifacts?per_page=100`,
391
- });
392
- const selected = selectReleaseCandidateArtifacts({
393
- artifacts: Array.isArray(artifactResponse.artifacts) ? artifactResponse.artifacts : [],
394
- artifactName,
395
- });
390
+ let run;
391
+ let artifactResponse;
392
+ let selected;
393
+ const selectionErrors = [];
394
+ for (const candidateRun of candidateRuns) {
395
+ const candidateArtifactResponse = await githubJson({
396
+ apiUrl,
397
+ token,
398
+ fetchImpl,
399
+ path: `/repos/${repoInfo.owner}/${repoInfo.repo}/actions/runs/${candidateRun.id}/artifacts?per_page=100`,
400
+ });
401
+ try {
402
+ selected = selectReleaseCandidateArtifacts({
403
+ artifacts: Array.isArray(candidateArtifactResponse.artifacts) ? candidateArtifactResponse.artifacts : [],
404
+ artifactName,
405
+ });
406
+ run = candidateRun;
407
+ artifactResponse = candidateArtifactResponse;
408
+ break;
409
+ } catch (error) {
410
+ selectionErrors.push(`run ${candidateRun.id}: ${error.message}`);
411
+ }
412
+ }
413
+ if (!run || !artifactResponse || !selected) {
414
+ throw new Error(`no successful ${workflowName} pull_request run for channel PR #${pullRequest.number} contained release-candidate artifacts: ${selectionErrors.join("; ")}`);
415
+ }
396
416
  const payloadArtifacts = selectPayloadArtifacts({
397
417
  artifacts: Array.isArray(artifactResponse.artifacts) ? artifactResponse.artifacts : [],
398
418
  artifactName: selected.prefix,