Initial commit: document_analyzer with CI/CD pipeline
CI / test (push) Successful in 30s

- 4 skill pipeline (doc_parser, conflict_detection, ir_generation, resolution_application)
- CI workflow on push/PR (.gitea/workflows/ci.yml)
- Auto-issue on CI failure (.gitea/workflows/auto-issue.yml)
- Pytest smoke tests (tests/test_sample.py)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-29 20:00:26 +08:00
commit 40567a4fb6
22 changed files with 2898 additions and 0 deletions
+89
View File
@@ -0,0 +1,89 @@
"""Minimal smoke tests for the document_analyzer pipeline."""
import os
import sys
import json
import pytest
# -- Helpers ------------------------------------------------------------------
def _import_from_skill(skill_name, module_name):
"""Import a module from a skill's scripts directory."""
skill_dir = os.path.join(
os.path.dirname(os.path.dirname(__file__)),
"skills", skill_name, "scripts"
)
if skill_dir not in sys.path:
sys.path.insert(0, skill_dir)
# -- WordParser tests (no LLM dependency) -------------------------------------
def test_import_word_parser():
"""word_parser module should be importable."""
_import_from_skill("doc_parser_skill", "word_parser")
import word_parser
assert hasattr(word_parser, "WordParser")
def test_import_image_parser():
"""image_parser module should be importable."""
_import_from_skill("doc_parser_skill", "image_parser")
import image_parser
assert hasattr(image_parser, "ImageParser")
def test_import_LLM():
"""LLM module should be importable (requires DASHSCOPE_API_KEY env var)."""
os.environ.setdefault("DASHSCOPE_API_KEY", "test-fake-key")
_import_from_skill("doc_parser_skill", "LLM")
import LLM
assert hasattr(LLM, "LLMClient")
# -- Conflict detection tests -------------------------------------------------
def test_import_detect_conflicts():
"""detect_conflicts module should be importable."""
os.environ.setdefault("DASHSCOPE_API_KEY", "test-fake-key")
_import_from_skill("conflict_detection_skill", "detect_conflicts")
import detect_conflicts
assert hasattr(detect_conflicts, "detect_conflicts")
# -- IR generation tests ------------------------------------------------------
def test_import_ir_generator():
"""ir_generator module should be importable."""
os.environ.setdefault("DASHSCOPE_API_KEY", "test-fake-key")
_import_from_skill("ir_generation_skill", "ir_generator")
import ir_generator
assert hasattr(ir_generator, "generate_ir")
# -- Resolution application tests ---------------------------------------------
def test_import_apply_resolutions():
"""apply_resolutions module should be importable."""
_import_from_skill("resolution_application_skill", "apply_resolutions")
import apply_resolutions
assert hasattr(apply_resolutions, "apply_resolutions")
# -- JSON output validation ---------------------------------------------------
def test_sample_ir_json_is_valid():
"""The sample IR JSON file should be valid JSON."""
sample_path = os.path.join(
os.path.dirname(os.path.dirname(__file__)),
"skills", "ir_generation_skill",
"车机娱乐系统禁止功能文档_精简_updated.json"
)
if os.path.exists(sample_path):
with open(sample_path, "r", encoding="utf-8") as f:
data = json.load(f)
assert isinstance(data, (dict, list))
else:
pytest.skip("Sample IR JSON not found")