autobump: report the whole record behind an escalation
A deferred bump said one line and dropped the rest: the engine's output was cut to its last four lines and the issue comment carried 25 lines of escalations.txt, so build.log and the tree/surface diffs never reached anyone. Print the engine output whole, put every evidence file in the comment (cut, never summarised) and upload the evidence directory as a run artifact.
This commit is contained in:
1 parent
26093ca081
commit
fc7ef73e1e
5 files changed
+115
-14
No files matched your search
@@ -226,6 +226,8 @@ jobs:
|
||||
# allow a generous per-op ceiling so a heavy from-source build (net-libs/nodejs ~1h)
|
||||
# finishes instead of timing out and deferring; keep in step with timeout-minutes above.
|
||||
AUTOBUMP_OP_TIMEOUT: '7200'
|
||||
# inside the container: ${{ runner.temp }} is a host path the container lacks
|
||||
AUTOBUMP_EVIDENCE_DIR: /tmp/autobump-evidence
|
||||
SHARD: ${{ toJSON(fromJSON(needs.plan.outputs.plan).shards[matrix.shard]) }}
|
||||
SHARD_ID: ${{ matrix.shard }}
|
||||
LIMIT: ${{ github.event.inputs.limit || 30 }}
|
||||
@@ -245,6 +247,14 @@ jobs:
|
||||
name: autobump-delta-${{ matrix.shard }}
|
||||
path: autobump-delta-${{ matrix.shard }}.json
|
||||
|
||||
- name: upload escalation evidence
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: autobump-evidence-${{ matrix.shard }}
|
||||
path: /tmp/autobump-evidence
|
||||
if-no-files-found: ignore
|
||||
|
||||
collect:
|
||||
needs: [plan, bump]
|
||||
if: ${{ always() && needs.plan.result == 'success' }}
|
||||
|
||||
+69
-12
@@ -59,6 +59,7 @@ class Settings:
|
||||
delta_files: list[Path]
|
||||
ledger_additions: dict[str, list[str]]
|
||||
worker_attempts: dict[tuple[str, str], int]
|
||||
evidence_dir: Path | None
|
||||
|
||||
|
||||
def command_output(command, *, stderr=None):
|
||||
@@ -232,7 +233,11 @@ def run_link(upstream_repo, label="run"):
|
||||
return f" · [{label}]({server}/{repository}/actions/runs/{run_id})"
|
||||
|
||||
|
||||
# Status comments stay short because detailed evidence belongs in the Actions log or collapsed evidence block.
|
||||
# A comment takes 65536 characters; leave the verdict line and footer room around the evidence.
|
||||
EVIDENCE_COMMENT_BUDGET = 55000
|
||||
EVIDENCE_FILE_LINES = 200
|
||||
|
||||
|
||||
def short_status_reason(reason):
|
||||
reason = re.sub(r"[ \t\r\n\v\f]+", " ", reason).strip(SPACE)
|
||||
if len(reason) > 200:
|
||||
@@ -313,8 +318,18 @@ def status_comment(issue, body, *, comment, footer, upstream_repo, status_commen
|
||||
status_comment_failed.add(issue)
|
||||
|
||||
|
||||
def print_tail_lines(text, count):
|
||||
print("\n".join(text.split("\n")[-count:]))
|
||||
def keep_evidence(settings, evidence, package, version):
|
||||
# The engine's evidence dir is a tmpdir inside the worker: without a copy under
|
||||
# AUTOBUMP_EVIDENCE_DIR (uploaded as a run artifact) every log and diff behind an
|
||||
# escalation dies with the container.
|
||||
if not settings.evidence_dir or not evidence.is_dir():
|
||||
return
|
||||
kept = settings.evidence_dir / f"{package.replace('/', '_')}-{version}"
|
||||
shutil.rmtree(kept, ignore_errors=True)
|
||||
try:
|
||||
shutil.copytree(evidence, kept)
|
||||
except OSError as error:
|
||||
print(f"could not keep evidence for {package}: {error}")
|
||||
|
||||
|
||||
# Parsed from the engine's own line, never hard-coded: its mkdtemp follows TMPDIR, which
|
||||
@@ -372,14 +387,53 @@ def last_clear_reason(text):
|
||||
return clear_reasons[-1] if clear_reasons else ""
|
||||
|
||||
|
||||
def evidence_excerpt(evidence):
|
||||
# wget writes one of these per 50K downloaded; a fetch log is mostly them.
|
||||
PROGRESS_LINE = re.compile(r"^[ \t]*[0-9]+K[ .]+[0-9]+%")
|
||||
|
||||
|
||||
def evidence_file_excerpt(path):
|
||||
try:
|
||||
with (evidence / "escalations.txt").open() as f:
|
||||
lines = [line.rstrip("\n").replace("```", "") for line in f]
|
||||
text = path.read_text(errors="replace")
|
||||
except OSError:
|
||||
return "", 0, 0
|
||||
lines = [
|
||||
line.replace("```", "")
|
||||
for line in text.split("\n")
|
||||
if not re.fullmatch(r"[ \t\r\v\f]*", line) and not PROGRESS_LINE.match(line)
|
||||
]
|
||||
if len(lines) <= EVIDENCE_FILE_LINES:
|
||||
return "\n".join(lines), len(lines), len(lines)
|
||||
# a log carries its failure at the end, a listing at the start
|
||||
kept = lines[-EVIDENCE_FILE_LINES:] if path.suffix == ".log" else lines[:EVIDENCE_FILE_LINES]
|
||||
return "\n".join(kept), len(kept), len(lines)
|
||||
|
||||
|
||||
def evidence_excerpt(evidence):
|
||||
# Every file the engine wrote, not a summary of them: the reason line says what tripped,
|
||||
# these say what the tools actually printed. Long files are cut, never paraphrased, and
|
||||
# the run artifact holds them whole.
|
||||
try:
|
||||
paths = sorted(path for path in evidence.iterdir() if path.is_file())
|
||||
except OSError:
|
||||
return ""
|
||||
filtered = [line for line in lines if not re.fullmatch(r"[ \t\r\v\f]*", line)]
|
||||
return "\n".join(filtered[:25])
|
||||
# the reason first, then the diffs and scan results, then the logs: a log is the bulkiest
|
||||
# file and the one the evidence artifact holds anyway, so it must not crowd out the rest
|
||||
paths.sort(key=lambda path: (path.suffix == ".log", path.name != "escalations.txt"))
|
||||
|
||||
sections, budget = [], EVIDENCE_COMMENT_BUDGET
|
||||
for index, path in enumerate(paths):
|
||||
excerpt, kept, total = evidence_file_excerpt(path)
|
||||
if not excerpt:
|
||||
continue
|
||||
title = path.name if kept == total else f"{path.name} ({kept} of {total} lines)"
|
||||
section = f"<details><summary>{title}</summary>\n\n```\n{excerpt}\n```\n</details>"
|
||||
if len(section) > budget:
|
||||
left = len(paths) - index
|
||||
sections.append(f"({left} more files in the run's evidence artifact)")
|
||||
break
|
||||
sections.append(section)
|
||||
budget -= len(section)
|
||||
return "\n\n".join(sections)
|
||||
|
||||
|
||||
def read_settings(argv):
|
||||
@@ -390,6 +444,8 @@ def read_settings(argv):
|
||||
upstream_repo = os.environ.get("AUTOBUMP_UPSTREAM_REPO") or "gentoo-zh/overlay"
|
||||
# An unset judge sends each escalation to a human; configure one only when its semantic judgment merits a call.
|
||||
judge = os.environ.get("AUTOBUMP_JUDGE", "")
|
||||
# where escalation evidence is kept for upload; unset means the run keeps none
|
||||
evidence_dir = os.environ.get("AUTOBUMP_EVIDENCE_DIR")
|
||||
state_home = os.environ.get("XDG_STATE_HOME") or f"{os.environ.get('HOME', '')}/.local/state"
|
||||
state_dir = Path(state_home) / "autobump"
|
||||
done_ledger = state_dir / "done.list"
|
||||
@@ -428,6 +484,7 @@ def read_settings(argv):
|
||||
delta_files=[Path(path) for path in arguments.delta_files],
|
||||
ledger_additions={"done": [], "attempts": []},
|
||||
worker_attempts=worker_attempts,
|
||||
evidence_dir=Path(evidence_dir) if evidence_dir else None,
|
||||
)
|
||||
|
||||
|
||||
@@ -562,7 +619,7 @@ def run_engine(engine, issue, args, pr):
|
||||
# Successful runs need only a tail; failures print all evidence because the CI container disappears after the run.
|
||||
status, engine_output = command_output_with_stderr(engine + [issue, *args] + ([pr] if pr else []))
|
||||
if status == 0:
|
||||
print_tail_lines(engine_output, 4)
|
||||
print(engine_output)
|
||||
else:
|
||||
print(engine_output)
|
||||
return status, engine_output
|
||||
@@ -611,7 +668,7 @@ def retry_accepted_escalation(
|
||||
retry_status, retry_output = command_output_with_stderr(
|
||||
engine + [issue, "--accept-surface", "--accept-payload", *args] + ([settings.pr] if settings.pr else [])
|
||||
)
|
||||
print_tail_lines(retry_output, 3)
|
||||
print(retry_output)
|
||||
if retry_status == 0:
|
||||
record_ledger(settings, "done", package, version, "bumped-after-judge")
|
||||
return "bumped (judge accepted surface delta)"
|
||||
@@ -654,10 +711,9 @@ def record_escalation(settings, issue, package, version, evidence, verdict, engi
|
||||
f"**autobump** can't bump `{package}` → `{version}` mechanically: "
|
||||
f"**{short_status_reason(reason)}**. Needs a manual bump.{run_link(settings.upstream_repo, 'log')}"
|
||||
)
|
||||
# Keep the issue comment scannable while retaining raw evidence one click away.
|
||||
excerpt = evidence_excerpt(evidence)
|
||||
if excerpt:
|
||||
body += f"\n\n<details><summary>evidence</summary>\n\n```\n{excerpt}\n```\n</details>"
|
||||
body += f"\n\n{excerpt}"
|
||||
status_comment(
|
||||
issue,
|
||||
body,
|
||||
@@ -677,6 +733,7 @@ def handle_escalation(
|
||||
if not evidence_path or not evidence.is_dir():
|
||||
return defer_unparseable_evidence(settings, package, version)
|
||||
|
||||
keep_evidence(settings, evidence, package, version)
|
||||
verdict = escalation_verdict(
|
||||
settings, tools, evidence, package, current_version(engine_output), version
|
||||
)
|
||||
|
||||
+2
-1
@@ -18,7 +18,8 @@ Step 2 has three outcomes:
|
||||
|
||||
* **mechanical** — version change only and emerge passed, so it opens a PR.
|
||||
* **escalate** — major version jump, changed dependencies, or a `files/` patch to
|
||||
re-verify. It comments the evidence on the issue and opens no PR.
|
||||
re-verify. It comments the evidence on the issue, uploads the engine's evidence
|
||||
directory as a run artifact, and opens no PR.
|
||||
* **defer** — a transient network, mirror or upstream-file problem, a per-version
|
||||
vendor bundle that is not generated yet, or a heavy dependency with no binpkg on
|
||||
the binhost that would exceed the CI timeout. Retried
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
第 2 步有三种结果:
|
||||
|
||||
* **可机械处理**:只改版本号且 emerge 通过,创建 PR。
|
||||
* **需人工处理**:大版本跳变、依赖有变化,或 `files/` 里的 patch 要重新验证。只在 issue 上记录证据,不创建 PR。
|
||||
* **需人工处理**:大版本跳变、依赖有变化,或 `files/` 里的 patch 要重新验证。只在 issue 上记录证据,完整证据目录作为 run artifact 上传,不创建 PR。
|
||||
* **暂缓**:网络、镜像或上游文件暂时不可用,per-version vendor bundle 还没生成,或者某个过重的依赖在 binhost 上没有 binpkg、从源码编译会超出 CI 限时。下次自动重试,重试若干次仍不行才交给人。
|
||||
|
||||
## 哪些包可以开启
|
||||
|
||||
@@ -108,6 +108,12 @@ class AutobumpSweepTest(unittest.TestCase):
|
||||
self.bin.mkdir()
|
||||
self.evidence.mkdir()
|
||||
(self.evidence / "escalations.txt").write_text("payload layout changed\n")
|
||||
(self.evidence / "tree-added.txt").write_text("usr/lib/libnew.so\n")
|
||||
(self.evidence / "build.log").write_text(
|
||||
" 1000K .......... .......... 71% 80.5M 0s\n"
|
||||
+ "".join(f"build line {index}\n" for index in range(300))
|
||||
)
|
||||
self.kept = Path(self.tempdir.name) / "kept"
|
||||
self.repo.joinpath(".github", "workflows", "overlay.toml").write_text(
|
||||
textwrap.dedent(
|
||||
"""\
|
||||
@@ -156,6 +162,7 @@ class AutobumpSweepTest(unittest.TestCase):
|
||||
"XDG_STATE_HOME": str(self.state_home),
|
||||
"GH_TOKEN": "test-token",
|
||||
"EVIDENCE_DIR": str(self.evidence),
|
||||
"AUTOBUMP_EVIDENCE_DIR": str(self.kept),
|
||||
"ENGINE_LOG": str(self.engine_log),
|
||||
"GH_LOG": str(self.gh_log),
|
||||
"GH_STATE": str(self.gh_state),
|
||||
@@ -261,6 +268,32 @@ class AutobumpSweepTest(unittest.TestCase):
|
||||
)
|
||||
)
|
||||
|
||||
def test_escalation_comment_carries_every_evidence_file(self):
|
||||
self.run_sweep("4", "--comment")
|
||||
|
||||
body = [
|
||||
call[-1] for call in self.gh_calls() if call[:3] == ["issue", "comment", "4"]
|
||||
][-1]
|
||||
self.assertIn("tree-added.txt", body)
|
||||
self.assertIn("usr/lib/libnew.so", body)
|
||||
# a log is cut from its start, so the failure at its end survives
|
||||
self.assertIn("build.log (200 of 300 lines)", body)
|
||||
# wget progress lines are not a record of anything
|
||||
self.assertNotIn("80.5M", body)
|
||||
# the diff comes before the log it would otherwise be buried under
|
||||
self.assertLess(body.index("tree-added.txt"), body.index("build.log"))
|
||||
self.assertIn("build line 299", body)
|
||||
self.assertNotIn("build line 0\n", body)
|
||||
|
||||
def test_escalation_evidence_is_kept_for_upload(self):
|
||||
self.run_sweep("4", "--comment")
|
||||
|
||||
kept = self.kept / "cat_escalate-3.0"
|
||||
self.assertEqual(
|
||||
sorted(path.name for path in kept.iterdir()),
|
||||
["build.log", "escalations.txt", "tree-added.txt"],
|
||||
)
|
||||
|
||||
def test_exit_2_retries(self):
|
||||
result = self.run_sweep("5")
|
||||
|
||||
|
||||
Reference in new issue
Block a user