Skip to content

Commit 9599ba7

Browse files
author
CometAPI
committed
fix: bind canonical Markdown workflow targets
1 parent 8314fa6 commit 9599ba7

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

scripts/_checks.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ def _actions_path_has_canonical_url(
166166
if canonical is None:
167167
return False
168168

169+
for link in _MARKDOWN_LINK.finditer(text):
170+
if link.start("target") <= path.start() and path.end() <= link.end("target"):
171+
return _CANONICAL_ACTIONS_URL.fullmatch(link.group("target")) is not None
172+
169173
for attribute in _RAW_HTML_URL_ATTRIBUTE.finditer(text):
170174
if attribute.start("url") <= path.start() and path.end() <= attribute.end("url"):
171175
return _CANONICAL_ACTIONS_URL.fullmatch(attribute.group("url")) is not None
@@ -186,10 +190,7 @@ def _actions_path_has_canonical_url(
186190
if boundary == "<":
187191
return canonical.start() >= 2 and text[canonical.start() - 2].isspace()
188192
if boundary == "(":
189-
before_boundary = canonical.start() - 2
190-
return (
191-
before_boundary < 0 or text[before_boundary].isspace() or text[before_boundary] == "]"
192-
)
193+
return canonical.start() == 1 or text[canonical.start() - 2].isspace()
193194
return False
194195

195196

tests/test_release_documents.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,8 @@ def test_release_evidence_rejects_obsolete_workflow_reference_marker(
706706
"actions/runs/30515861246)",
707707
"mailto:(https://github.com/cometapi-dev/cometapi-python/actions/runs/30515861246)",
708708
"prefix<https://github.com/cometapi-dev/cometapi-python/actions/runs/30515861246>",
709+
"[evil](mailto:foo](https://github.com/cometapi-dev/cometapi-python/"
710+
"actions/runs/30515861246))",
709711
"http://github.com/cometapi-dev/cometapi-python/actions/runs/30511373822",
710712
"https://evil.example/?next=https%3A%2F%2Fgithub.com%2Fcometapi-dev%2F"
711713
"cometapi-python%2Factions%2Fruns%2F30511373822",
@@ -777,6 +779,29 @@ def test_release_evidence_accepts_canonical_raw_html_anchor(
777779
require_public_preview_docs()
778780

779781

782+
def test_release_evidence_accepts_canonical_markdown_link(
783+
releasable_documents: Path,
784+
) -> None:
785+
evidence = _release_evidence_block().replace(
786+
"- Release workflow https://github.com/cometapi-dev/cometapi-python/actions/runs/"
787+
"30515861246",
788+
"- Release workflow [canonical publication run](https://github.com/"
789+
"cometapi-dev/cometapi-python/actions/runs/30515861246)",
790+
1,
791+
)
792+
for name in ("ROADMAP.md", "RELEASING.md"):
793+
with (releasable_documents / name).open("a", encoding="utf-8") as stream:
794+
stream.write(evidence)
795+
_replace(
796+
releasable_documents,
797+
"CHANGELOG.md",
798+
"# Changelog\n",
799+
"# Changelog\n\n## [0.1.2] - 2026-07-30\n\nHistory.\n",
800+
)
801+
802+
require_public_preview_docs()
803+
804+
780805
def test_fenced_release_evidence_is_not_accepted_as_history(
781806
releasable_documents: Path,
782807
) -> None:

0 commit comments

Comments
 (0)