Skip to content

Commit 7ba2355

Browse files
authored
Merge pull request #609 from NeptuneHub/devel
Readme update
2 parents 9f05b1d + e8abae6 commit 7ba2355

1 file changed

Lines changed: 18 additions & 25 deletions

File tree

.github/workflows/pr-test-link.yml

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
# body (to avoid two workflows racing on the same description). That coupled the
99
# link list to one build and meant a link could be posted before its artifact
1010
# actually existed. This workflow instead runs *after* a build finishes
11-
# (``workflow_run``) and, before emitting any link, VERIFIES via the API that:
12-
# * the build's workflow run for this PR's head commit concluded ``success``, and
11+
# (``workflow_run``) and emits a line ONLY for a build that has a SUCCESSFUL
12+
# run, after VERIFYING via the API that:
13+
# * the latest run of that build on the PR branch concluded ``success``, and
1314
# * for artifact builds (macOS / Linux), the named artifact actually exists.
14-
# So every link it writes is known-good. It recomputes the whole block from the
15-
# current state of all builds on each trigger, so the block is idempotent: it
16-
# fills in as builds complete and never duplicates or goes stale.
15+
# In-progress and failed builds produce no line. It keys off the latest
16+
# SUCCESSFUL run on the PR branch, so when a new build is triggered the existing
17+
# link stays until the new one succeeds -- a working link is never replaced by a
18+
# placeholder, and users always have something to test.
1719
#
1820
# Note: ``workflow_run`` workflows only fire from the copy of this file on the
1921
# repository's DEFAULT branch -- links start appearing on PRs once this file is
@@ -71,13 +73,16 @@ jobs:
7173
return;
7274
}
7375
74-
// ---- All workflow runs for this head commit ---------------------
76+
// ---- Latest SUCCESSFUL run per build, scoped to the PR branch ----
77+
const headBranch = context.payload.workflow_run.head_branch;
7578
const allRuns = await github.paginate(
7679
github.rest.actions.listWorkflowRunsForRepo,
77-
{ owner, repo, head_sha: headSha, per_page: 100 },
80+
{ owner, repo, branch: headBranch, per_page: 100 },
7881
);
79-
const latestRun = (wfFile) => {
80-
const c = allRuns.filter(r => r.path === `.github/workflows/${wfFile}`);
82+
const latestSuccessfulRun = (wfFile) => {
83+
const c = allRuns.filter(r =>
84+
r.path === `.github/workflows/${wfFile}` &&
85+
r.status === 'completed' && r.conclusion === 'success');
8186
c.sort((a, b) => b.run_number - a.run_number);
8287
return c[0] || null;
8388
};
@@ -96,10 +101,8 @@ jobs:
96101
kind: 'artifact', artifact: 'AudioMuse-AI-aarch64-deb' },
97102
{ label: 'Linux aarch64 (.rpm)', wf: 'build-linux.yml',
98103
kind: 'artifact', artifact: 'AudioMuse-AI-aarch64-rpm' },
99-
{ label: 'Docker image (amd64)', wf: 'build-arm-intel.yml',
100-
kind: 'image', image: `${ghcr}:build-amd64-pr-${pull_number}` },
101-
{ label: 'Docker image (arm64)', wf: 'build-arm-intel.yml',
102-
kind: 'image', image: `${ghcr}:build-arm64-pr-${pull_number}` },
104+
{ label: 'Docker image', wf: 'build-arm-intel.yml',
105+
kind: 'image', image: `${ghcr}:pr-${pull_number}` },
103106
{ label: 'Docker image (nvidia)', wf: 'build-nvidia.yml',
104107
kind: 'image', image: `${ghcr}:pr-${pull_number}-nvidia` },
105108
{ label: 'Docker image (noavx2)', wf: 'build-noavx2.yml',
@@ -108,16 +111,8 @@ jobs:
108111
109112
const lines = [];
110113
for (const b of builds) {
111-
const run = latestRun(b.wf);
112-
if (!run) continue; // build never triggered for this PR
113-
if (run.status !== 'completed') {
114-
lines.push(`- ${b.label}: ⏳ building…`);
115-
continue;
116-
}
117-
if (run.conclusion !== 'success') {
118-
lines.push(`- ${b.label}: ❌ build failed ([log](${run.html_url}))`);
119-
continue;
120-
}
114+
const run = latestSuccessfulRun(b.wf);
115+
if (!run) continue; // no successful build yet — show nothing
121116
if (b.kind === 'artifact') {
122117
// VERIFY the artifact exists before publishing its public link.
123118
const arts = await github.paginate(
@@ -128,8 +123,6 @@ jobs:
128123
if (a) {
129124
const url = `https://nightly.link/${owner}/${repo}/actions/runs/${run.id}/${b.artifact}.zip`;
130125
lines.push(`- ${b.label}: [${b.artifact}.zip](${url})`);
131-
} else {
132-
lines.push(`- ${b.label}: ⚠️ run succeeded but artifact not found`);
133126
}
134127
} else {
135128
// Image builds: a successful run means the tag was pushed.

0 commit comments

Comments
 (0)