mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-11-04 14:52:12 +08:00
fix(docs): publish directly from LangBot before archiving docs repository
Co-authored-by: multica-agent <[email protected]>
This commit is contained in:
co-authored by
multica-agent
parent
407352cc51
commit
fe8fa51b50
@@ -36,7 +36,7 @@ description: "ignored"
|
||||
self.assertIn("> **提示**", output)
|
||||
self.assertIn("[模型文档](zh-usage-models-readme)", output)
|
||||
self.assertIn(
|
||||
"https://raw.githubusercontent.com/langbot-app/langbot-docs/main/images/ui.png",
|
||||
"https://raw.githubusercontent.com/langbot-app/LangBot/master/docs/images/ui.png",
|
||||
output,
|
||||
)
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Offline API-contract tests; the workflow run verifies real GitHub writes."""
|
||||
import base64
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
@@ -10,8 +11,9 @@ spec.loader.exec_module(sync)
|
||||
|
||||
|
||||
class FakeAPI:
|
||||
def __init__(self, already=False, conflict=False, status="ahead"):
|
||||
def __init__(self, already=False, conflict=False, status="ahead", migrated=True):
|
||||
self.calls = []
|
||||
self.migrated = migrated
|
||||
self.pin = "new-docs" if already else "old-docs"
|
||||
self.landing = "landing-parent"
|
||||
self.deploy = "old-deploy"
|
||||
@@ -20,7 +22,12 @@ class FakeAPI:
|
||||
|
||||
def __call__(self, method, path, data=None):
|
||||
self.calls.append((method, path, data))
|
||||
if path.endswith("/git/ref/heads/main"):
|
||||
if "/contents/.gitmodules?ref=" in path:
|
||||
repo = "LangBot" if self.migrated else "langbot-docs"
|
||||
branch = "master" if self.migrated else "main"
|
||||
content = f'[submodule "docs"]\npath = docs\nurl = https://github.com/langbot-app/{repo}.git\nbranch = {branch}\n'
|
||||
return {"content": base64.b64encode(content.encode()).decode()}
|
||||
if "/git/ref/heads/" in path:
|
||||
sha = "new-docs" if path.startswith(sync.SOURCE + "/") else self.deploy if path.startswith(sync.DEPLOY + "/") else self.landing
|
||||
return {"object": {"sha": sha}}
|
||||
if method == "GET" and "/git/commits/" in path:
|
||||
@@ -83,3 +90,16 @@ class SyncTests(unittest.TestCase):
|
||||
with self.assertRaises(RuntimeError):
|
||||
sync.sync(api)
|
||||
self.assertTrue(all(m == "GET" for m, p, d in api.calls))
|
||||
|
||||
def test_reads_master_and_does_not_contact_archived_repository(self):
|
||||
api = FakeAPI()
|
||||
sync.sync(api)
|
||||
self.assertIn(("GET", "langbot-app/LangBot/git/ref/heads/master", None), api.calls)
|
||||
self.assertFalse(any("langbot-app/langbot-docs/" in p for _, p, _ in api.calls))
|
||||
|
||||
def test_old_submodule_configuration_fails_before_any_write(self):
|
||||
for already in [False, True]:
|
||||
api = FakeAPI(already=already, migrated=False)
|
||||
with self.assertRaisesRegex(RuntimeError, "must point to LangBot/master"):
|
||||
sync.sync(api)
|
||||
self.assertTrue(all(m == "GET" for m, _, _ in api.calls))
|
||||
|
||||
Reference in New Issue
Block a user