Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions scripts/publish_release_notes_to_discourse.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ def format_release_content(config: dict[str, str]) -> tuple[str, str]:
config["RELEASE_BODY"],
)

# Convert user mentions to GitHub profile links to avoid Discourse API limit of 10 mentions per post
# Replace @username with [@username](https://github.com/username)
release_body = re.sub(r"@([\w-]+)", r"[@\1](https://github.com/\1)", release_body)

content = f"""A new release of **{repo_name}** is now available!

## 📦 Release Information
Expand Down
47 changes: 45 additions & 2 deletions scripts/test_publish_release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_non_pymc_links_unchanged(self):
"RELEASE_URL": "https://github.com/pymc-devs/pymc/releases/tag/v1.0.0",
}

title, content = format_release_content(config)
_title, content = format_release_content(config)

# Check that pymc-devs/pymc PR link is formatted
assert "[#456](https://github.com/pymc-devs/pymc/pull/456)" in content
Expand Down Expand Up @@ -144,7 +144,7 @@ def test_already_formatted_links_not_double_formatted(self):
"RELEASE_URL": "https://github.com/pymc-devs/pymc/releases/tag/v1.0.0",
}

title, content = format_release_content(config)
_title, content = format_release_content(config)

# Already formatted link should remain unchanged
assert "[#123](https://github.com/pymc-devs/pymc/pull/123)" in content
Expand All @@ -153,3 +153,46 @@ def test_already_formatted_links_not_double_formatted(self):

# Raw link should be formatted
assert "[#456](https://github.com/pymc-devs/pymc/pull/456)" in content

def test_user_mentions_converted_to_links(self):
"""Test that user mentions are converted to GitHub profile links."""
release_body = """<!-- Release notes generated using configuration in .github/release.yml at main -->

## What's Changed
### Major Changes 🛠
* Bump PyTensor dependency by @ricardoV94 in https://github.com/pymc-devs/pymc/pull/7910
* Remove deprecated parameter by @williambdean in https://github.com/pymc-devs/pymc/pull/7886

### New Features 🎉
* Implement feature by @asifzubair in https://github.com/pymc-devs/pymc/pull/7884

### Bugfixes 🪲
* Fix bug by @tomicapretto in https://github.com/pymc-devs/pymc/pull/7877

## New Contributors
* @asifzubair made their first contribution in https://github.com/pymc-devs/pymc/pull/7871
* @user-with-dashes contributed in https://github.com/pymc-devs/pymc/pull/7872
* @another_user123 helped out in https://github.com/pymc-devs/pymc/pull/7873

**Full Changelog**: https://github.com/pymc-devs/pymc/compare/v5.25.1...v5.26.0"""

config = {
"RELEASE_TAG": "v5.26.0",
"REPO_NAME": "pymc-devs/pymc",
"RELEASE_BODY": release_body,
"RELEASE_URL": "https://github.com/pymc-devs/pymc/releases/tag/v5.26.0",
}

_title, content = format_release_content(config)

# Check that user mentions are converted to links
assert "[@ricardoV94](https://github.com/ricardoV94)" in content
assert "[@williambdean](https://github.com/williambdean)" in content
assert "[@asifzubair](https://github.com/asifzubair)" in content
assert "[@tomicapretto](https://github.com/tomicapretto)" in content
assert "[@user-with-dashes](https://github.com/user-with-dashes)" in content
assert "[@another_user123](https://github.com/another_user123)" in content

# Check that PR links are still formatted correctly
assert "[#7910](https://github.com/pymc-devs/pymc/pull/7910)" in content
assert "[#7886](https://github.com/pymc-devs/pymc/pull/7886)" in content