fix: credential check, step summary, fetch hardening, case-insensitive repo match
- drafter: claude with neither CLAUDE_CODE_OAUTH_TOKEN nor ANTHROPIC_API_KEY set posts the stage 1 flags with the note 'drafter: claude but no Claude credential is set' and fails, without starting Claude. - total_cost_usd and num_turns are printed and appended to GITHUB_STEP_SUMMARY. - git.fetch puts --end-of-options before the branch; run_pr and run_monthly use it. - The bot's own PRs match head.repo.full_name case-insensitively. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ade847ba5b
commit
a1f061ca6c
9 files changed
+112
-6
No files matched your search
@@ -54,6 +54,7 @@ class CliCase(unittest.TestCase):
|
||||
"DOCS_REVIEW_CLAUDE_BIN": str(self.fake_claude),
|
||||
"DOCS_REVIEW_BOT_TOKEN": "bot-token-value-123456",
|
||||
"RUNNER_TEMP": str(tmp),
|
||||
"ANTHROPIC_API_KEY": "test-api-key-value-123456",
|
||||
}
|
||||
|
||||
def claude(self, **config):
|
||||
@@ -221,6 +222,47 @@ class ClaudeDrafterTests(CliCase):
|
||||
self.assertEqual(len(self.comment_bodies()), 1)
|
||||
|
||||
|
||||
class CredentialAndSummaryTests(CliCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.claude(edit="docs/README.md")
|
||||
|
||||
def test_missing_credential_posts_stage1_note_and_fails(self):
|
||||
sha = self.feature_commit()
|
||||
env = {k: v for k, v in self.env.items()
|
||||
if k not in ("CLAUDE_CODE_OAUTH_TOKEN", "ANTHROPIC_API_KEY")}
|
||||
self.env = env
|
||||
self.assertEqual(self.run_pr(sha, CLAUDE_CODE_OAUTH_TOKEN="", ANTHROPIC_API_KEY=""), 1)
|
||||
bodies = self.comment_bodies()
|
||||
self.assertEqual(len(bodies), 1)
|
||||
self.assertIn("drafter: claude but no Claude credential is set", bodies[0])
|
||||
self.assertIn("Touched", bodies[0])
|
||||
self.assertFalse(self.sentinel.exists())
|
||||
self.assertEqual(self.fake.prs, [])
|
||||
|
||||
def test_oauth_token_alone_is_enough(self):
|
||||
sha = self.feature_commit()
|
||||
self.env.pop("ANTHROPIC_API_KEY")
|
||||
self.assertEqual(self.run_pr(sha, CLAUDE_CODE_OAUTH_TOKEN="oauth-token-value-1"), 0)
|
||||
self.assertEqual(len(self.fake.prs), 1)
|
||||
|
||||
def test_cost_and_turns_reach_the_step_summary(self):
|
||||
summary = Path(self.env["RUNNER_TEMP"]) / "step-summary.md"
|
||||
summary.write_text("earlier step\n", encoding="utf-8")
|
||||
sha = self.feature_commit()
|
||||
self.assertEqual(self.run_pr(sha, GITHUB_STEP_SUMMARY=str(summary)), 0)
|
||||
text = summary.read_text(encoding="utf-8")
|
||||
self.assertTrue(text.startswith("earlier step\n"))
|
||||
self.assertIn("total_cost_usd: 0.12", text)
|
||||
self.assertIn("num_turns: 3", text)
|
||||
|
||||
def test_no_summary_file_without_the_variable(self):
|
||||
sha = self.feature_commit()
|
||||
self.env.pop("GITHUB_STEP_SUMMARY", None)
|
||||
self.assertEqual(self.run_pr(sha), 0)
|
||||
self.assertFalse((Path(self.env["RUNNER_TEMP"]) / "step-summary.md").exists())
|
||||
|
||||
|
||||
class DocsPrLifecycleTests(CliCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
Reference in new issue
Block a user