The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(release): link incomplete build rows to their workflow run
ethernet627196d74674
diff --git a/.github/workflows/desktop-bundled-release.yml b/.github/workflows/desktop-bundled-release.ymlindex 3242870be42..7be775c28d4 100644--- a/.github/workflows/desktop-bundled-release.yml+++ b/.github/workflows/desktop-bundled-release.yml@@ -1625,6 +1625,7 @@ jobs:GH_TOKEN: ${{ github.token }}HERMES_PAYLOAD_TAG: ${{ inputs.tag }}RELEASE_NEEDS: ${{ toJSON(needs) }}+ RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}CLOUDFLARE_R2_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_R2_ACCOUNT_ID }}CLOUDFLARE_R2_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }}CLOUDFLARE_R2_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }}@@ -1632,7 +1633,7 @@ jobs:CLOUDFLARE_R2_PUBLIC_URL: ${{ vars.CLOUDFLARE_R2_PUBLIC_URL }}run: |python3 scripts/render-builds-table.py \- --tag "$HERMES_PAYLOAD_TAG" --repo "$GITHUB_REPOSITORY"+ --tag "$HERMES_PAYLOAD_TAG" --repo "$GITHUB_REPOSITORY" --run-url "$RUN_URL"# publish-canary consumes this job's result. Publish diagnostics first,# then retain the original all-needs-success release gate.@@ -1671,6 +1672,7 @@ jobs:CLOUDFLARE_R2_PUBLIC_URL: ${{ vars.CLOUDFLARE_R2_PUBLIC_URL }}RELEASE_COMMIT: ${{ needs.validate.outputs.sha }}RELEASE_NEEDS: ${{ toJSON(needs) }}+ RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}# Render failed admitted builds too. Only receipt-listed objects# receive download links. Rendering does not alter job results.run: |@@ -1686,7 +1688,7 @@ jobs:python3 scripts/render-builds-table.py \--summary-commit "$RELEASE_COMMIT" \--summary-out "$GITHUB_STEP_SUMMARY" \- --summary-failed-legs "$failed"+ --summary-failed-legs "$failed" --run-url "$RUN_URL"candidate-manifest:name: Stage verified stable candidate artifactsdiff --git a/scripts/render-builds-table.py b/scripts/render-builds-table.pyindex 6f30d135103..ce28bc1c63f 100644--- a/scripts/render-builds-table.py+++ b/scripts/render-builds-table.py@@ -117,7 +117,8 @@ def table_rows(assets_by_app: dict) -> list[tuple[str, list[tuple[str, str, str,def render_tables(assets_by_app: dict, base_url: str,- incomplete_jobs: list[str] | None = None) -> str:+ incomplete_jobs: list[str] | None = None,+ run_url: str | None = None) -> str:"""The replacement block: marker + tables + end marker."""sections = []for title, rows in table_rows(assets_by_app):@@ -133,6 +134,10 @@ def render_tables(assets_by_app: dict, base_url: str,if incomplete_jobs:sections.insert(0, "> **Build incomplete.** Jobs not successful: "+ ", ".join(incomplete_jobs) + ". The channel page was not advanced.")+ if run_url:+ sections.append("### Build diagnostics\n\n| Job | Diagnostics |\n|---|---|\n"+ + "\n".join(f"| {job} | [View build run]({run_url}) |"+ for job in incomplete_jobs))return MARKER + "\n## Downloads\n\n" + "\n\n".join(sections) + "\n" + END_MARKER@@ -232,45 +237,51 @@ def _validated_commit_inputs(commit: str, receipts: dict[str, dict | None]) -> Ndef commit_entries(commit: str, names: list[str], base_url: str,receipts: dict[str, dict | None],failed_legs: list[str] | None = None,+ run_url: str | None = None,) -> list[tuple[str, str, str | None, str | None]]:- """[(label, status, download URL or None, object basename or None)] — the- ONE row set the step summary and the commit page render. A link exists- only for a receipt-listed object that is really in the bucket."""+ """[(label, status, URL or None, link text or None)] for both summary sinks.++ Downloads require a receipt-listed object in the bucket. Missing artifacts+ link to the actual workflow run, never a guessed download or job URL.+ """failed = set(failed_legs or [])entries: list[tuple[str, str, str | None, str | None]] = []for row in commit_expected_rows(names, receipts):label, leg, key, state = row["label"], row["leg"], row["key"], row["state"]if state == "built":entries.append((label, "✅ Built", r2.public_url_for(base_url, key), key.rsplit("/", 1)[-1]))+ continueelif state == "receipt-missing":related = failed.intersection({leg, _COMMIT_JOBS[leg]})blame = f"failed: {', '.join(sorted(related))}" if related \else "leg incomplete or upload interrupted"- entries.append((label, f"❌ Not built ({blame})", None, None))+ status = f"❌ Not built ({blame})"elif state == "object-missing":- entries.append((label, "❌ Not built (receipt present but object missing)", None, None))+ status = "❌ Not built (receipt present but object missing)"elif state == "receipt-omits":- entries.append((label, "❌ Not built (artifact absent from receipt)", None, None))+ status = "❌ Not built (artifact absent from receipt)"else:- entries.append((label, "❌ Not built (ambiguous: multiple objects match)", None, None))+ status = "❌ Not built (ambiguous: multiple objects match)"+ entries.append((label, status, run_url, "View build run" if run_url else None))for label in _COMMIT_DISABLED:- entries.append((label, "❌ Not built (release leg disabled)", None, None))+ entries.append((label, "Disabled (release leg disabled)", None, None))return entriesdef render_commit_summary(names: list[str], base_url: str, commit: str,receipts: dict[str, dict | None],- failed_legs: list[str] | None = None) -> str:+ failed_legs: list[str] | None = None,+ run_url: str | None = None) -> str:"""Render every expected product without reading or changing a release."""_validated_commit_inputs(commit, receipts)lines = [f"## Commit build `{commit[:12]}`","",- "| Binary | Status | Download |",+ "| Binary | Status | Download / diagnostics |","|---|---|---|",]- for label, status, url, basename in commit_entries(commit, names, base_url, receipts, failed_legs):- cell = f"[{basename}]({url})" if url and basename else "—"+ for label, status, url, link_text in commit_entries(commit, names, base_url, receipts, failed_legs, run_url):+ cell = f"[{link_text}]({url})" if url and link_text else "—"lines.append(f"| {label} | {status} | {cell} |")return "\n".join([*lines, ""])@@ -359,7 +370,8 @@ def _link(url: str) -> str:def render_page(tag: str, assets_by_app: dict, base_url: str,- incomplete_jobs: list[str] | None = None) -> str:+ incomplete_jobs: list[str] | None = None,+ run_url: str | None = None) -> str:"""The tag/channel page: the release-body download table as HTML."""channel = r2.channel_for_tag(tag)body = [@@ -382,23 +394,30 @@ def render_page(tag: str, assets_by_app: dict, base_url: str,f"{_link(r2.public_url_for(base_url, name))}{html.escape(kind)}</a>"]for os_name, arch, kind, name in rows],))+ if incomplete_jobs and run_url:+ body.append("<h2>Build diagnostics</h2>")+ body.extend(_table(+ ("Job", "Diagnostics"),+ [[html.escape(job), f"{_link(run_url)}View build run</a>"] for job in incomplete_jobs],+ ))return _page(f"Hermes Desktop {channel} builds", tag, body)def render_commit_page(commit: str, names: list[str], base_url: str,receipts: dict[str, dict | None],- failed_legs: list[str] | None = None) -> str:+ failed_legs: list[str] | None = None,+ run_url: str | None = None) -> str:"""The commit-build page: every expected binary, built or not."""_validated_commit_inputs(commit, receipts)rows = []- for label, status, url, basename in commit_entries(commit, names, base_url, receipts, failed_legs):- cell = (f"{_link(url)}{html.escape(basename)}</a>" if url and basename else "—")+ for label, status, url, link_text in commit_entries(commit, names, base_url, receipts, failed_legs, run_url):+ cell = (f"{_link(url)}{html.escape(link_text)}</a>" if url and link_text else "—")rows.append([html.escape(label), html.escape(status), cell])body = [f"<h1>Hermes commit build <code>{html.escape(commit[:12])}</code></h1>",f"<p>Commit <code>{html.escape(commit)}</code>. Every expected binary is listed; "- "a row without a link was not built.</p>",- *_table(("Binary", "Status", "Download"), rows),+ "built rows link to downloads; incomplete rows link to the build run when available.</p>",+ *_table(("Binary", "Status", "Download / diagnostics"), rows),]return _page(f"Hermes commit build {commit[:12]}", commit, body)@@ -499,6 +518,8 @@ def main() -> int:help="With --summary-commit: comma-separated failed job names, ""blamed on the Not built rows")parser.add_argument("--repo", default="NousResearch/hermes-agent")+ parser.add_argument("--run-url", default=None,+ help="Actual workflow run URL for incomplete-build diagnostics")parser.add_argument("--r2-base-url", default=os.environ.get("CLOUDFLARE_R2_PUBLIC_URL"),help="Public base URL of the R2 bucket (default: $CLOUDFLARE_R2_PUBLIC_URL)")parser.add_argument("--dry-run", action="store_true",@@ -530,11 +551,11 @@ def main() -> int:receipts = read_commit_receipts(commit)failed_legs = (failed_legs_from_release_needs(os.environ.get("RELEASE_NEEDS"))or [leg.strip() for leg in args.summary_failed_legs.split(",") if leg.strip()])- block = render_commit_summary(names, args.r2_base_url, commit, receipts, failed_legs)+ block = render_commit_summary(names, args.r2_base_url, commit, receipts, failed_legs, args.run_url)with open(args.summary_out, "a", encoding="utf-8") as out:out.write(block)write_page(r2.commit_page_key_for(commit),- render_commit_page(commit, names, args.r2_base_url, receipts, failed_legs),+ render_commit_page(commit, names, args.r2_base_url, receipts, failed_legs, args.run_url),args.r2_base_url)built = sum(1 for row in commit_expected_rows(names, receipts) if row["state"] == "built")print(f"✓ Commit summary appended to {args.summary_out} ({built}/{len(_COMMIT_EXPECTED)} binaries built)")@@ -555,12 +576,12 @@ def main() -> int:names = r2_object_names(args.tag)assets = parse_assets(names)incomplete = incomplete_release_jobs(os.environ.get("RELEASE_NEEDS"))- block = render_tables(assets, args.r2_base_url, incomplete)+ block = render_tables(assets, args.r2_base_url, incomplete, args.run_url)# A failed run still owns its tag page, never the channel pointer- # consumed by source updates. Missing artifacts never become links.+ # consumed by source updates. Missing artifacts never become downloads.if not args.dry_run:write_page(r2.staging_key_for(args.tag, "index.html"),- render_page(args.tag, assets, args.r2_base_url, incomplete), args.r2_base_url)+ render_page(args.tag, assets, args.r2_base_url, incomplete, args.run_url), args.r2_base_url)# Keep the per-tag diagnostic page even when GitHub cannot supply a draft.view = subprocess.run(diff --git a/tests/ci/test_commit_build_staging.py b/tests/ci/test_commit_build_staging.pyindex 0cc1480f9ac..589f4adacb2 100644--- a/tests/ci/test_commit_build_staging.py+++ b/tests/ci/test_commit_build_staging.py@@ -8,6 +8,8 @@ import subprocessimport sysfrom urllib.request import urlopen+import pytest+from tests.ci.test_desktop_release_tag_admission import _BASH, _child_env, _workflowfrom tests.scripts.test_release_r2 import r2_server # noqa: F401@@ -54,6 +56,54 @@ def shell_step(tmp_path, r2_server, job, name, env):env=environment, capture_output=True, text=True, encoding='utf-8', timeout=60)[email protected]("has_download", [True, False])+def test_failed_commit_summary_publishes_downloads_or_run_links(tmp_path, r2_server, has_download):+ sha = 'a' * 40+ run_url = 'https://github.example/o/r/actions/runs/12345'+ base = f'http://127.0.0.1:{r2_server.server_port}/hermes-releases'+ summary = tmp_path / 'summary.md'+ jobs = _workflow()['jobs']+ env = dict(HERMES_BUILD_COMMIT=sha, HERMES_PAYLOAD_TAG='', RELEASE_COMMIT=sha,+ RELEASE_PHASE='', TARGET='win32-x64', RUN_URL=run_url,+ GITHUB_STEP_SUMMARY=str(summary), CLOUDFLARE_R2_PUBLIC_URL=base,+ CLOUDFLARE_R2_ACCOUNT_ID='loopback', CLOUDFLARE_R2_ACCESS_KEY_ID='test-inert',+ CLOUDFLARE_R2_SECRET_ACCESS_KEY='test-inert', CLOUDFLARE_R2_BUCKET='hermes-releases',+ RELEASE_NEEDS=json.dumps({name: {'result': 'success' if name == 'validate' else 'failure'}+ for name in jobs['commit-builds-summary']['needs']}))+ if has_download:+ artifact = tmp_path / 'apps/desktop/release/HermesBundled-0.33.0-win-x64.msix'+ artifact.parent.mkdir(parents=True)+ artifact.write_bytes(b'inert downloadable fixture')+ staged = shell_step(tmp_path, r2_server, 'build-win32', 'Stage Windows packages to R2', env)+ assert staged.returncode == 0, staged.stdout + staged.stderr+ result = shell_step(tmp_path, r2_server, 'commit-builds-summary',+ 'Render the full expected-binary matrix', env)+ assert result.returncode == 0, result.stdout + result.stderr+ text = summary.read_text(encoding='utf-8')+ page_key = f'releases/commit/{sha}/index.html'+ with urlopen(f'{base}/{page_key}', timeout=5) as response:+ page = response.read().decode()+ links = re.findall(r'\]\((https?://[^)]+)\)', text)+ assert run_url in links+ assert text.count('✅ Built') == page.count('✅ Built') == int(has_download)+ for url in links:+ assert f'href="{url}"' in page+ if url != run_url:+ assert url.startswith(base + '/')+ with urlopen(url, timeout=5) as response:+ assert response.read() == b'inert downloadable fixture'+ for line in text.splitlines():+ if 'Not built' in line:+ assert f'[View build run]({run_url})' in line and base not in line+ elif 'Linux' in line:+ assert 'Disabled' in line and '](' not in line+ assert all(key.startswith(f'releases/commit/{sha}/') for key in r2_server.store)+ for name in ('build-win32', 'build-darwin'):+ assert jobs[name]['strategy']['fail-fast'] is False+ step = next(step for step in jobs['commit-builds-summary']['steps'] if 'run' in step)+ assert step['env']['RUN_URL'] == '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'++def test_commit_staging_and_summary_bind_every_produced_file_without_channels(tmp_path, r2_server):sha = 'a' * 40base = f'http://127.0.0.1:{r2_server.server_port}/hermes-releases'diff --git a/tests/ci/test_tag_builds_summary.py b/tests/ci/test_tag_builds_summary.pyindex abc1abdb9b4..0521b17f05c 100644--- a/tests/ci/test_tag_builds_summary.py+++ b/tests/ci/test_tag_builds_summary.py@@ -24,6 +24,7 @@ def test_admitted_failure_publishes_tag_info_without_promoting_channel(tmp_path,assert render["env"]["RELEASE_NEEDS"] == "${{ toJSON(needs) }}"tag = "v0.28.0-canary.20260818101010"+ run_url = "https://github.example/o/r/actions/runs/12345"base = f"http://127.0.0.1:{r2_server.server_port}/hermes-releases"channel_key = "releases/canary/index.html"previous = b'<meta name="hermes-build" content="v0.27.0-canary.20260817101010">'@@ -50,9 +51,12 @@ def test_admitted_failure_publishes_tag_info_without_promoting_channel(tmp_path,gh.chmod(0o755)needs = {name: {"result": "success"} for name in job["needs"]}needs["build-win32"]["result"] = "failure"+ needs["build-darwin"]["result"] = "failure"+ needs["termux-deb"]["result"] = "failure"needs["publish-win32-updater"]["result"] = "skipped"result = shell_step(tmp_path, r2_server, "builds-table", "Render", {"HERMES_PAYLOAD_TAG": tag, "GITHUB_REPOSITORY": "o/r",+ "RUN_URL": run_url,"RELEASE_NEEDS": json.dumps(needs), "CLOUDFLARE_R2_PUBLIC_URL": base,"CLOUDFLARE_R2_ACCOUNT_ID": "loopback", "CLOUDFLARE_R2_ACCESS_KEY_ID": "test-inert","CLOUDFLARE_R2_SECRET_ACCESS_KEY": "test-inert", "CLOUDFLARE_R2_BUCKET": "hermes-releases",@@ -63,7 +67,12 @@ def test_admitted_failure_publishes_tag_info_without_promoting_channel(tmp_path,page = r2_server.store[key][0].decode()assert "Build incomplete" in pageassert "build-win32 (failure)" in page and "publish-win32-updater (skipped)" in page- assert "No downloadable artifacts" in page and 'href="' not in page+ assert "No downloadable artifacts" in page+ for name, info in needs.items():+ if info["result"] != "success":+ assert f'<td>{name} ({info["result"]})</td><td><a href="{run_url}">View build run</a>' in page+ assert base not in page+ assert render["env"]["RUN_URL"] == "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"assert f"{base}/{key}" in result.stdoutassert r2_server.store[channel_key][0] == previousassert set(r2_server.store) == {channel_key, key}diff --git a/tests/scripts/test_release_handoff_commit.py b/tests/scripts/test_release_handoff_commit.pyindex 04e748ca245..482c5764262 100644--- a/tests/scripts/test_release_handoff_commit.py+++ b/tests/scripts/test_release_handoff_commit.py@@ -301,7 +301,7 @@ def test_real_cli_stage_and_summary_run_as_subprocesses(tmp_path):assert render.returncode == 0, render.stdout + render.stderrtext = summary.read_text(encoding="utf-8")# The staged leg is receipt+object bound -> exactly one ✅ row with- # a link; every other leg renders an explicit ❌.+ # a link; other enabled legs are Not built, and Linux is Disabled.built = [line for line in text.splitlines() if "✅ Built" in line]assert len(built) == 1, textassert "HermesBundled-0.28.0-win-x64.msix" in built[0]@@ -309,7 +309,8 @@ def test_real_cli_stage_and_summary_run_as_subprocesses(tmp_path):assert f"/releases/commit/{COMMIT}/" in urlwith urlopen(url, timeout=5) as response:assert response.read() == b"cli-bytes"- assert "Windows universal Store bundle (MSIXBUNDLE)" in text+ assert "Windows universal bundle (MSIXBUNDLE)" in text+ assert "Store" not in textassert "Linux x64" in text and "Linux ARM64" in textassert all(key.startswith(f"releases/commit/{COMMIT}/") for key in server.store)diff --git a/tests/scripts/test_render_builds_table.py b/tests/scripts/test_render_builds_table.pyindex dcc2c33fd98..4798817ce1c 100644--- a/tests/scripts/test_render_builds_table.py+++ b/tests/scripts/test_render_builds_table.py@@ -176,6 +176,26 @@ class TestBucketPage:assert BASE_URL + "/releases/tag/v0.28.0/HermesBundled-0.28.0-linux-x64.AppImage" in pageassert "linux-arm64" not in page+ @pytest.mark.parametrize("has_download", [True, False])+ def test_failed_tag_rows_link_diagnostics_not_downloads(self, has_download):+ run_url = "https://github.example/o/r/actions/runs/12345"+ names = [ASSETS[2]] if has_download else []+ assets = rbt.parse_assets(names)+ failed = ["build-win32 (failure)", "build-darwin (failure)", "termux-deb (failure)"]+ block = rbt.render_tables(assets, BASE_URL, failed, run_url=run_url)+ page = rbt.render_page("v0.28.0", assets, BASE_URL, failed, run_url=run_url)+ for job in failed:+ md = next(line for line in block.splitlines() if line.startswith(f"| {job} |"))+ html_row = next(row for row in re.findall(r"<tr><td>(.*?)</tr>", page) if job in row)+ assert f"[View build run]({run_url})" in md+ assert f'<a href="{run_url}">View build run</a>' in html_row+ assert BASE_URL not in md and BASE_URL not in html_row+ downloads = [url for url in re.findall(r"href=\"([^\"]+)\"", page) if url.startswith(BASE_URL)]+ assert downloads == [f"{BASE_URL}/{name}" for name in names]+ assert ("No downloadable artifacts" in page) is (not has_download)+ for url in downloads:+ assert f"]({url})" in block+def test_page_names_the_build_it_describes(self):page = rbt.render_page("v0.28.0", rbt.parse_assets(ASSETS), BASE_URL)assert rbt.recorded_build(page) == "v0.28.0"diff --git a/tests/scripts/test_render_builds_table_commit.py b/tests/scripts/test_render_builds_table_commit.pyindex dc8bc2d3f5a..b601b4f329c 100644--- a/tests/scripts/test_render_builds_table_commit.py+++ b/tests/scripts/test_render_builds_table_commit.py@@ -221,6 +221,36 @@ def test_summary_uses_exact_nested_keys_and_lists_the_sideload_bundle():assert "Linux x64" in summary and "Linux ARM64" in summary[email protected]("has_download", [True, False])+def test_incomplete_commit_rows_link_run_not_missing_downloads(has_download):+ run_url = "https://github.example/o/r/actions/runs/12345"+ receipts = _receipts_all_built() if has_download else {}+ names = _names("HermesBundled-0.28.0-win-x64.msix") if has_download else []+ # The uploaded x64 binary stays downloadable even when that job fails+ # after staging, or a sibling fails before staging its own artifact.+ failed = ["build-win32", "build-darwin", "publish-win32-updater", "termux-deb"]+ summary = rbt.render_commit_summary(names, BASE, COMMIT, receipts, failed, run_url=run_url)+ page = rbt.render_commit_page(COMMIT, names, BASE, receipts, failed, run_url=run_url)+ markdown_rows = [line for line in summary.splitlines() if line.startswith("| ")][1:]+ html_rows = re.findall(r"<tr><td>(.*?)</tr>", page)+ assert len(markdown_rows) == len(html_rows) == len(rbt._COMMIT_EXPECTED) + len(rbt._COMMIT_DISABLED)+ for md, html_row in zip(markdown_rows, html_rows):+ if "Linux" in md:+ assert "Disabled" in md and "Disabled" in html_row+ assert "](" not in md and "href=" not in html_row+ elif has_download and "Windows x64" in md:+ url = f"{BASE}/{names[0]}"+ assert "✅ Built" in md and "✅ Built" in html_row+ assert f"]({url})" in md and f'href="{url}"' in html_row+ assert run_url not in md and run_url not in html_row+ else:+ assert "❌ Not built" in md and "❌ Not built" in html_row+ assert f"[View build run]({run_url})" in md+ assert f'<a href="{run_url}">View build run</a>' in html_row+ assert BASE not in md and BASE not in html_row+ assert summary.count("✅ Built") == page.count("✅ Built") == int(has_download)++def test_commit_page_matches_the_summary_rows():"""Two sinks, ONE row set: every link and every status in the stepsummary appears on the page, and neither sink drops a missing binary."""@@ -233,7 +263,8 @@ def test_commit_page_matches_the_summary_rows():for url in links:assert f'href="{url}"' in pageassert page.count("✅ Built") == summary.count("✅ Built") == len(rbt._COMMIT_EXPECTED)- assert page.count("❌ Not built") == summary.count("❌ Not built") == len(rbt._COMMIT_DISABLED)+ assert page.count("Disabled") == summary.count("Disabled") == len(rbt._COMMIT_DISABLED)+ assert "❌ Not built" not in page and "❌ Not built" not in summaryassert rbt.recorded_build(page) == COMMIT