test: 移除硬编码路径,适配新 config.py 目录结构 - Closes #10
CI / test (pull_request) Successful in 7s

- conftest.py: secrets 路径改为多位置查找 (QE_SECRETS_PATH env → ~/.openclaw/config/ → workspace-document-analyzer/config/)
- conftest.py: IR 默认路径改为 output/final/ir_final.json (匹配 config.IR_FINAL_JSON)
- conftest.py: parsed 默认路径改为项目相对路径
- agent_poller.py: 添加 --labels 过滤 (向后兼容)
- 新增 agents/QE_AGENT.md + scripts/start_qe_agent.sh
This commit is contained in:
2026-05-31 16:48:35 +08:00
parent c2affcad42
commit 5c451099ad
4 changed files with 339 additions and 19 deletions
+16 -8
View File
@@ -1,10 +1,11 @@
"""Helper for dev agent to interact with Gitea issues and PRs.
"""Helper for QE/Dev agents to interact with Gitea issues and PRs.
Usage:
python scripts/agent_poller.py --action list
python scripts/agent_poller.py --action list --labels test-dev
python scripts/agent_poller.py --action get --issue 1
python scripts/agent_poller.py --action comment --issue 1 --body "Working on this"
python scripts/agent_poller.py --action create-pr --issue 1 --branch fix/issue-1
python scripts/agent_poller.py --action create-pr --issue 1 --branch test/issue-1
python scripts/agent_poller.py --action pr-status --pr 4
python scripts/agent_poller.py --action merge-pr --pr 4
python scripts/agent_poller.py --action close-issue --issue 2 --body "Done"
@@ -45,14 +46,19 @@ def _req(method, path, data=None):
# ── Issue operations ─────────────────────────────────────────────────────────
def list_issues():
issues = _req("GET", "/issues?state=open")
def list_issues(labels: list[str] | None = None):
url = "/issues?state=open"
if labels:
for lb in labels:
url += f"&labels={lb}"
issues = _req("GET", url)
if not issues:
print("No open issues found.")
label_hint = f" (filtered by {labels})" if labels else ""
print(f"No open issues found{label_hint}.")
return []
for i in issues:
labels = [l["name"] for l in i.get("labels", [])]
print(f"#{i['number']} [{', '.join(labels) if labels else 'no label'}] {i['title']}")
issue_labels = [l["name"] for l in i.get("labels", [])]
print(f"#{i['number']} [{', '.join(issue_labels) if issue_labels else 'no label'}] {i['title']}")
return issues
@@ -200,6 +206,7 @@ def main():
parser.add_argument("--pr", type=int)
parser.add_argument("--branch")
parser.add_argument("--body")
parser.add_argument("--labels", help="Comma-separated labels to filter issues (for 'list' action)")
args = parser.parse_args()
if not GITEA_TOKEN:
@@ -208,7 +215,8 @@ def main():
sys.exit(1)
if args.action == "list":
list_issues()
label_filter = [l.strip() for l in args.labels.split(",") if l.strip()] if args.labels else None
list_issues(label_filter)
elif args.action == "get":
if not args.issue:
print("--issue is required for 'get' action", file=sys.stderr)
+53
View File
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
# QE-Agent 启动脚本 — 在 Git Bash 中运行
# 用法: bash scripts/start_qe_agent.sh
set -e
export GITEA_API_TOKEN="59117246ec418d5d87042de073b0d4197d8054bf"
export GITEA_URL="http://localhost:3000"
export GITEA_REPO="pzhang_zywl/document_analyzer"
cd "$(dirname "$0")/.."
echo "============================================"
echo " QE-Agent 启动器"
echo "============================================"
echo ""
echo "模式选择:"
echo " [1] 单次任务 - 检查一次 test-dev Issue 并处理"
echo " [2] 持续轮询 - 每 10 分钟检查一次 (推荐)"
echo " [3] 交互模式 - 进入对话手动操作"
echo ""
read -r -p "请输入 (1/2/3): " MODE
case "$MODE" in
1)
echo ""
echo "正在执行单次检查..."
claude -p --agent agents/QE_AGENT.md \
"你是 QE-Agent。检查 Gitea 上的 test-dev 和 acceptance-failure 标签 Issue--action list --labels test-dev 和 --labels acceptance-failure)。对 test-dev Issue:分析内容 → 开发验收测试到 tests/acceptance/ → pytest 本地验证 → commit 'test: <描述> - Closes #N' → push → create-pr → comment Issue → 等 CI 通过 → merge-pr。对 acceptance-failure Issue:分析失败原因 → 如果是测试本身问题修复测试 → 如果是管道问题开 test-dev issue 跟踪。"
;;
2)
echo ""
echo "启动持续轮询模式 (每 10 分钟)..."
echo "按 Ctrl+C 停止"
claude -p --agent agents/QE_AGENT.md \
"你是 QE-Agent。用 loop 模式每 10 分钟检查一次 Gitea 上的 test-dev 和 acceptance-failure 标签 Issue。对 test-dev Issue 走完整闭环:分析→开发验收测试→pytest验证→commit('test:' 前缀)→push→create-pr→comment→CI→merge-pr。对 acceptance-failure 分析失败原因→修复→push→PR。每个步骤用 agent_poller.py 对应命令。如果没有待处理 Issue,报告 '当前没有 QE 相关 Issuemain branch 质量正常'。"
;;
3)
echo ""
echo "启动交互模式..."
echo "进入后输入: 检查 Gitea test-dev Issues 并处理"
echo "可用命令速查:"
echo " agent_poller.py --action list --labels test-dev"
echo " agent_poller.py --action list --labels acceptance-failure"
echo " agent_poller.py --action get --issue <N>"
echo " python -m pytest tests/acceptance/ -v --run-acceptance"
claude --agent agents/QE_AGENT.md
;;
*)
echo "无效选择。"
exit 1
;;
esac