Files
marqdo-cli/tools/ci/annotate_workspace_tests.py
T
cflmy 3a29fce061
CI / fmt + clippy + test (Linux x86_64) (push) Waiting to run
CI / schema instance validation + consumers (push) Waiting to run
CI / runtime contract (macos-latest) (push) Waiting to run
CI / runtime contract (windows-latest) (push) Waiting to run
Linux strict security lane (G-C) / strict isolation escape matrix (push) Waiting to run
ci/woodpecker/push/woodpecker Pipeline was successful
fix(foreign): resolve Windows PATH executables with PATHEXT
The built-in Python provider scanned PATH for the extension-less token
python3; a Windows PATH contains python3.exe, so a working interpreter was
reported as kernel.unavailable and the semantic golden suite failed on
windows-latest. Expand candidates with PATHEXT (conservative default) and use
the same platform-aware resolver in the conformance test's availability probe.

Also make native failures diagnosable: strip ANSI before matching and emit the
panic/build context as public check annotations, and run Linux tests through
the same annotator. This fixes the Windows native lane and gives the macOS
failure the context needed to diagnose it.
2026-11-21 18:22:22 +08:00

64 lines
2.0 KiB
Python
Executable File

#!/usr/bin/env python3
"""Emit GitHub check annotations from a cargo-test log.
Native jobs (Windows/macOS) and the Linux gate tee `cargo test --workspace` to
a file. Public check-run annotations are then the only failure detail visible
without repository-admin log access. ANSI colour codes are stripped first so
anchored patterns still match.
"""
import re
import sys
MAX_ANNOTATIONS = 60
ANSI = re.compile(r"\x1b\[[0-9;]*m")
def escape(text: str) -> str:
return text.replace("%", "%25").replace("\r", "%0D").replace("\n", "%0A")
def interesting_lines(lines: list[str]) -> list[tuple[int, str]]:
selected: list[tuple[int, str]] = []
seen: set[int] = set()
def add(index: int) -> None:
if 0 <= index < len(lines) and index not in seen:
seen.add(index)
selected.append((index, lines[index]))
for index, line in enumerate(lines):
if "panicked at" in line:
for offset in range(-2, 19):
add(index + offset)
elif line.startswith("failures:") or line.startswith("---- "):
for offset in range(0, 6):
add(index + offset)
elif re.match(r"^error(\[|:)", line):
for offset in range(-1, 7):
add(index + offset)
elif "test " in line and line.endswith("FAILED"):
add(index)
return sorted(selected)
def main(argv: list[str]) -> int:
if len(argv) < 2:
print("usage: annotate_workspace_tests.py <log> [title]", file=sys.stderr)
return 2
log = sys.argv[1]
title = sys.argv[2] if len(argv) > 2 else "Workspace tests"
try:
text = open(log, encoding="utf-8", errors="replace").read()
except OSError as error:
print(f"::error title={title}::cannot read test log: {error}")
return 0
lines = ANSI.sub("", text).splitlines()
for _, line in interesting_lines(lines)[:MAX_ANNOTATIONS]:
print(f"::error title={title}::{escape(line)}")
return 0
if __name__ == "__main__":
raise SystemExit(main(sys.argv))