feat(template): SRCP v1 standards, job_context/finish gold sample (v1.0.38, platform-kit 1.2.0)
All checks were successful
技能自动化发布 / release (push) Successful in 4s
All checks were successful
技能自动化发布 / release (push) Successful in 4s
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -35,7 +35,7 @@ def get_skill_root() -> str:
|
||||
return _SKILL_ROOT
|
||||
|
||||
|
||||
def platform_kit_version_patch(version: str = "1.0.17"):
|
||||
def platform_kit_version_patch(version: str = "1.2.0"):
|
||||
"""Mock installed jiangchang-platform-kit version for health/diagnostics tests."""
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
@@ -41,6 +41,9 @@ POLICY_IDS = (
|
||||
"POLICY-LOGGING-003",
|
||||
"POLICY-LOGGING-004",
|
||||
"POLICY-LOGGING-005",
|
||||
"POLICY-CONTROL-001",
|
||||
"POLICY-CONTROL-002",
|
||||
"POLICY-CONTROL-003",
|
||||
)
|
||||
|
||||
STRUCTURE_PATHS = (
|
||||
@@ -619,6 +622,65 @@ class TestPolicyLogging005(unittest.TestCase):
|
||||
)
|
||||
|
||||
|
||||
class TestPolicyControl001(unittest.TestCase):
|
||||
def test_no_util_progress_module(self) -> None:
|
||||
skill_root = get_skill_root()
|
||||
path = os.path.join(skill_root, "scripts", "util", "progress.py")
|
||||
self.assertFalse(
|
||||
os.path.isfile(path),
|
||||
msg=_policy_msg(
|
||||
"POLICY-CONTROL-001",
|
||||
"development/LOGGING.md §2.5; development/RPA.md §0.1",
|
||||
"scripts/util/progress.py must not exist",
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class TestPolicyControl002(unittest.TestCase):
|
||||
def test_task_service_uses_job_context_and_finish(self) -> None:
|
||||
skill_root = get_skill_root()
|
||||
path = os.path.join(skill_root, "scripts", "service", "task_service.py")
|
||||
text = _read_text(path)
|
||||
rel = _rel(skill_root, path)
|
||||
missing: list[str] = []
|
||||
if "job_context(" not in text:
|
||||
missing.append("job_context(")
|
||||
if "finish(" not in text:
|
||||
missing.append("finish(")
|
||||
self.assertEqual(
|
||||
missing,
|
||||
[],
|
||||
msg=_policy_msg(
|
||||
"POLICY-CONTROL-002",
|
||||
"development/LOGGING.md §2.5、§7",
|
||||
f"{rel} missing: " + ", ".join(missing),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class TestPolicyControl003(unittest.TestCase):
|
||||
def test_service_layer_has_no_bare_asyncio_sleep(self) -> None:
|
||||
skill_root = get_skill_root()
|
||||
offenders: list[str] = []
|
||||
for path in _walk_files(skill_root, "scripts/service", suffix=".py"):
|
||||
rel = _rel(skill_root, path)
|
||||
for lineno, line in enumerate(_read_text(path).splitlines(), 1):
|
||||
stripped = line.strip()
|
||||
if not stripped or stripped.startswith("#"):
|
||||
continue
|
||||
if "asyncio.sleep" in stripped:
|
||||
offenders.append(f"{rel}:{lineno}: {stripped}")
|
||||
self.assertEqual(
|
||||
offenders,
|
||||
[],
|
||||
msg=_policy_msg(
|
||||
"POLICY-CONTROL-003",
|
||||
"development/RPA.md §0.1",
|
||||
"use interruptible_sleep instead:\n" + "\n".join(offenders),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class TestPolicyDocs001(unittest.TestCase):
|
||||
def test_policy_matrix_exists_and_lists_policy_ids(self) -> None:
|
||||
skill_root = get_skill_root()
|
||||
|
||||
@@ -172,7 +172,7 @@ class TestDocsStandards(unittest.TestCase):
|
||||
self.assertIn("--no-sandbox", text)
|
||||
self.assertIn("--disable-blink-features=AutomationControlled", text)
|
||||
self.assertIn("RpaVideoSession", text)
|
||||
self.assertIn("1.0.17", text)
|
||||
self.assertIn("1.2.0", text)
|
||||
|
||||
def test_rpa_md_forbids_rpa_helpers_import(self) -> None:
|
||||
text = self._read("development/RPA.md")
|
||||
|
||||
@@ -83,16 +83,16 @@ class TestPlatformImportSource(unittest.TestCase):
|
||||
)
|
||||
)
|
||||
|
||||
def test_platform_kit_min_version_is_1_0_14(self) -> None:
|
||||
def test_platform_kit_min_version_is_1_2_0(self) -> None:
|
||||
from jiangchang_skill_core import version_ge
|
||||
from util.constants import PLATFORM_KIT_MIN_VERSION
|
||||
|
||||
self.assertEqual(PLATFORM_KIT_MIN_VERSION, "1.0.17")
|
||||
self.assertEqual(PLATFORM_KIT_MIN_VERSION, "1.2.0")
|
||||
|
||||
md_path = os.path.join(get_skill_root(), "SKILL.md")
|
||||
with open(md_path, encoding="utf-8") as f:
|
||||
md = f.read()
|
||||
self.assertEqual(_parse_platform_kit_min_version(md), "1.0.17")
|
||||
self.assertEqual(_parse_platform_kit_min_version(md), "1.2.0")
|
||||
|
||||
req_path = os.path.join(get_skill_root(), "requirements.txt")
|
||||
with open(req_path, encoding="utf-8") as f:
|
||||
|
||||
@@ -34,7 +34,7 @@ FORBIDDEN_PHRASES = (
|
||||
|
||||
POSITIVE_MARKERS = (
|
||||
"jiangchang-platform-kit",
|
||||
"1.0.17",
|
||||
"1.2.0",
|
||||
"共享 runtime",
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user