feat: reusable review workflow
tests / unittest (push) Successful in 19s

Callers use Civilytics/docs-review/.gitea/workflows/review.yml@v1 with secrets: inherit.
Stage 1 on every pull request; for drafter: claude, a 180-second wait and then the sandboxed
drafter; closed pull requests close their docs PR; schedule and dispatch run the monthly
pass. Tested live against Gitea 28.3 (drafter none, a misspelled drafter, claude, close).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-12 15:12:57 -05:00
1 parent ade847ba5b
commit f39409e62c
11 files changed
+466 -26

No files matched your search

+40
View File
@@ -49,6 +49,20 @@ class TestGit(unittest.TestCase):
call()
self.assertFalse(out.exists())
def test_checkout_new_creates_branch_at_rev(self):
git.checkout_new("docs-review/pr-3", "HEAD~1", self.repo)
self.assertEqual(git.run(["rev-parse", "--abbrev-ref", "HEAD"], self.repo).strip(),
"docs-review/pr-3")
self.assertEqual(git.run(["rev-parse", "HEAD"], self.repo).strip(),
git.run(["rev-parse", "main~1"], self.repo).strip())
def test_checkout_new_refuses_option_like_values(self):
out = Path(self._tmp.name) / "x"
for branch, rev in (("b", f"--output={out}"), ("-b", "HEAD"), ("b", "")):
with self.assertRaises(git.GitError):
git.checkout_new(branch, rev, self.repo)
self.assertFalse(out.exists())
def test_merge_base_and_ls_files(self):
head = git.run(["rev-parse", "HEAD"], self.repo).strip()
self.assertEqual(git.merge_base("HEAD", "HEAD~1", self.repo),
@@ -136,6 +150,32 @@ class TestGitHardening(unittest.TestCase):
git.run(["status"], self.repo)
self.assertNotIn("GIT_CONFIG_COUNT", calls[-1][1])
def test_fetch_ends_options_before_the_branch(self):
git.run(["push", "-q", "origin", "main"], self.repo)
calls = self._record()
git.fetch("main", self.repo)
argv, _ = calls[-1]
self.assertEqual(argv[-2:], [git.EOO, "main"])
self.assertEqual(git.run(["rev-parse", "FETCH_HEAD"], self.repo).strip(),
git.run(["rev-parse", "main"], self.repo).strip())
out = Path(self._tmp.name) / "x"
with self.assertRaises(git.GitError):
git.fetch(f"--upload-pack=touch {out}", self.repo)
self.assertFalse(out.exists())
def test_push_scopes_header_to_the_server(self):
calls = self._record()
git.run(["checkout", "-q", "-b", "docs-review/pr-4"], self.repo)
git.push("docs-review/pr-4", self.repo, self.TOKEN, "https://gitea.example.org/")
env = calls[-1][1]
self.assertEqual(env["GIT_CONFIG_KEY_0"], "http.https://gitea.example.org/.extraHeader")
self.assertEqual(env["GIT_CONFIG_VALUE_0"], f"Authorization: token {self.TOKEN}")
def test_header_key_falls_back_to_unscoped(self):
self.assertEqual(git.header_key(None), "http.extraHeader")
self.assertEqual(git.header_key(""), "http.extraHeader")
self.assertEqual(git.header_key("https://h.example"), "http.https://h.example/.extraHeader")
def test_push_without_token_adds_no_header(self):
calls = self._record()
git.push("main", self.repo, None)