Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Keep contribution-policy links scoped to the PR template

pulse-triage[bot]f0bc8f11ebc8
diff --git a/scripts/tests/test_repo_docs_link_drift.py b/scripts/tests/test_repo_docs_link_drift.py
index eae0c5f2af..c5289b7378 100644
--- a/scripts/tests/test_repo_docs_link_drift.py
+++ b/scripts/tests/test_repo_docs_link_drift.py
@@ -21,6 +21,16 @@ ALLOWED_BRANCH_TIP_DOC_URLS = {
"https://github.com/rcourtman/Pulse/blob/main/docs/AI_TRANSPARENCY.md",
}
+# GitHub renders this template for new contributor conversations, not from a
+# shipped Pulse runtime. It must describe the current contribution policy.
+# Keep the exception bound to this exact file and anchor, not runtime links or
+# other branch-tip documentation in the template.
+ALLOWED_REPOSITORY_POLICY_URLS = {
+ ".github/PULL_REQUEST_TEMPLATE.md": {
+ "https://github.com/rcourtman/Pulse/blob/main/CONTRIBUTING.md#sharing-a-tested-patch",
+ },
+}
+
SKIP_DIR_NAMES = {
".claude",
".git",
@@ -68,7 +78,40 @@ def should_skip(rel_path: str) -> bool:
return False
+def branch_tip_docs_links(rel_path: str, content: str) -> list[str]:
+ for allowed_url in ALLOWED_BRANCH_TIP_DOC_URLS | ALLOWED_REPOSITORY_POLICY_URLS.get(rel_path, set()):
+ # An appended path, query or different anchor is not the reviewed URL.
+ content = re.sub(re.escape(allowed_url) + r"(?=$|[\s\"'<>\)])", "", content)
+ return [match.group(0) for pattern in FORBIDDEN_PATTERNS if (match := pattern.search(content))]
+
+
class RepoDocsLinkDriftTest(unittest.TestCase):
+ def test_current_contribution_policy_is_allowed_only_in_the_pr_template(self) -> None:
+ policy_url = next(iter(ALLOWED_REPOSITORY_POLICY_URLS[".github/PULL_REQUEST_TEMPLATE.md"]))
+ link = f"[Sharing a tested patch]({policy_url})."
+ self.assertEqual(branch_tip_docs_links(".github/PULL_REQUEST_TEMPLATE.md", link), [])
+ for runtime_path in ("frontend-modern/src/help.ts", "internal/api/help.go", ".github/workflows/release.yml"):
+ with self.subTest(path=runtime_path):
+ self.assertTrue(branch_tip_docs_links(runtime_path, link))
+
+ def test_policy_exception_does_not_allow_other_or_extended_branch_tip_links(self) -> None:
+ policy_url = next(iter(ALLOWED_REPOSITORY_POLICY_URLS[".github/PULL_REQUEST_TEMPLATE.md"]))
+ for url in (
+ "https://github.com/rcourtman/Pulse/blob/main/docs/API.md",
+ policy_url.replace("main", "master"),
+ policy_url.replace("Pulse", "AnotherRepo"),
+ policy_url.replace("#sharing-a-tested-patch", "#another-anchor"),
+ policy_url + "?extra=1",
+ policy_url + "-extra",
+ ):
+ with self.subTest(url=url):
+ self.assertTrue(branch_tip_docs_links(".github/PULL_REQUEST_TEMPLATE.md", f"[Guide]({url})"))
+ self.assertFalse(should_skip(".github/PULL_REQUEST_TEMPLATE.md"))
+
+ def test_standing_triage_disclosure_remains_allowed(self) -> None:
+ for url in ALLOWED_BRANCH_TIP_DOC_URLS:
+ self.assertEqual(branch_tip_docs_links("internal/api/help.go", f"[Triage]({url})"), [])
+
def test_runtime_files_do_not_reference_branch_tip_docs(self) -> None:
offenders: list[str] = []
@@ -85,13 +128,7 @@ class RepoDocsLinkDriftTest(unittest.TestCase):
except UnicodeDecodeError:
continue
- for allowed_url in ALLOWED_BRANCH_TIP_DOC_URLS:
- content = content.replace(allowed_url, "")
-
- for pattern in FORBIDDEN_PATTERNS:
- match = pattern.search(content)
- if match:
- offenders.append(f"{rel_path}: {match.group(0)}")
+ offenders.extend(f"{rel_path}: {link}" for link in branch_tip_docs_links(rel_path, content))
self.assertEqual(
offenders,