🔧 chore(thirdparty): generalize skills sync pipeline
replace the superpowers-only workflow with a manifest-driven pipeline sync ui-ux-pro-max into codex/skills and document source lists fix the prettier path test so the Python suite passes on Windows
This commit is contained in:
+1
-2
@@ -15,8 +15,7 @@ tests/
|
||||
├── test_sync_directory_actions.py # sync_memory_bank/sync_prompts 行为测试
|
||||
├── test_vendor_snapshot_templates.py # vendor 快照模板完整性测试
|
||||
├── test_main_loop_cli.py # main_loop CLI 测试
|
||||
├── test_superpowers_list_sync.py # superpowers 列表一致性测试
|
||||
├── test_superpowers_workflows.py # superpowers 工作流配置校验
|
||||
├── test_thirdparty_skills_pipeline.py # thirdparty skills 流水线配置与同步产物测试
|
||||
├── test_sync_templates_placeholders.py # 占位符替换测试(sync_rules/sync_standards)
|
||||
├── test_toml_edge_cases.py # TOML 解析边界测试
|
||||
├── templates/ # 模板验证测试
|
||||
|
||||
@@ -26,14 +26,22 @@ class FormatMdActionTests(unittest.TestCase):
|
||||
|
||||
bin_dir = root / "bin"
|
||||
bin_dir.mkdir()
|
||||
prettier = bin_dir / "prettier"
|
||||
prettier.write_text(
|
||||
"#!/usr/bin/env python3\n"
|
||||
"from pathlib import Path\n"
|
||||
"Path(\".prettier_called\").write_text(\"ok\")\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
prettier.chmod(0o755)
|
||||
if os.name == "nt":
|
||||
prettier = bin_dir / "prettier.cmd"
|
||||
prettier.write_text(
|
||||
"@echo off\r\n"
|
||||
"echo ok> .prettier_called\r\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
else:
|
||||
prettier = bin_dir / "prettier"
|
||||
prettier.write_text(
|
||||
"#!/usr/bin/env python3\n"
|
||||
"from pathlib import Path\n"
|
||||
"Path(\".prettier_called\").write_text(\"ok\")\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
prettier.chmod(0o755)
|
||||
|
||||
config_body = f"""
|
||||
[playbook]
|
||||
@@ -47,7 +55,7 @@ project_root = \"{tmp_dir}\"
|
||||
config_path.write_text(config_body, encoding="utf-8")
|
||||
|
||||
env = os.environ.copy()
|
||||
env["PATH"] = f"{bin_dir}:{env.get('PATH', '')}"
|
||||
env["PATH"] = f"{bin_dir}{os.pathsep}{env.get('PATH', '')}"
|
||||
|
||||
result = run_cli("-config", str(config_path), env=env)
|
||||
self.assertEqual(result.returncode, 0, msg=result.stderr)
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SKILLS_MD = ROOT / "SKILLS.md"
|
||||
SOURCES_LIST = ROOT / "codex" / "skills" / ".sources" / "superpowers.list"
|
||||
SOURCE_REF = "来源:`codex/skills/.sources/superpowers.list`(第三方来源清单)。"
|
||||
|
||||
|
||||
def read_sources_list() -> list[str]:
|
||||
return [
|
||||
line.strip()
|
||||
for line in SOURCES_LIST.read_text(encoding="utf-8").splitlines()
|
||||
if line.strip() and not line.strip().startswith("#")
|
||||
]
|
||||
|
||||
|
||||
def read_skills_md() -> str:
|
||||
return SKILLS_MD.read_text(encoding="utf-8")
|
||||
|
||||
|
||||
class SuperpowersListSyncTests(unittest.TestCase):
|
||||
def test_superpowers_section_routes_to_source_list(self):
|
||||
self.assertTrue(read_sources_list())
|
||||
|
||||
text = read_skills_md()
|
||||
|
||||
self.assertIn(SOURCE_REF, text)
|
||||
self.assertEqual(text.count("Third-party Skills (superpowers)"), 1)
|
||||
self.assertNotIn("<!-- superpowers:skills:start -->", text)
|
||||
self.assertNotIn("<!-- superpowers:skills:end -->", text)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -1,93 +0,0 @@
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
LEGACY_SYNC_WORKFLOW = ROOT / ".gitea" / "workflows" / "sync-superpowers.yml"
|
||||
AUTO_UPDATE_WORKFLOW = ROOT / ".gitea" / "workflows" / "update-thirdparty-superpowers.yml"
|
||||
AUTO_UPDATE_SCRIPT = ROOT / ".gitea" / "ci" / "update_thirdparty_superpowers.sh"
|
||||
SYNC_SCRIPT = ROOT / ".gitea" / "ci" / "sync_superpowers.sh"
|
||||
|
||||
|
||||
class SuperpowersWorkflowTests(unittest.TestCase):
|
||||
def test_legacy_sync_workflow_is_removed(self):
|
||||
self.assertFalse(LEGACY_SYNC_WORKFLOW.exists())
|
||||
|
||||
def test_auto_update_workflow_name_describes_full_pipeline(self):
|
||||
text = AUTO_UPDATE_WORKFLOW.read_text(encoding="utf-8")
|
||||
self.assertIn("Update and Sync Superpowers", text)
|
||||
|
||||
def test_auto_update_workflow_triggers_on_main_push(self):
|
||||
text = AUTO_UPDATE_WORKFLOW.read_text(encoding="utf-8")
|
||||
self.assertIn("push:", text)
|
||||
self.assertIn("- main", text)
|
||||
self.assertIn("workflow_dispatch:", text)
|
||||
|
||||
def test_auto_update_workflow_runs_daily_schedule(self):
|
||||
text = AUTO_UPDATE_WORKFLOW.read_text(encoding="utf-8")
|
||||
self.assertIn("schedule:", text)
|
||||
self.assertIn('- cron: "@daily"', text)
|
||||
|
||||
def test_auto_update_workflow_runs_update_script(self):
|
||||
text = AUTO_UPDATE_WORKFLOW.read_text(encoding="utf-8")
|
||||
self.assertIn("bash .gitea/ci/update_thirdparty_superpowers.sh", text)
|
||||
|
||||
def test_auto_update_workflow_uses_single_serial_job(self):
|
||||
text = AUTO_UPDATE_WORKFLOW.read_text(encoding="utf-8")
|
||||
self.assertIn("update_and_sync:", text)
|
||||
self.assertNotIn("\n update:\n", text)
|
||||
self.assertNotIn("\n sync:\n", text)
|
||||
self.assertNotIn("needs: update", text)
|
||||
self.assertNotIn("outputs:", text)
|
||||
self.assertIn("bash .gitea/ci/sync_superpowers.sh", text)
|
||||
|
||||
def test_auto_update_workflow_sync_job_clears_stale_index_flags(self):
|
||||
text = AUTO_UPDATE_WORKFLOW.read_text(encoding="utf-8")
|
||||
self.assertIn("git update-index --no-assume-unchanged", text)
|
||||
self.assertIn("--no-skip-worktree", text)
|
||||
|
||||
def test_auto_update_workflow_sync_step_runs_from_latest_main(self):
|
||||
text = AUTO_UPDATE_WORKFLOW.read_text(encoding="utf-8")
|
||||
self.assertIn('TARGET_BRANCH="$THIRDPARTY_BRANCH" bash .gitea/ci/update_thirdparty_superpowers.sh', text)
|
||||
self.assertIn('TARGET_BRANCH="main" \\', text)
|
||||
self.assertIn('SUPERPOWERS_BRANCH="$THIRDPARTY_BRANCH" \\', text)
|
||||
self.assertIn('SUPERPOWERS_DIR="$SUPERPOWERS_DIR" \\', text)
|
||||
self.assertIn('SUPERPOWERS_LIST="$SUPERPOWERS_LIST" \\', text)
|
||||
|
||||
def test_auto_update_workflow_sync_job_uses_literal_superpowers_paths(self):
|
||||
text = AUTO_UPDATE_WORKFLOW.read_text(encoding="utf-8")
|
||||
self.assertIn('SUPERPOWERS_DIR: "superpowers"', text)
|
||||
self.assertIn('SUPERPOWERS_LIST: "codex/skills/.sources/superpowers.list"', text)
|
||||
self.assertNotIn('SUPERPOWERS_DIR: "${{ env.SUPERPOWERS_DIR }}"', text)
|
||||
self.assertNotIn('SUPERPOWERS_LIST: "${{ env.SUPERPOWERS_LIST }}"', text)
|
||||
|
||||
def test_auto_update_workflow_logs_clear_serial_flow(self):
|
||||
text = AUTO_UPDATE_WORKFLOW.read_text(encoding="utf-8")
|
||||
self.assertIn("name: 🪄 Update and Sync Superpowers", text)
|
||||
self.assertIn("- name: 🧰 Prepare repo", text)
|
||||
self.assertIn('- name: ♻️ Update thirdparty and sync main', text)
|
||||
self.assertIn('echo "📦 Refresh thirdparty/skill snapshot"', text)
|
||||
self.assertIn('echo "✅ No thirdparty snapshot change; skip main sync."', text)
|
||||
self.assertIn('echo "🚀 Sync skills into main"', text)
|
||||
|
||||
def test_auto_update_script_targets_thirdparty_branch(self):
|
||||
text = AUTO_UPDATE_SCRIPT.read_text(encoding="utf-8")
|
||||
self.assertIn('TARGET_BRANCH="${TARGET_BRANCH:-thirdparty/skill}"', text)
|
||||
self.assertIn("api.github.com/repos", text)
|
||||
self.assertIn("ls-remote", text)
|
||||
self.assertIn('git checkout -B "$TARGET_BRANCH" "origin/$TARGET_BRANCH"', text)
|
||||
|
||||
def test_ci_scripts_use_ci_bot_identity(self):
|
||||
sync_text = SYNC_SCRIPT.read_text(encoding="utf-8")
|
||||
update_text = AUTO_UPDATE_SCRIPT.read_text(encoding="utf-8")
|
||||
|
||||
self.assertIn('COMMIT_AUTHOR_NAME="${COMMIT_AUTHOR_NAME:-ci[bot]}"', sync_text)
|
||||
self.assertIn('COMMIT_AUTHOR_EMAIL="${COMMIT_AUTHOR_EMAIL:-ci-bot@local}"', sync_text)
|
||||
self.assertIn('COMMIT_AUTHOR_NAME="${COMMIT_AUTHOR_NAME:-ci[bot]}"', update_text)
|
||||
self.assertIn(
|
||||
'COMMIT_AUTHOR_EMAIL="${COMMIT_AUTHOR_EMAIL:-ci-bot@local}"',
|
||||
update_text,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,85 @@
|
||||
import json
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
MANIFEST = ROOT / ".gitea" / "ci" / "thirdparty_skills.json"
|
||||
WORKFLOW = ROOT / ".gitea" / "workflows" / "update-thirdparty-skills.yml"
|
||||
LEGACY_WORKFLOW = ROOT / ".gitea" / "workflows" / "update-thirdparty-superpowers.yml"
|
||||
UPDATE_SCRIPT = ROOT / ".gitea" / "ci" / "update_thirdparty_skills.sh"
|
||||
SYNC_SCRIPT = ROOT / ".gitea" / "ci" / "sync_thirdparty_skills.sh"
|
||||
SKILLS_MD = ROOT / "SKILLS.md"
|
||||
SUPERPOWERS_LIST = ROOT / "codex" / "skills" / ".sources" / "superpowers.list"
|
||||
UI_UX_PRO_MAX_LIST = ROOT / "codex" / "skills" / ".sources" / "ui-ux-pro-max.list"
|
||||
UI_UX_PRO_MAX_DIR = ROOT / "codex" / "skills" / "ui-ux-pro-max"
|
||||
|
||||
|
||||
def load_manifest() -> dict:
|
||||
return json.loads(MANIFEST.read_text(encoding="utf-8"))
|
||||
|
||||
|
||||
class ThirdpartySkillsPipelineTests(unittest.TestCase):
|
||||
def test_manifest_declares_superpowers_and_ui_ux_pro_max(self):
|
||||
data = load_manifest()
|
||||
self.assertEqual(
|
||||
[entry["id"] for entry in data["sources"]],
|
||||
["superpowers", "ui-ux-pro-max"],
|
||||
)
|
||||
|
||||
def test_ui_ux_pro_max_uses_render_codex_skill_sync_mode(self):
|
||||
data = load_manifest()
|
||||
ui_skill = next(item for item in data["sources"] if item["id"] == "ui-ux-pro-max")
|
||||
self.assertEqual(ui_skill["sync_mode"], "render_codex_skill")
|
||||
self.assertEqual(ui_skill["snapshot_dir"], "ui-ux-pro-max")
|
||||
|
||||
def test_workflow_uses_generic_scripts_and_single_serial_job(self):
|
||||
text = WORKFLOW.read_text(encoding="utf-8")
|
||||
self.assertFalse(LEGACY_WORKFLOW.exists())
|
||||
self.assertIn("update_and_sync:", text)
|
||||
self.assertNotIn("\n update:\n", text)
|
||||
self.assertNotIn("\n sync:\n", text)
|
||||
self.assertIn("bash .gitea/ci/update_thirdparty_skills.sh", text)
|
||||
self.assertIn("bash .gitea/ci/sync_thirdparty_skills.sh", text)
|
||||
self.assertNotIn("git merge", text)
|
||||
self.assertNotIn("git pull", text)
|
||||
|
||||
def test_workflow_has_serial_concurrency_and_literal_generic_paths(self):
|
||||
text = WORKFLOW.read_text(encoding="utf-8")
|
||||
self.assertIn("concurrency:", text)
|
||||
self.assertIn("update-thirdparty-${{ github.repository }}", text)
|
||||
self.assertIn('MANIFEST_PATH: ".gitea/ci/thirdparty_skills.json"', text)
|
||||
self.assertIn('TARGET_BRANCH="$THIRDPARTY_BRANCH" bash .gitea/ci/update_thirdparty_skills.sh', text)
|
||||
self.assertIn('TARGET_BRANCH="main" \\', text)
|
||||
self.assertIn('MANIFEST_PATH="$MANIFEST_PATH" \\', text)
|
||||
|
||||
def test_generic_scripts_exist_and_use_manifest(self):
|
||||
update_text = UPDATE_SCRIPT.read_text(encoding="utf-8")
|
||||
sync_text = SYNC_SCRIPT.read_text(encoding="utf-8")
|
||||
self.assertIn('MANIFEST_PATH="${MANIFEST_PATH:-.gitea/ci/thirdparty_skills.json}"', update_text)
|
||||
self.assertIn('MANIFEST_PATH="${MANIFEST_PATH:-.gitea/ci/thirdparty_skills.json}"', sync_text)
|
||||
self.assertIn('TARGET_BRANCH="${TARGET_BRANCH:-thirdparty/skill}"', update_text)
|
||||
self.assertIn('TARGET_BRANCH="${TARGET_BRANCH:-main}"', sync_text)
|
||||
self.assertIn(':package: deps(thirdparty): update snapshots', update_text)
|
||||
self.assertIn(':package: deps(skills): sync thirdparty skills', sync_text)
|
||||
|
||||
def test_skills_doc_points_to_generic_thirdparty_sources(self):
|
||||
text = SKILLS_MD.read_text(encoding="utf-8")
|
||||
self.assertIn("## 9. Third-party Skills", text)
|
||||
self.assertIn("来源:`codex/skills/.sources/`(第三方来源清单目录)。", text)
|
||||
self.assertNotIn("Third-party Skills (superpowers)", text)
|
||||
|
||||
def test_superpowers_and_ui_ux_pro_max_source_lists_exist(self):
|
||||
self.assertTrue(SUPERPOWERS_LIST.is_file())
|
||||
self.assertTrue(UI_UX_PRO_MAX_LIST.is_file())
|
||||
self.assertIn("using-superpowers", SUPERPOWERS_LIST.read_text(encoding="utf-8"))
|
||||
self.assertIn("ui-ux-pro-max", UI_UX_PRO_MAX_LIST.read_text(encoding="utf-8"))
|
||||
|
||||
def test_ui_ux_pro_max_output_exists_with_data_and_scripts(self):
|
||||
self.assertTrue((UI_UX_PRO_MAX_DIR / "SKILL.md").is_file())
|
||||
self.assertTrue((UI_UX_PRO_MAX_DIR / "data").is_dir())
|
||||
self.assertTrue((UI_UX_PRO_MAX_DIR / "scripts").is_dir())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user