fix(ci): make MCP audit writeback repeatable

This commit is contained in:
ogt
2026-07-15 11:27:36 +08:00
parent 5eb46f9421
commit dd32cbf9cd
8 changed files with 539 additions and 69 deletions

View File

@@ -19,6 +19,7 @@ CONTROLLER_PATH = ROOT / "scripts/security/external_mcp_replay_controller.py"
POLICY_PATH = ROOT / "config/mcp/playwright-mcp-replay-policy.json"
ARTIFACT_POLICY_PATH = ROOT / "config/mcp/playwright-mcp-artifact-policy.json"
WORKFLOW_PATH = ROOT / ".gitea/workflows/mcp-external-replay.yaml"
AUDIT_WRITEBACK_PATH = ROOT / "scripts/ci/write-gitea-audit-receipts.sh"
SPEC = importlib.util.spec_from_file_location("external_mcp_replay_controller", CONTROLLER_PATH)
assert SPEC and SPEC.loader
@@ -389,6 +390,14 @@ class ReceiptAndWorkflowTests(unittest.TestCase):
self.assertIn("wait-host-web-build-pressure.sh", raw)
self.assertIn("mcp-replay-receipts", raw)
self.assertIn("verify_external_mcp_replay_receipt.py", raw)
self.assertIn("bash scripts/ci/write-gitea-audit-receipts.sh", raw)
writeback = AUDIT_WRITEBACK_PATH.read_text(encoding="utf-8").lower()
self.assertIn("git checkout --force --detach fetch_head", writeback)
self.assertNotIn("git merge --no-edit fetch_head", writeback)
self.assertIn(
'git push "${remote_name}" "head:refs/heads/${gitea_audit_branch}"',
writeback,
)
if __name__ == "__main__":