Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/community-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,11 @@ jobs:
fi
deadline=$((SECONDS + 18000))
while [ "$SECONDS" -lt "$deadline" ]; do
run="$(gh api "/repos/$GITHUB_REPOSITORY/actions/runs/$PIPELINE_RUN_ID")"
if ! run="$(gh api "/repos/$GITHUB_REPOSITORY/actions/runs/$PIPELINE_RUN_ID")"; then
echo "::warning::Community CI observation is unavailable; the existing run is still authoritative."
sleep 30
continue
fi
if [ "$(jq -r '.status' <<< "$run")" = completed ]; then
# GitHub may return a placeholder title while a newly dispatched
# run is initializing. Verify identity before publishing its result.
Expand Down Expand Up @@ -589,9 +593,9 @@ jobs:
name: Community CPU / Unit / C++ and Python
needs: authorize
runs-on: ubuntu-24.04
timeout-minutes: 65
timeout-minutes: 120
env:
CPP_BUILD_TIMEOUT: 45m
CPP_BUILD_TIMEOUT: 60m
permissions:
contents: read
steps:
Expand Down
4 changes: 3 additions & 1 deletion tools/e2e_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ def classification_index(logits: Any) -> tuple[int, int | float] | None:


def _escape(value: Any) -> str:
return html.escape(str(value), quote=True)
# Keep malformed Unicode in recorded text from breaking the HTML document.
text = str(value).encode("utf-8", errors="backslashreplace").decode("utf-8")
return html.escape(text, quote=True)


def _json(value: Any) -> str:
Expand Down
66 changes: 66 additions & 0 deletions tools/tests/test_community_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,72 @@ def test_only_complete_pipeline_publishes_stable_and_dev_results(
assert int((tmp_path / "counter").read_text()) == (2 if queued_first else 1)


def test_publisher_keeps_waiting_through_a_failed_run_lookup(tmp_path):
"""A transient API error while observing the run must not publish a failure."""
fake = tmp_path / "gh"
fake.write_text(
"#!/usr/bin/env python3\nimport json,os,sys\nfrom pathlib import Path\n"
"if any(a.startswith('/repos/') and '/actions/runs/' in a for a in sys.argv):\n"
" counter=Path(os.environ['COUNTER'])\n"
" count=int(counter.read_text())+1 if counter.exists() else 1\n"
" counter.write_text(str(count))\n"
" if count==1:\n"
" print('gh: Server Error (HTTP 502)', file=sys.stderr); sys.exit(1)\n"
" print(os.environ['RUN'])\n"
"else: Path(os.environ['CALLS']).write_text('\\n'.join(sys.argv[1:]))\n"
)
fake.chmod(0o755)
sleep = tmp_path / "sleep"
sleep.write_text("#!/bin/sh\nexit 0\n")
sleep.chmod(0o755)
head, merge = "a" * 40, "b" * 40
result = subprocess.run(
[
"bash",
"-c",
_workflow_step_script(
"community-ci.yml", "dispatch", "Publish the complete workflow conclusion"
),
],
env={
**os.environ,
"PATH": f"{tmp_path}:{os.environ['PATH']}",
"PIPELINE_RUN_ID": "42",
"CI_BRANCH": "main",
"LANE": "stable",
"PR_NUMBER": "17",
"HEAD_SHA": head,
"STATUS_CONTEXT": "Stable Community CI",
"SOURCE_SNAPSHOT": json.dumps({"merge_sha": merge}),
"GITHUB_SERVER_URL": "https://github.com",
"GITHUB_REPOSITORY": "example/source",
"GITHUB_OUTPUT": str(tmp_path / "output"),
"CALLS": str(tmp_path / "calls"),
"COUNTER": str(tmp_path / "counter"),
"RUN": json.dumps(
{
"path": ".github/workflows/community-ci.yml",
"event": "workflow_dispatch",
"head_branch": "main",
"display_title": f"Stable Community CI · PR #17 · head {head} · merge {merge}",
"status": "completed",
"conclusion": "success",
}
),
},
capture_output=True,
text=True,
)

assert result.returncode == 0, result.stderr
assert "observation is unavailable" in result.stdout
assert int((tmp_path / "counter").read_text()) == 2
calls = (tmp_path / "calls").read_text().splitlines()
assert "state=success" in calls
assert "context=Stable Community CI" in calls
assert (tmp_path / "output").read_text() == "reported=true\n"


@pytest.mark.parametrize("ready_after", [1, 2, 7])
def test_pr_trigger_waits_for_github_merge_generation_with_a_bounded_retry(tmp_path, ready_after):
head, base, merge, tree = (value * 40 for value in "abcd")
Expand Down
25 changes: 25 additions & 0 deletions tools/tests/test_e2e_evidence.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,31 @@ def test_html_escapes_observations_and_never_executes_active_artifacts(tmp_path:
assert "fetch(" not in report


def test_report_writes_lone_surrogates_as_visible_escapes(tmp_path: Path) -> None:
from tools.e2e_report import main as render_main

case = tmp_path / "artifacts" / "example-case"
case.mkdir(parents=True)
text = "caf\u00e9 \u4e2d\u6587 \U0001f600 lone surrogate: \ud800"
evidence = {
"schema_version": 1,
"family": "example",
"case": "example-case",
"status": "passed",
"native": {"text": text},
}
# json.dumps escapes the surrogate; json.loads in the report restores it.
(case / "evidence.json").write_text(json.dumps(evidence), encoding="utf-8")
output = tmp_path / "report.html"

assert render_main([str(tmp_path / "artifacts"), "-o", str(output)]) == 0

report = output.read_text(encoding="utf-8")
assert "caf\u00e9 \u4e2d\u6587 \U0001f600" in report
assert "lone surrogate: \\ud800" in report
assert "\ud800" not in report


def test_json_bound_preserves_failed_check_before_passed_details(
tmp_path: Path, monkeypatch
) -> None:
Expand Down
Loading