Skip to content

Commit 8a65c81

Browse files
ci(papers): require stable PySR_Docs URL when using image URLs
1 parent db4f874 commit 8a65c81

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

scripts/validate_papers_yml.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
DATE_RE = re.compile(r"^\d{4}-\d{2}-\d{2}$")
4040
IMAGE_EXT_RE = re.compile(r"\.(png|jpe?g|webp)$", re.IGNORECASE)
4141
TEMP_BOT_BRANCH_RE = re.compile(r"/paper-images/pr-\d+(/|$)")
42+
ALLOWED_DOCS_URL_RE = re.compile(
43+
r"^https?://raw\.githubusercontent\.com/MilesCranmer/PySR_Docs/(master|refs/heads/master)/images/[^\s]+$",
44+
re.IGNORECASE,
45+
)
4246

4347

4448
def fail(msg: str) -> "NoReturn":
@@ -111,11 +115,16 @@ def main() -> None:
111115
image_s = image.strip()
112116

113117
if image_s.startswith("http://") or image_s.startswith("https://"):
114-
# Reject temporary bot-branch URLs (these are not stable and shouldn't
115-
# be used in papers.yml).
118+
# We expect authors to upload an image with the PR. URLs are typically
119+
# only used after a maintainer moves images to PySR_Docs.
120+
# Allow only the stable raw.githubusercontent.com location in PySR_Docs.
116121
if TEMP_BOT_BRANCH_RE.search(image_s):
117122
errors.append(
118-
f"{prefix}.image: points to temporary bot branch URL; use a stable URL (e.g. PySR_Docs master)"
123+
f"{prefix}.image: points to temporary bot branch URL; use a local uploaded image path (preferred)"
124+
)
125+
elif not ALLOWED_DOCS_URL_RE.match(image_s):
126+
errors.append(
127+
f"{prefix}.image: URL must be the stable PySR_Docs raw URL (or upload an image in this PR)"
119128
)
120129
else:
121130
# Must be a basename only (no paths)

0 commit comments

Comments
 (0)