🔧 chore(ci): scope tsl playbook sync paths
This commit is contained in:
@@ -126,8 +126,18 @@ class BuildTslPlaybookTests(unittest.TestCase):
|
||||
text = SYNC_WORKFLOW.read_text(encoding="utf-8")
|
||||
|
||||
self.assertNotRegex(text, r"git rm -rf --quiet\s+\.")
|
||||
self.assertIn("generated_paths=(AGENTS.md docs skills)", text)
|
||||
self.assertIn('git add -A "${generated_paths[@]}"', text)
|
||||
self.assertIn("managed_paths=(", text)
|
||||
for path in (
|
||||
"AGENTS.md",
|
||||
"docs/tsl",
|
||||
"skills/tsl-syntax-reference",
|
||||
"skills/tsl-api-reference",
|
||||
):
|
||||
self.assertIn(f'"{path}"', text)
|
||||
self.assertNotIn("generated_paths=(AGENTS.md docs skills)", text)
|
||||
self.assertIn('rm -rf -- "${managed_paths[@]}"', text)
|
||||
self.assertIn('git add -A -- "${managed_paths[@]}"', text)
|
||||
self.assertNotIn('cp -R "$bundle"/. "$REPO_DIR"/', text)
|
||||
self.assertNotIn(".gitea/ci/", text)
|
||||
self.assertNotIn("https://oauth2", text)
|
||||
self.assertNotIn("oauth2:${TOKEN}", text)
|
||||
@@ -145,23 +155,49 @@ class BuildTslPlaybookTests(unittest.TestCase):
|
||||
|
||||
git(repo, "checkout", "--orphan", "tsl-playbook")
|
||||
git(repo, "rm", "-rf", ".")
|
||||
(repo / "README.md").write_text(
|
||||
"manual branch note\n", encoding="utf-8", newline="\n"
|
||||
unmanaged_files = {
|
||||
"README.md": "manual branch note\n",
|
||||
"docs/python/index.md": "manual python docs\n",
|
||||
"skills/manual-skill/SKILL.md": "manual skill\n",
|
||||
}
|
||||
for relative, content in unmanaged_files.items():
|
||||
path = repo / relative
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(content, encoding="utf-8", newline="\n")
|
||||
|
||||
stale_managed_files = (
|
||||
"docs/tsl/stale.md",
|
||||
"skills/tsl-syntax-reference/stale.md",
|
||||
"skills/tsl-api-reference/stale.md",
|
||||
)
|
||||
git(repo, "add", "README.md")
|
||||
git(repo, "commit", "-m", "manual target branch note")
|
||||
for relative in stale_managed_files:
|
||||
path = repo / relative
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text("stale\n", encoding="utf-8", newline="\n")
|
||||
|
||||
git(repo, "add", ".")
|
||||
git(repo, "commit", "-m", "manual target branch content")
|
||||
git(repo, "push", "-u", "origin", "tsl-playbook")
|
||||
|
||||
git(repo, "checkout", "main")
|
||||
run_sync(repo)
|
||||
|
||||
readme = run(
|
||||
["git", "show", "HEAD:README.md"],
|
||||
cwd=repo,
|
||||
check=False,
|
||||
)
|
||||
self.assertEqual(readme.returncode, 0, msg=readme.stderr)
|
||||
self.assertEqual(readme.stdout, "manual branch note\n")
|
||||
for relative, expected in unmanaged_files.items():
|
||||
result = run(
|
||||
["git", "show", f"HEAD:{relative}"],
|
||||
cwd=repo,
|
||||
check=False,
|
||||
)
|
||||
self.assertEqual(result.returncode, 0, msg=result.stderr)
|
||||
self.assertEqual(result.stdout, expected)
|
||||
|
||||
for relative in stale_managed_files:
|
||||
result = run(
|
||||
["git", "cat-file", "-e", f"HEAD:{relative}"],
|
||||
cwd=repo,
|
||||
check=False,
|
||||
)
|
||||
self.assertNotEqual(result.returncode, 0, msg=relative)
|
||||
|
||||
for path in (
|
||||
"AGENTS.md",
|
||||
@@ -171,6 +207,12 @@ class BuildTslPlaybookTests(unittest.TestCase):
|
||||
):
|
||||
git(repo, "cat-file", "-e", f"HEAD:{path}")
|
||||
|
||||
first_publish = git(repo, "rev-parse", "HEAD").stdout.strip()
|
||||
git(repo, "checkout", "main")
|
||||
run_sync(repo)
|
||||
second_publish = git(repo, "rev-parse", "HEAD").stdout.strip()
|
||||
self.assertEqual(second_publish, first_publish)
|
||||
|
||||
def test_sync_creates_new_branch_without_source_files(self):
|
||||
if shutil.which("bash") is None:
|
||||
self.skipTest("bash is required to run sync workflow script")
|
||||
|
||||
Reference in New Issue
Block a user