Add community scope gate
Deploy / deploy (push) Successful in 1m26s
CI / Rust Checks (push) Successful in 4m40s
CI / UI Checks (push) Successful in 5s
CI / Deployment Manifests (push) Successful in 3s
CI / Frontend E2E (push) Successful in 4m34s

This commit is contained in:
github-ops
2026-06-20 17:59:58 +00:00
parent 0af60b1693
commit eaa369bf85
8 changed files with 240 additions and 27 deletions
+73
View File
@@ -0,0 +1,73 @@
import subprocess
import sys
import tempfile
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
CHECKER = ROOT / "scripts" / "check-community-scope.py"
class CommunityScopeCheckTests(unittest.TestCase):
def run_checker(self, root: Path, files: list[str]) -> subprocess.CompletedProcess[str]:
return subprocess.run(
[sys.executable, str(CHECKER), "--root", str(root), "--files", *files],
check=False,
text=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
def test_passes_for_clean_community_content(self) -> None:
with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
(root / "README.md").write_text(
"Crank publishes REST API endpoints as MCP tools.\n",
encoding="utf-8",
)
result = self.run_checker(root, ["README.md"])
self.assertEqual(result.returncode, 0, result.stderr)
self.assertIn("Community scope check passed", result.stdout)
def test_fails_for_forbidden_product_marker(self) -> None:
with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
(root / "apps").mkdir()
(root / "apps" / "ui.md").write_text(
"Hidden GraphQL protocol card must not be here.\n",
encoding="utf-8",
)
result = self.run_checker(root, ["apps/ui.md"])
self.assertNotEqual(result.returncode, 0)
self.assertIn("apps/ui.md:1", result.stderr)
self.assertIn("graphql", result.stderr.lower())
def test_ignores_default_excluded_paths(self) -> None:
with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
(root / "LICENSE").write_text(
"The license text may mention commercial distribution terms.\n",
encoding="utf-8",
)
result = self.run_checker(root, ["LICENSE"])
self.assertEqual(result.returncode, 0, result.stderr)
def test_skips_binary_files(self) -> None:
with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
(root / "logo.png").write_bytes(b"\x89PNG\x00enterprise\x00")
result = self.run_checker(root, ["logo.png"])
self.assertEqual(result.returncode, 0, result.stderr)
if __name__ == "__main__":
unittest.main()