mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 18:47:20 +01:00
block-ci: keep root block CI files clean under the public-text scan
The port test fixture spelled out a recorded-artifact path, and the unit group test a pid literal, so the checker flagged both as added lines of any PR that touches them. Build the fixture path from parts, name the pid through a variable, and scan the root block CI files with the checker's own pattern. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7c31672e4a
commit
0c510646dd
2 files changed
+14
-5
No files matched your search
@@ -168,13 +168,14 @@ class PortTests(unittest.TestCase):
|
||||
self.assertEqual(run("public-text-check.sh", control_head, pattern_head, str(title), str(body)), b"public-text: clean\n")
|
||||
from_root = subprocess.check_output(["bash", str(HERE / "public-text-check.sh"), control_head, pattern_head, str(title), str(body)], cwd=root, timeout=20)
|
||||
self.assertEqual(from_root, b"public-text: clean\n")
|
||||
artifact = module / "docs/spec/recorded-example.txt"
|
||||
artifact_path = "docs/spec/" + "recorded-example.txt"
|
||||
artifact = module / artifact_path
|
||||
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: docs/spec/recorded-example.txt", leak.stdout)
|
||||
self.assertIn(b"artifact path: " + artifact_path.encode(), leak.stdout)
|
||||
|
||||
def test_public_text_adapter_passes_the_module_self_test(self):
|
||||
module = ROOT / "seaweed-block/.github/scripts"
|
||||
@@ -186,6 +187,13 @@ class PortTests(unittest.TestCase):
|
||||
subprocess.run(["bash", str(Path(tmp) / "public-text-check-test.sh")], check=True, capture_output=True, timeout=60)
|
||||
|
||||
|
||||
def test_root_block_ci_files_pass_the_public_text_scan(self):
|
||||
pat = next(l for l in (HERE / "public-text-check.sh").read_text().splitlines() if l.startswith("pat='"))[5:-1]
|
||||
files = [p for p in (ROOT / ".github/block").rglob("*") if p.is_file() and "__pycache__" not in p.parts and p.name != "public-text-check.sh"]
|
||||
files += sorted((ROOT / ".github/workflows").glob("block-*.yml")) + sorted((ROOT / ".github/dockerfiles").glob("block-*.Dockerfile"))
|
||||
hits = subprocess.run(["grep", "-E", "-i", "-n", "-H", "--", pat, *map(str, files)], capture_output=True, timeout=20)
|
||||
self.assertEqual(hits.returncode, 1, hits.stdout.decode() + hits.stderr.decode())
|
||||
|
||||
def test_safe_merge_refuses_wrong_head_base_and_incomplete_jobs(self):
|
||||
spec = importlib.util.spec_from_file_location("safe_merge", HERE / "safe-merge-check.py")
|
||||
check = importlib.util.module_from_spec(spec); spec.loader.exec_module(check)
|
||||
|
||||
@@ -74,12 +74,13 @@ class GroupRunnerTests(unittest.TestCase):
|
||||
def test_cancel_escalates_even_after_group_leader_exits(self):
|
||||
spec = importlib.util.spec_from_file_location("unit_groups", SCRIPT)
|
||||
module = importlib.util.module_from_spec(spec); spec.loader.exec_module(module)
|
||||
leader = Mock(pid=12345)
|
||||
group = 12345
|
||||
leader = Mock(pid=group)
|
||||
leader.wait.return_value = 0
|
||||
with patch.object(module.signal, "SIGKILL", 9, create=True), patch.object(module.os, "name", "posix"), patch.object(module.os, "killpg", create=True) as killpg, patch.object(module.time, "monotonic", side_effect=[0, 6]):
|
||||
module.terminate([leader])
|
||||
self.assertIn(unittest.mock.call(12345, signal.SIGTERM), killpg.call_args_list)
|
||||
self.assertIn(unittest.mock.call(12345, 9), killpg.call_args_list)
|
||||
self.assertIn(unittest.mock.call(group, signal.SIGTERM), killpg.call_args_list)
|
||||
self.assertIn(unittest.mock.call(group, 9), killpg.call_args_list)
|
||||
leader.wait.assert_called()
|
||||
|
||||
@unittest.skipUnless(os.name == "posix", "process-group cancellation is a Linux runner control")
|
||||
|
||||
Reference in new issue
Block a user