From c06afc5a2639d5065199046e358d0dc3024afc9b Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 5 Dec 2026 05:50:09 -0800 Subject: [PATCH] fix(block-ci): normalize artifact paths from both checker entry points --- .github/block/scripts/block-ci-port-test.py | 25 ++++++++++++++++++--- .github/block/scripts/public-text-check.sh | 5 ++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/.github/block/scripts/block-ci-port-test.py b/.github/block/scripts/block-ci-port-test.py index 3a52f581f3..be6973f14e 100644 --- a/.github/block/scripts/block-ci-port-test.py +++ b/.github/block/scripts/block-ci-port-test.py @@ -3,6 +3,7 @@ from pathlib import Path import copy import importlib.util import os +import shutil import re import subprocess import tempfile @@ -173,9 +174,27 @@ class PortTests(unittest.TestCase): artifact.parent.mkdir(parents=True); artifact.write_text("") git("add", "."); git("commit", "-m", "artifact") artifact_head = git("rev-parse", "HEAD").decode().strip() - leak = subprocess.run(["bash", str(HERE / "public-text-check.sh"), pattern_head, artifact_head, str(title), str(body)], cwd=module, capture_output=True, timeout=20) - self.assertEqual(leak.returncode, 1) - self.assertIn(b"artifact path: " + artifact_path.encode(), leak.stdout) + command = ["bash", str(HERE / "public-text-check.sh"), pattern_head, artifact_head, str(title), str(body)] + for cwd in (root, module): + leak = subprocess.run(command, cwd=cwd, capture_output=True, timeout=20) + self.assertEqual(leak.returncode, 1, (cwd, leak.stdout, leak.stderr)) + self.assertIn(b"artifact path: " + artifact_path.encode(), leak.stdout) + git("rm", str(artifact.relative_to(root))); git("commit", "-m", "remove artifact") + deleted = git("rev-parse", "HEAD").decode().strip() + removal = ["bash", str(HERE / "public-text-check.sh"), artifact_head, deleted, str(title), str(body)] + for cwd in (root, module): + result = subprocess.run(removal, cwd=cwd, capture_output=True, timeout=20) + self.assertEqual((result.returncode, result.stdout), (0, b"public-text: clean\n"), result.stderr) + fakebin = root / "fakebin"; fakebin.mkdir() + fakegit = fakebin / "git" + fakegit.write_text("#!/bin/sh\nfor arg; do\n if [ \"$arg\" = --diff-filter=ACMT ]; then\n printf 'docs/spec/partial.txt\\0'\n exit 23\n fi\ndone\nexec \"$PUBLIC_TEXT_REAL_GIT\" \"$@\"\n") + fakegit.chmod(0o755) + env = dict(os.environ, PUBLIC_TEXT_REAL_GIT=shutil.which("git"), PATH=str(fakebin) + os.pathsep + os.environ["PATH"]) + for cwd in (root, module): + result = subprocess.run(removal, cwd=cwd, env=env, capture_output=True, timeout=20) + self.assertEqual(result.returncode, 2, (cwd, result.stdout, result.stderr)) + self.assertIn(b"cannot enumerate artifact paths", result.stderr) + self.assertNotIn(b"public-text: clean", result.stdout) def test_public_text_adapter_passes_the_module_self_test(self): module = ROOT / "seaweed-block/.github/scripts" diff --git a/.github/block/scripts/public-text-check.sh b/.github/block/scripts/public-text-check.sh index b485202dda..0cebd0bbc0 100644 --- a/.github/block/scripts/public-text-check.sh +++ b/.github/block/scripts/public-text-check.sh @@ -30,11 +30,14 @@ report() { # report WHERE < matching lines } # Raw run artifacts are not public specs, even with scrubbed contents. # Allow deletions so existing artifacts can be removed. -if ! git diff --name-only -z --relative --no-renames --diff-filter=ACMT "$mb" "$head" -- docs/spec/ >"$paths"; then +repo_root=$(git rev-parse --show-toplevel) +if ! (cd "$repo_root" && git diff --name-only -z --no-relative --no-renames --diff-filter=ACMT "$mb" "$head" -- docs/spec/ seaweed-block/docs/spec/) >"$paths"; then echo 'public-text: cannot enumerate artifact paths' >&2 exit 2 fi while IFS= read -r -d '' path; do + # Match the module's paths the same way from either entry point. + path=${path#seaweed-block/} if [[ $path =~ ^docs/spec/(.*/)?recorded-[^/]+(/|$) ]]; then printf '%s\n' "$path" | report "artifact path" fi